diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2017-12-18 20:11:37 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2017-12-18 20:11:37 +0000 |
commit | 461a67fa15370a9ec88f8f8a240bf7c123bb2029 (patch) | |
tree | 6942083d7d56bba40ec790a453ca58ad3baf6832 /test/SemaCXX/decl-expr-ambiguity.cpp | |
parent | 75c3240472ba6ac2669ee72ca67eb72d4e2851fc (diff) |
Diffstat (limited to 'test/SemaCXX/decl-expr-ambiguity.cpp')
-rw-r--r-- | test/SemaCXX/decl-expr-ambiguity.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/test/SemaCXX/decl-expr-ambiguity.cpp b/test/SemaCXX/decl-expr-ambiguity.cpp index 1b1f7dc8a70e2..1e31d701d0c16 100644 --- a/test/SemaCXX/decl-expr-ambiguity.cpp +++ b/test/SemaCXX/decl-expr-ambiguity.cpp @@ -48,13 +48,20 @@ void f() { struct RAII { RAII(); + RAII(int); ~RAII(); }; +struct NotRAII { + NotRAII(); + NotRAII(int); +}; + void func(); void func2(short); namespace N { struct S; + int n; void emptyParens() { RAII raii(); // expected-warning {{function declaration}} expected-note {{remove parentheses to declare a variable}} @@ -69,6 +76,23 @@ namespace N { void nonEmptyParens() { int f = 0, // g = 0; expected-note {{change this ',' to a ';' to call 'func2'}} func2(short(f)); // expected-warning {{function declaration}} expected-note {{add a pair of parentheses}} + + RAII(n); // expected-warning {{parentheses were disambiguated as redundant parentheses around declaration of variable named 'n'}} + // expected-note@-1 {{add a variable name to declare a 'RAII' initialized with 'n'}} + // expected-note@-2 {{add enclosing parentheses to perform a function-style cast}} + // expected-note@-3 {{remove parentheses to silence this warning}} + + RAII(undeclared1); +#pragma clang diagnostic push +#pragma clang diagnostic warning "-Wredundant-parens" + RAII(undeclared2); // expected-warning {{redundant parentheses surrounding declarator}} +#pragma clang diagnostic pop + + { + NotRAII(n); // expected-warning {{parentheses were disambiguated as redundant parentheses around declaration of variable named 'n'}} + // expected-note@-1 {{add enclosing parentheses to perform a function-style cast}} + // expected-note@-2 {{remove parentheses to silence this warning}} + } } } |