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: Fix PR 16193


This patch fixes PR 16193.  Applied as obvious to the mainline, after
brief testing on i686-pc-linux-gnu.

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

2004-06-27  Mark Mitchell  <mark@codesourcery.com>

	PR c++/16193
	* parser.c (cp_parser_set_decl_spec_type): Refine test for
	redefinition of built-in types.

2004-06-27  Mark Mitchell  <mark@codesourcery.com>

	PR c++/16193
	* g++.dg/parse/redef1.C: New test.

Index: cp/parser.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/parser.c,v
retrieving revision 1.218
diff -c -5 -p -r1.218 parser.c
*** cp/parser.c	27 Jun 2004 03:03:55 -0000	1.218
--- cp/parser.c	27 Jun 2004 18:52:09 -0000
*************** static void
*** 15425,15441 ****
  cp_parser_set_decl_spec_type (cp_decl_specifier_seq *decl_specs,
  			      tree type_spec,
  			      bool user_defined_p)
  {
    decl_specs->any_specifiers_p = true;
!   if (decl_specs->type)
!     {
!       if (decl_specs->specs[(int)ds_typedef] && !user_defined_p)
! 	decl_specs->redefined_builtin_type = type_spec;
!       else
! 	decl_specs->multiple_types_p = true;
!     }
    else
      {
        decl_specs->type = type_spec;
        decl_specs->user_defined_type_p = user_defined_p;
      }
--- 15425,15449 ----
  cp_parser_set_decl_spec_type (cp_decl_specifier_seq *decl_specs,
  			      tree type_spec,
  			      bool user_defined_p)
  {
    decl_specs->any_specifiers_p = true;
!  
!   /* If the user tries to redeclare a built-in type (with, for example,
!      in "typedef int wchar_t;") we remember that this is what
!      happened.  In system headers, we ignore these declarations so
!      that G++ can work with system headers that are not C++-safe.  */
!   if (decl_specs->specs[(int) ds_typedef] 
!       && !user_defined_p
!       && (decl_specs->type
! 	  || decl_specs->specs[(int) ds_long]
! 	  || decl_specs->specs[(int) ds_short]
! 	  || decl_specs->specs[(int) ds_unsigned]
! 	  || decl_specs->specs[(int) ds_signed]))
!     decl_specs->redefined_builtin_type = type_spec;
!   else if (decl_specs->type)
!     decl_specs->multiple_types_p = true;
    else
      {
        decl_specs->type = type_spec;
        decl_specs->user_defined_type_p = user_defined_p;
      }
Index: testsuite/g++.dg/parse/redef1.C
===================================================================
RCS file: testsuite/g++.dg/parse/redef1.C
diff -N testsuite/g++.dg/parse/redef1.C
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/parse/redef1.C	27 Jun 2004 18:52:41 -0000
***************
*** 0 ****
--- 1,10 ----
+ // { dg-options "" }
+ // PR c++/16193
+ 
+ # 1 "syshdr1.C"
+ # 1 "syshdr1.h" 1 3
+ // Redefinitions of built-in types are allowed in system headers so
+ // that G++ will work with system headers that are not fully
+ // C++-aware.
+ typedef long wchar_t;
+ # 2 "syshdr1.C" 2


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