This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Help w/-Wtraditional warning about ISO C style function definitions
- From: Neil Booth <neil at daikokuya dot demon dot co dot uk>
- To: "Kaveh R. Ghazi" <ghazi at caip dot rutgers dot edu>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Thu, 7 Mar 2002 22:08:38 +0000
- Subject: Re: Help w/-Wtraditional warning about ISO C style function definitions
- References: <200203072128.QAA22530@caip.rutgers.edu>
Kaveh R. Ghazi wrote:-
> Ok, then I suppose I'll have to keep state. This seems to work
> properly, are there any obvious problems with this approach?
>
> If not, I'll proceed to add docs and a testcase and submit it.
>
> Thanks,
> --Kaveh
>
>
> extdef:
> fndef
> + { parsing_iso_function_signature = false; } /* Reset after a definition */
> | datadef
> + { parsing_iso_function_signature = false; } /* Reset after a declaration */
This isn't enough I think. It's possible for other code paths to go
through parmlist_2, and ultimately get to old_style_parm_decls without
passing through the above. e.g. nested functions. There may be
others. The C parser is very fragile; this kind of thing is much
simpler and safer with a recursive descent parser IMO.
Does this introduce any new shift / reduce conflicts?
> old_style_parm_decls:
> + {
> + if (warn_traditional && parsing_iso_function_signature)
> + warning ("traditional C rejects ISO C style function definitions[3]");
> + }
> + old_style_parm_decls_1
> +
> +old_style_parm_decls_1:
> /* empty */
> | datadecls
> | datadecls ELLIPSIS
> @@ -2524,7 +2535,9 @@ parmlist_2: /* empty */
> error ("ISO C requires a named argument before `...'");
> }
> | parms
> - { $$ = get_parm_info (1); }
> + { $$ = get_parm_info (1);
> + parsing_iso_function_signature = true;
> + }
Neil.