[cfe-dev] A construct clang accepts and gcc don't. Who is right?

Sebastian Redl sebastian.redl at getdesigned.at
Sun Dec 28 08:58:45 PST 2008


Paolo Bolzoni wrote:
> dear cfe-dev list,
> I was trying to make a clang AST with a ConstantArrayType object with array
> size modifier `static'.
>
> The first try:
> void f(int a[static 10]);
>
> did not work because clang simplify the array parameter to a pointer.
>   
I'm not sure how Clang handles static here. It might remain only on the 
declaration and be dropped from the type. But this is contradicted by 
the fact that ArrayType::ArraySizeModifier has the value Static. So 
there is something wrong with Clang's handling of the parameter.
> So I thought to add a dimension, because you can't simplify a multi dimension
> array to pointer and I tried:
>
> void f(int a[10][static 10]);
> and I had my ConstantArrayType object with size modifier `static'.
>   
Clang should reject this. See C99 6.7.5.2p1: "[...] the keyword static 
shall appear only in a declaration of a function parameter with an array 
type, and then only in the outermost array type derivation."
> But gcc in the same code says:
> `error: static or type qualifiers in non-parameter array declarator'
> and fails the -fsyntax-only's checks.
>
> So I have to two questions:
> - About the second? Who is right?
>   
GCC is right.

Sebastian



More information about the cfe-dev mailing list