[cfe-dev] error: parameter declarator cannot be qualified
Richard Smith
richard at metafoo.co.uk
Fri Aug 10 14:58:34 PDT 2012
On Fri, Aug 10, 2012 at 1:47 PM, Артем Зуйков <chertus at gmail.com> wrote:
> 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.
>
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:
<stdin>: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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20120810/6710adea/attachment.html>
More information about the cfe-dev
mailing list