[RFC]: allowing c99 for-loop scope in gnu89?

Joseph S. Myers jsm28@cam.ac.uk
Thu Jun 20 10:46:00 GMT 2002


On Thu, 20 Jun 2002, Kaveh R. Ghazi wrote:

> I'm not sure whether you're for or against my proposal, but I'm
> suggesting we relax the check in check_for_loop_decls. to a pedwarn
> instead of a hard error.
> 
> A quick grep shows this is no different to how we handle other c99
> features, for example "long long", complex types, variable sized
> arrays and flexible array members.

I'm against making the change by a simplistic change to 
check_for_loop_decls only.  The other features you mention do not require 
features that involve quiet changes to programs valid in both standards.  
(Compound literals are marginal; some aspects of their lifetimes may be 
confusing in the absence of the new scopes, as discussed in the Rationale, 
but in general they can be used without them.  Whereas much of the point 
of for loop decls is to make the variable more local.)

The right way to do this would involve arranging for the presence of the
for loop decl outside C99 mode to cause the new scopes for the for loop to
be present (that for the loop as a whole, and preferably that for the
body).  You'll need to produce the patch that does this to show it doesn't
cause undue complexity.

-- 
Joseph S. Myers
jsm28@cam.ac.uk



More information about the Gcc mailing list