This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

C++ PATCH: PR 15025


This patch fixes PR 15025, wherein we failed to check (when declaring
a non-template class) that the same class had not already been
declared as a template.

--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com

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++/15025
	* g++.dg/template/redecl1.C: New test.

Index: cp/decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/decl.c,v
retrieving revision 1.1174.2.19
diff -c -5 -p -r1.1174.2.19 decl.c
*** cp/decl.c	1 Apr 2004 20:47:21 -0000	1.1174.2.19
--- cp/decl.c	23 May 2004 21:00:22 -0000
*************** xref_tag (enum tag_types tag_code, tree 
*** 9461,9470 ****
--- 9461,9477 ----
      }
    else
      {
        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: testsuite/g++.dg/template/redecl1.C
===================================================================
RCS file: testsuite/g++.dg/template/redecl1.C
diff -N testsuite/g++.dg/template/redecl1.C
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/template/redecl1.C	23 May 2004 21:00:22 -0000
***************
*** 0 ****
--- 1,4 ----
+ // PR c++/15025
+ 
+ template <int> struct X; 
+ struct X {}; // { dg-error "" }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]