From 42681840e394597dfdd824248e4207d349b51187 Mon Sep 17 00:00:00 2001 From: paolo Date: Fri, 25 Oct 2013 16:26:10 +0000 Subject: [PATCH] /cp 2013-10-25 Paolo Carlini PR c++/58878 * pt.c (check_template_shadow): Don't skip declarations in inline member templates. /testsuite 2013-10-25 Paolo Carlini PR c++/58878 * g++.dg/template/pr58878.C: New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@204071 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/ChangeLog | 6 ++++ gcc/cp/pt.c | 3 +- gcc/testsuite/ChangeLog | 5 +++ gcc/testsuite/g++.dg/template/pr58878.C | 61 +++++++++++++++++++++++++++++++++ 4 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/template/pr58878.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index dfe4a3f..297d015 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2013-10-25 Paolo Carlini + + PR c++/58878 + * pt.c (check_template_shadow): Don't skip declarations in inline + member templates. + 2013-10-25 Tobias Burnus PR other/33426 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index cbb0339a..224be8b 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -3511,7 +3511,8 @@ check_template_shadow (tree decl) name inside a class. We check TPFI to avoid duplicate errors for inline member templates. */ if (decl == olddecl - || TEMPLATE_PARMS_FOR_INLINE (current_template_parms)) + || (DECL_TEMPLATE_PARM_P (decl) + && TEMPLATE_PARMS_FOR_INLINE (current_template_parms))) return true; error ("declaration of %q+#D", decl); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 044b76b..ac5ab6d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2013-10-25 Paolo Carlini + + PR c++/58878 + * g++.dg/template/pr58878.C: New. + 2013-10-25 Marc Glisse * gcc.dg/tree-ssa/alias-23.c: New file. diff --git a/gcc/testsuite/g++.dg/template/pr58878.C b/gcc/testsuite/g++.dg/template/pr58878.C new file mode 100644 index 0000000..adad9fe --- /dev/null +++ b/gcc/testsuite/g++.dg/template/pr58878.C @@ -0,0 +1,61 @@ +// PR c++/58878 + +// Template-members of non-template class +struct A +{ + template // { dg-error "shadows" } + void f() + { + int t = 1; // { dg-error "declaration" } + } + + template + void g(); +}; + +template // { dg-error "shadows" } +void A::g() +{ + int t = 2; // { dg-error "declaration" } +} + +// (Non-template) Members of template class +template // { dg-error "shadows" } +struct B +{ + void f() + { + int t = 3; // { dg-error "declaration" } + } + + void g(); +}; + +template // { dg-error "shadows" } +void B::g() +{ + int t = 4; // { dg-error "declaration" } +} + +// Template members of template class +template // { dg-error "shadows" } +struct C +{ + template // { dg-error "shadows" } + void f() + { + int t = 5; // { dg-error "declaration" } + int s = 6; // { dg-error "declaration" } + } + + template + void g(); +}; + +template // { dg-error "shadows" } +template // { dg-error "shadows" } +void C::g() +{ + int t = 7; // { dg-error "declaration" } + int s = 8; // { dg-error "declaration" } +} -- 2.7.4