C++ PATCH: PR 8164

Mark Mitchell mark@codesourcery.com
Fri Jul 11 08:52:00 GMT 2003


I've fixed this bug on the 3.3 branch -- at least as well as 3.3 is
ever going to do.  We now issue an error message, rather than
crashing.  With the new parser, some of this may become unnecessary.

Tested on i686-pc-linux-gnu, applied on the branch.  (Except that I
will also add a slightly modified version of the test to the branch.)

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

2003-07-11  Mark Mitchell  <mark@codesourcery.com>

	PR c++/8164
	* decl.c (duplicate_decls): Avoid mangling names unnecessarily.

2003-07-11  Mark Mitchell  <mark@codesourcery.com>

	PR c++/8164
	* g++.dg/template/nontype2.C: New test.

Index: cp/decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/decl.c,v
retrieving revision 1.965.2.53
diff -c -5 -p -r1.965.2.53 decl.c
*** cp/decl.c	27 Jun 2003 21:28:13 -0000	1.965.2.53
--- cp/decl.c	11 Jul 2003 08:28:07 -0000
*************** duplicate_decls (newdecl, olddecl)
*** 3512,3522 ****
  	    return 0;
  	}
  
        /* Already complained about this, so don't do so again.  */
        else if (current_class_type == NULL_TREE
! 	  || IDENTIFIER_ERROR_LOCUS (DECL_ASSEMBLER_NAME (newdecl)) != current_class_type)
  	{
  	  error ("conflicting types for `%#D'", newdecl);
  	  cp_error_at ("previous declaration as `%#D'", olddecl);
  	}
      }
--- 3512,3524 ----
  	    return 0;
  	}
  
        /* Already complained about this, so don't do so again.  */
        else if (current_class_type == NULL_TREE
! 	       || !DECL_ASSEMBLER_NAME_SET_P (newdecl)
! 	       || (IDENTIFIER_ERROR_LOCUS (DECL_ASSEMBLER_NAME (newdecl)) 
! 		   != current_class_type))
  	{
  	  error ("conflicting types for `%#D'", newdecl);
  	  cp_error_at ("previous declaration as `%#D'", olddecl);
  	}
      }
Index: testsuite/g++.dg/template/nontype2.C
===================================================================
RCS file: testsuite/g++.dg/template/nontype2.C
diff -N testsuite/g++.dg/template/nontype2.C
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/template/nontype2.C	11 Jul 2003 08:48:20 -0000	1.1.2.2
***************
*** 0 ****
--- 1,11 ----
+ template <bool> struct A {};
+  
+ template <bool> struct B
+ {
+   void foo()
+   {
+     const int i=0;
+     typedef A< i<=1 > C; // { dg-error "" } 
+     typedef A< i<=2 > C; // { dg-error "" } 
+   }
+ };



More information about the Gcc-patches mailing list