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: [RFC:patch] c99 6.2.2: static vs extern


DJ Delorie <dj@redhat.com> writes:

> > You missed footnote 23; the standard actually reads:
> > 
> > ... prior declaration of that identifier is visible, 23) ...
> > 
> > 23) As specified in 6.2.1, the later declaration might hide the prior
> >     declaration.
> 
> I read that, I thought that applied to function parameter scope
> declarations, which hide file scope declarations, or other actual
> declarations of variables (of the "int x;" variety).  

The paragraph that references this footnote speaks about 'the later
declaration' (the one with 'extern') and 'the prior declaration' (that
specified internal or external linkage).  When the footnote uses the
same words, it refers to the same declarations.

I don't believe you can declare a function parameter as 'extern',
see 6.7.5.3 paragraph 2.

> Since "extern" is called out specially in para 4, does that imply
> that it doesn't automatically hide outer scoped declarations?

No.  It means that if you declare it 'static' or don't supply a
specifier, paragraph 4 does not apply (except see paragraph 5 for
function types).  In particular,

extern int i;
static int i;

is not valid C, and neither is

static int i;
int i;

> Plus, wrt 6.2.2 para 4, at the point where we're parsing the "extern"
> maybe the global "static" is still visible?  How does one create a
> situation that 6.2.2 para 4 would relate to?

One says

static int i;
extern int i;

> > So, I think the existing behaviour is correct; it prints an error
> > message for a case ISO C says is undefined.
> 
> I thought that at first too ;-)

I still think so.

-- 
- Geoffrey Keating <geoffk@geoffk.org>


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