This is the mail archive of the
mailing list for the GCC project.
Re: Couldn't `function(arg[static 3])` imply nonnull and array size in C?
- From: Joseph Myers <joseph at codesourcery dot com>
- To: Manuel López-Ibáñez <lopezibanez at gmail dot com>
- Cc: Martin Uecker <uecker at eecs dot berkeley dot edu>, GCC Development <gcc at gcc dot gnu dot org>, Jason Merrill <jason at redhat dot com>
- Date: Fri, 8 May 2015 11:04:22 +0000
- Subject: Re: Couldn't `function(arg[static 3])` imply nonnull and array size in C?
- Authentication-results: sourceware.org; auth=none
- References: <CAEcf3Nzxt=uATHYdYu+aLBoKaB8Wyy=AztF=ZXn-atKpKhVU3Q at mail dot gmail dot com> <20150503224039 dot 28ab0404 at lemur> <55479E41 dot 2070108 at gmail dot com> <20150507105144 dot 277cc59b at lemur> <CAESRpQDGdrshKp21GrZEJsOTST5C530=j=VR=116NVEyvj-ieA at mail dot gmail dot com>
On Fri, 8 May 2015, Manuel LÃpez-IbÃÃez wrote:
> "At present, the first parameter in a function prototype must have
> some type specifier that is not an attribute specifier; this resolves
> an ambiguity in the interpretation of void f(int (__attribute__((foo))
> But I don't understand the example given in the docs.
This means that this example is interpreted as
void f(int __attribute__((foo)) x);
void f(int (*)(int __attribute__((foo)) x));
(with implicit int and adjustment of a parameter declared with function
type to have pointer to function type), which would be a valid parse if
you only consider the syntax productions without the above disambiguation.
Cf C11 126.96.36.199#11 "If, in a parameter declaration, an identifier can be
treated either as a typedef name or as a parameter name, it shall be taken
as a typedef name." (disambiguating cases such as "void f(int (T))" where
T is a typedef name). And some other cases in C90 that became irrelevant
in C99 with the removal of implicit int.
Joseph S. Myers