diff options
author | Jason Merrill <jason@redhat.com> | 2014-01-28 16:04:29 -0500 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2014-01-28 16:04:29 -0500 |
commit | 3807059e82873de1e5d0b8580b4755be7f90c54b (patch) | |
tree | 95949425d523e36db7eedfffc1daaa0ec7c0374a /gcc | |
parent | 1b2b9969c85179ac7f64f2d200cdbdcec7036725 (diff) | |
download | gcc-3807059e82873de1e5d0b8580b4755be7f90c54b.zip gcc-3807059e82873de1e5d0b8580b4755be7f90c54b.tar.gz gcc-3807059e82873de1e5d0b8580b4755be7f90c54b.tar.bz2 |
re PR c++/58632 (ICE reusing template parameter name as class name)
PR c++/58632
* decl.c (lookup_and_check_tag): Ignore template parameters if
scope == ts_current.
* pt.c (check_template_shadow): Don't complain about the injected
class name.
From-SVN: r207208
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/decl.c | 5 | ||||
-rw-r--r-- | gcc/cp/pt.c | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/template/shadow1.C | 4 |
4 files changed, 19 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index c5e24d9..43ba804 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,11 @@ 2014-01-28 Jason Merrill <jason@redhat.com> + PR c++/58632 + * decl.c (lookup_and_check_tag): Ignore template parameters if + scope == ts_current. + * pt.c (check_template_shadow): Don't complain about the injected + class name. + * decl.c (duplicate_decls): Tweak. PR c++/53756 diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index aca96fc..e14e401 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -11982,7 +11982,10 @@ lookup_and_check_tag (enum tag_types tag_code, tree name, if (decl && (DECL_CLASS_TEMPLATE_P (decl) - || DECL_TEMPLATE_TEMPLATE_PARM_P (decl))) + /* If scope is ts_current we're defining a class, so ignore a + template template parameter. */ + || (scope != ts_current + && DECL_TEMPLATE_TEMPLATE_PARM_P (decl)))) decl = DECL_TEMPLATE_RESULT (decl); if (decl && TREE_CODE (decl) == TYPE_DECL) diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 47d07db..6c68bae 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -3527,6 +3527,11 @@ check_template_shadow (tree decl) && TEMPLATE_PARMS_FOR_INLINE (current_template_parms))) return true; + /* Don't complain about the injected class name, as we've already + complained about the class itself. */ + if (DECL_SELF_REFERENCE_P (decl)) + return false; + error ("declaration of %q+#D", decl); error (" shadows template parm %q+#D", olddecl); return false; diff --git a/gcc/testsuite/g++.dg/template/shadow1.C b/gcc/testsuite/g++.dg/template/shadow1.C new file mode 100644 index 0000000..6eb30d0 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/shadow1.C @@ -0,0 +1,4 @@ +// PR c++/58632 + +template<template<int I> class A> // { dg-message "shadows" } +class A {}; // { dg-error "declaration" } |