error: parameter declarator cannot be qualified

Hi,

What do you think about this code and clang reaction?

struct A
{
static const char * a;
};

const char * A::a = “O.o”;

struct B
{
B(const char * s);
};

struct C
{
C(B& b);
};

class Problem
{
public:
void foo()
{
C c(B(A::a)); // error here
}
};

clang++ x.cpp
x.cpp:23:6: warning: parentheses were disambiguated as a function declarator
[-Wvexing-parse]
C c(B(A::a)); // error here
^~~~~~~~~
x.cpp:23:12: error: parameter declarator cannot be qualified
C c(B(A::a)); // error here

1 warning and 1 error generated.

> clang -v
FreeBSD clang version 3.1 (branches/release_31 156863) 20120523
Target: x86_64-unknown-freebsd9.0
Thread model: posix

The error looks correct to me. This line conforms to the grammar rules of a function-declaration, so it is interpreted as one. The diagnostic on trunk is a bit better:

:23:15: error: parameter declarator cannot be qualified
C c(B(A::a)); // error here

<stdin>:23:9: warning: parentheses were disambiguated as a function declaration [-Wvexing-parse]
C c(B(A::a)); // error here
^~~~~~~~~
<stdin>:23:10: note: add a pair of parentheses to declare a variable
C c(B(A::a)); // error here
^
( )

1 warning and 1 error generated.

... though perhaps we should detect this case and give a more specific error message.