diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2016-06-23 08:41:20 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2016-06-23 08:41:20 +0000 |
commit | 19f877c3f2625188b73e77635a409a8ab925ca11 (patch) | |
tree | 1cf9c635e6a7465c6c1c6489caac41ffd17c467b /clang/test | |
parent | 26036843724d49fcd4678f177c02f0097997c731 (diff) | |
download | bcm5719-llvm-19f877c3f2625188b73e77635a409a8ab925ca11.tar.gz bcm5719-llvm-19f877c3f2625188b73e77635a409a8ab925ca11.zip |
Rearrange condition handling so that semantic checks on a condition variable
are performed before the other substatements of the construct are parsed,
rather than deferring them until the end. This allows better error recovery
from semantic errors in the condition, improves diagnostic order, and is a
prerequisite for C++17 constexpr if.
llvm-svn: 273548
Diffstat (limited to 'clang/test')
-rw-r--r-- | clang/test/FixIt/fixit-vexing-parse.cpp | 2 | ||||
-rw-r--r-- | clang/test/Parser/cxx0x-condition.cpp | 4 | ||||
-rw-r--r-- | clang/test/SemaCXX/crashes.cpp | 3 | ||||
-rw-r--r-- | clang/test/SemaCXX/for-range-examples.cpp | 4 | ||||
-rw-r--r-- | clang/test/SemaObjCXX/foreach.mm | 9 |
5 files changed, 9 insertions, 13 deletions
diff --git a/clang/test/FixIt/fixit-vexing-parse.cpp b/clang/test/FixIt/fixit-vexing-parse.cpp index 0232f5dbb04..71d3eff5329 100644 --- a/clang/test/FixIt/fixit-vexing-parse.cpp +++ b/clang/test/FixIt/fixit-vexing-parse.cpp @@ -60,7 +60,7 @@ namespace N { VO m(int (*p)[4]); // Don't emit warning and fixit because direct initializer is not permitted here. - if (int n(int())){} // expected-error {{function type is not allowed here}} expected-error {{condition must have an initializer}} + if (int n(int())){} // expected-error {{function type is not allowed here}} // CHECK: fix-it:"{{.*}}":{66:8-66:10}:" = {}" U u(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}} diff --git a/clang/test/Parser/cxx0x-condition.cpp b/clang/test/Parser/cxx0x-condition.cpp index 8b64bcf1273..071e09e4158 100644 --- a/clang/test/Parser/cxx0x-condition.cpp +++ b/clang/test/Parser/cxx0x-condition.cpp @@ -23,9 +23,9 @@ void f() { if (S b(a)) {} // expected-error {{variable declaration in condition cannot have a parenthesized initializer}} - if (S b(n)) {} // expected-error {{a function type is not allowed here}} expected-error {{must have an initializer}} + if (S b(n)) {} // expected-error {{a function type is not allowed here}} if (S b(n) = 0) {} // expected-error {{a function type is not allowed here}} - if (S b(n) == 0) {} // expected-error {{a function type is not allowed here}} expected-error {{did you mean '='?}} + if (S b(n) == 0) {} // expected-error {{a function type is not allowed here}} S s(a); if (S{s}) {} // ok diff --git a/clang/test/SemaCXX/crashes.cpp b/clang/test/SemaCXX/crashes.cpp index 926d13ab453..a80587d8405 100644 --- a/clang/test/SemaCXX/crashes.cpp +++ b/clang/test/SemaCXX/crashes.cpp @@ -105,8 +105,7 @@ namespace PR9026 { namespace PR10270 { template<typename T> class C; template<typename T> void f() { - if (C<T> == 1) // expected-error{{expected unqualified-id}} \ - // expected-error{{invalid '==' at end of declaration}} + if (C<T> == 1) // expected-error{{expected unqualified-id}} return; } } diff --git a/clang/test/SemaCXX/for-range-examples.cpp b/clang/test/SemaCXX/for-range-examples.cpp index 83023e31101..08a9982c637 100644 --- a/clang/test/SemaCXX/for-range-examples.cpp +++ b/clang/test/SemaCXX/for-range-examples.cpp @@ -176,9 +176,9 @@ namespace test4 { // Make sure these don't crash. Better diagnostics would be nice. for (: {1, 2, 3}) {} // expected-error {{expected expression}} expected-error {{expected ';'}} - for (1 : {1, 2, 3}) {} // expected-error {{must declare a variable}} expected-warning {{result unused}} + for (1 : {1, 2, 3}) {} // expected-error {{must declare a variable}} for (+x : {1, 2, 3}) {} // expected-error {{undeclared identifier}} expected-error {{expected ';'}} - for (+y : {1, 2, 3}) {} // expected-error {{must declare a variable}} expected-warning {{result unused}} + for (+y : {1, 2, 3}) {} // expected-error {{must declare a variable}} } } diff --git a/clang/test/SemaObjCXX/foreach.mm b/clang/test/SemaObjCXX/foreach.mm index d1302c19a58..99f5d0ce55e 100644 --- a/clang/test/SemaObjCXX/foreach.mm +++ b/clang/test/SemaObjCXX/foreach.mm @@ -6,10 +6,8 @@ void f(NSArray *a) { id keys; for (int i : a); // expected-error{{selector element type 'int' is not a valid object}} - for ((id)2 : a); // expected-error {{for range declaration must declare a variable}} \ - // expected-warning {{expression result unused}} - for (2 : a); // expected-error {{for range declaration must declare a variable}} \ - // expected-warning {{expression result unused}} + for ((id)2 : a); // expected-error {{for range declaration must declare a variable}} + for (2 : a); // expected-error {{for range declaration must declare a variable}} for (id thisKey : keys); @@ -65,8 +63,7 @@ int main () @end void test2(NSObject<NSFastEnumeration> *collection) { Test2 *obj; - for (obj.prop : collection) { // expected-error {{for range declaration must declare a variable}} \ - // expected-warning {{property access result unused - getters should not be used for side effects}} + for (obj.prop : collection) { // expected-error {{for range declaration must declare a variable}} } } |