This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Help w/-Wtraditional warning about ISO C style function definitions
- From: "Kaveh R. Ghazi" <ghazi at caip dot rutgers dot edu>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 6 Mar 2002 16:58:43 -0500 (EST)
- Subject: 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); }
;