diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2017-09-29 23:57:25 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2017-09-29 23:57:25 +0000 |
commit | ecad4de87bbbac3218bf0b8c1526459b004d7719 (patch) | |
tree | d226e5e1230c6568ba4621bbc3199724a719a4a0 /test/Parser | |
parent | 3b862f67453ad24060274ad29dc28f56a435025a (diff) |
Add a "vexing parse" warning for ambiguity between a variable declaration and a
function-style cast.
This fires for cases such as
T(x);
... where 'x' was previously declared and T is a type. This construct declares
a variable named 'x' rather than the (probably expected) interpretation of a
function-style cast of 'x' to T.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@314570 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Parser')
-rw-r--r-- | test/Parser/cxx0x-condition.cpp | 4 | ||||
-rw-r--r-- | test/Parser/cxx1z-class-template-argument-deduction.cpp | 1 |
2 files changed, 3 insertions, 2 deletions
diff --git a/test/Parser/cxx0x-condition.cpp b/test/Parser/cxx0x-condition.cpp index 071e09e415..19d5a7395d 100644 --- a/test/Parser/cxx0x-condition.cpp +++ b/test/Parser/cxx0x-condition.cpp @@ -14,11 +14,11 @@ void f() { for (; int x = ++a; ) ; if (S(a)) {} // ok - if (S(a) = 0) {} // ok + if (S(a) = 0) {} // expected-warning {{redundant parentheses}} expected-note 2{{}} if (S(a) == 0) {} // ok if (S(n)) {} // expected-error {{unexpected type name 'n': expected expression}} - if (S(n) = 0) {} // ok + if (S(n) = 0) {} // expected-warning {{redundant parentheses}} expected-note 2{{}} if (S(n) == 0) {} // expected-error {{unexpected type name 'n': expected expression}} if (S b(a)) {} // expected-error {{variable declaration in condition cannot have a parenthesized initializer}} diff --git a/test/Parser/cxx1z-class-template-argument-deduction.cpp b/test/Parser/cxx1z-class-template-argument-deduction.cpp index dac17dfbf4..b8f5a82d46 100644 --- a/test/Parser/cxx1z-class-template-argument-deduction.cpp +++ b/test/Parser/cxx1z-class-template-argument-deduction.cpp @@ -180,6 +180,7 @@ namespace typename_specifier { {(void)(typename T::A)(0);} // expected-error{{refers to class template member}} {(void)(typename T::A){0};} // expected-error{{refers to class template member}} {typename T::A (parens) = 0;} // expected-error {{refers to class template member in 'typename_specifier::X'; argument deduction not allowed here}} + // expected-warning@-1 {{disambiguated as redundant parentheses around declaration of variable named 'parens'}} expected-note@-1 {{add a variable name}} expected-note@-1{{remove parentheses}} expected-note@-1 {{add enclosing parentheses}} {typename T::A *p = 0;} // expected-error {{refers to class template member}} {typename T::A &r = *p;} // expected-error {{refers to class template member}} {typename T::A arr[3] = 0;} // expected-error {{refers to class template member}} |