This is the mail archive of the gcc@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: Couldn't `function(arg[static 3])` imply nonnull and array size in C?


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))
> x))"
> https://gcc.gnu.org/onlinedocs/gcc/Attribute-Syntax.html#Attribute-Syntax
> 
> 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);

and not

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 6.7.6.3#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
joseph@codesourcery.com

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