This is the mail archive of the gcc-bugs@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]

[Bug c/17205] [3.5 Regression] Strange behaviour when function prototypes appear inside other functions


------- Additional Comments From jsm at polyomino dot org dot uk  2004-08-27 09:44 -------
Subject: Re:  Strange behaviour when function prototypes appear
 inside other functions

On Fri, 27 Aug 2004, pinskia at gcc dot gnu dot org wrote:

> This is not valid C.
> We should be warning or erroring out.

To be precise, it's compile-time undefined for block-scope function 
declarations to have any storage-class specifier other than extern.  I 
don't object to removing this undocumented extension, but this bug report 
shows it does have users.

The problem appears with a compiler from before my patch for bug 13801 
went in, so it is not a problem caused by that patch.  However, an 
appropriate fix if we keep the extension would probably be along the lines 
I suggested for a possible future refinement to that patch: add an 
internal scope between the external scope and the file scope, which stores 
hidden declarations of objects and functions with internal linkage used 
for type checking the same way as the external scope, then merge the 
handling of static function declarations at block scope with the handling 
of external and file scope declarations.  (So everything with external 
linkage goes in the external scope, in addition to its proper scope, and 
everything with internal linkage in a given translation unit goes in the 
internal scope, in addition to its proper scope, static function 
declarations at block scope are defined as having internal linkage, and 
the internal scope, just like the external scope, accumulates composite 
type information from all declarations, while the file scope and scopes 
below that have the type information from visible declarations only.)

I might look at doing this, but not immediately given the problem isn't 
caused by my patch.



-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17205


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