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]

redefining typedefs extension





This extension allows typedefs to be redefined to the "same" type; "same"
is defined below, but in practice is more lenient than the similar extension
invoked by the "traditional" flag.

The primary reason for this extension is to allow gcc to read MS windows
header files, but its also a reasonable extension in it's own right.

If no one sees a problem with it, or objects to it, I'll commit this
in a few days.

                                                  -gavin...



	* c-decl.c (redeclaration_error_message): Allow typedefs to
	be redefined to the same type.
	* extend.text: Document the extension: Redefining Typedefs.


Index: extend.texi
===================================================================
RCS file: /cvs/cvsfiles/devo/gcc/extend.texi,v
retrieving revision 1.96
diff -c -p -r1.96 extend.texi
*** extend.texi	1999/01/15 07:57:34	1.96
--- extend.texi	1999/04/24 21:58:36
*************** C++ Language}, for extensions that apply
*** 71,76 ****
--- 71,77 ----
  			 function.
  * Return Address::      Getting the return or frame address of a function.
  * Other Builtins::      Other built-in functions.
+ * Redefining Typedefs:: Allow typedefs to be redefined.
  @end menu
  @end ifset
  @ifclear INTERNALS
*************** C++ Language}, for extensions that apply
*** 119,124 ****
--- 120,126 ----
  * Function Names::	Printable strings which are the name of the current
  			 function.
  * Return Address::      Getting the return or frame address of a function.
+ * Redefining Typedefs:: Allow typedefs to be redefined.
  @end menu
  @end ifclear
  
*************** never return 1 when you call the inline 
*** 3104,3109 ****
--- 3106,3128 ----
  or constructor expression (@pxref{Constructors}) and will not return 1
  when you pass a constant numeric value to the inline function unless you
  specify the @samp{-O} option.
+ 
+ @node Redefining Typedefs
+ @section Redefining typedef names
+ @cindex typedefs, typedef names
+ 
+ GNU CC allows you to redefine a typedef name, as long as the previous
+ type and the new type are the same.  ISO/ANSI does not allow typedefs
+ to be redefined.
+ 
+ Two types, T1 and T2, are the same for the purposes of this extension
+ if this would be legal:
+ 
+ @example
+   extern T1 var;
+   extern T2 var;
+ @end example
+ 
  
  @node C++ Extensions
  @chapter Extensions to the C++ Language
Index: c-decl.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gcc/c-decl.c,v
retrieving revision 1.223
diff -c -p -r1.223 c-decl.c
*** c-decl.c	1999/01/15 07:57:14	1.223
--- c-decl.c	1999/04/24 21:58:46
*************** redeclaration_error_message (newdecl, ol
*** 2673,2678 ****
--- 2673,2681 ----
        if (flag_traditional 
  	  && TYPE_MAIN_VARIANT (TREE_TYPE (olddecl)) == TREE_TYPE (newdecl))
  	return 0;
+       if (! pedantic
+ 	  && 1 == comptypes (TREE_TYPE (olddecl), TREE_TYPE (newdecl)))
+ 	return 0;
        if (DECL_IN_SYSTEM_HEADER (olddecl) || DECL_IN_SYSTEM_HEADER (newdecl))
  	return 0;
        return "redefinition of `%s'";


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