PR c++/15025
authormmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 23 May 2004 21:06:56 +0000 (21:06 +0000)
committermmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 23 May 2004 21:06:56 +0000 (21:06 +0000)
* decl.c (xref_tag): Issue errors about redeclaring template
classes as non-template classes.

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

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@82172 138bc75d-0d04-0410-961f-82ee72b054a4

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

index e6a6524..7fd46ac 100644 (file)
@@ -1,5 +1,11 @@
 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
        * name-lookup.c (supplement_binding): Allow redefinitions of
        namespace aliases.
index 65e8800..b666dd7 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 d93b5c9..32d2f17 100644 (file)
@@ -1,5 +1,10 @@
 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
        * g++.dg/other/ns1.C: New test.
 
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 "" }