]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/15025 (accepts redeclaration of template as non-template)
authorMark Mitchell <mark@codesourcery.com>
Sun, 23 May 2004 21:06:56 +0000 (21:06 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Sun, 23 May 2004 21:06:56 +0000 (21:06 +0000)
PR c++/15025
* decl.c (xref_tag): Issue errors about redeclaring template
classes as non-template classes.

PR c++/15025
* g++.dg/template/redecl1.C: New test.

From-SVN: r82172

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/redecl1.C [new file with mode: 0644]

index e6a652443b68090cc75ad192a7d7aa6474feba61..7fd46ac7108b4ec0d2e45b446f3ca4fd1fc19c1c 100644 (file)
@@ -1,3 +1,9 @@
+2004-05-23  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/15025
+       * decl.c (xref_tag): Issue errors about redeclaring template
+       classes as non-template classes.
+
 2004-05-23  Mark Mitchell  <mark@codesourcery.com>
 
        PR c++/14821
index 65e8800beec8dc6771c660229b25479e534e602b..b666dd7105d3f49f0b538372e88864ac28acec41 100644 (file)
@@ -9407,6 +9407,13 @@ xref_tag (enum tag_types tag_code, tree name,
     {
       if (!globalize && processing_template_decl && IS_AGGR_TYPE (t))
        redeclare_class_template (t, current_template_parms);
+      else if (!processing_template_decl 
+              && CLASS_TYPE_P (t)
+              && CLASSTYPE_IS_TEMPLATE (t))
+       {
+         error ("redeclaration of `%T' as a non-template", t);
+         t = error_mark_node;
+       }
     }
 
   POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, t);
index d93b5c9a60e52be3541470bc412833b72a67bb56..32d2f1717e0b45e31c6027bb98d80a6966921be9 100644 (file)
@@ -1,3 +1,8 @@
+2004-05-23  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/15025
+       * g++.dg/template/redecl1.C: New test.
+
 2004-05-23  Mark Mitchell  <mark@codesourcery.com>
 
        PR c++/14821
diff --git a/gcc/testsuite/g++.dg/template/redecl1.C b/gcc/testsuite/g++.dg/template/redecl1.C
new file mode 100644 (file)
index 0000000..1bbf20e
--- /dev/null
@@ -0,0 +1,4 @@
+// PR c++/15025
+
+template <int> struct X; 
+struct X {}; // { dg-error "" }