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]

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


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.


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