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]

Help w/-Wtraditional warning about ISO C style function definitions


Currently our convention is to use traditional style function
definitions to allow for bootstrap with K&R compilers.  Every now and
then some ISO C style ones sneak in.

I was trying to add the capability for -Wtraditional to warn about ISO
C style.  FYI, we would need to avoid warning about stdarg functions
since VPARAMS uses ISO C style when __STDC__ is defined and would
yield spurious warnings.

I thought I had found exactly the right place to put the check, you'll
notice it nicely fits in where fixed argument functions are parsed.
However this part of c-parse.in parses both function *prototypes* as
well as function definitions.  We do use ISO C style prototypes
wrapped by PARAMS and they would be warned about by this change as it
now stands.

I was wondering if there was an easy way to determine when we reach the code
below whether we are in the midst of parsing a function definition,
possibly by examining `current_declspecs' or something similar.

Thanks in advance for any help.

		--Kaveh

diff -rup orig/egcc-CVS20020305/gcc/c-parse.in egcc-CVS20020305/gcc/c-parse.in
--- orig/egcc-CVS20020305/gcc/c-parse.in	Thu Feb 28 15:41:41 2002
+++ egcc-CVS20020305/gcc/c-parse.in	Wed Mar  6 00:00:05 2002
@@ -2524,7 +2524,10 @@ parmlist_2:  /* empty */
 		  error ("ISO C requires a named argument before `...'");
 		}
 	| parms
-		{ $$ = get_parm_info (1); }
+		{ $$ = get_parm_info (1);
+		  if (warn_traditional)
+		    warning ("traditional C rejects ISO C style function definitions");
+		}
 	| parms ',' ELLIPSIS
 		{ $$ = get_parm_info (0); }
 	;


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