diff options
author | Douglas Gregor <dgregor@apple.com> | 2012-02-17 03:49:44 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2012-02-17 03:49:44 +0000 |
commit | b3f323d6c41cb614a249dbc4af7493762786521a (patch) | |
tree | a3920ec3ded16e5dd6a6e4378f5dcae3e28a9e2d /test/Parser/cxx0x-lambda-expressions.cpp | |
parent | f3908f2ae111b1b12ade2524dda71c669ed6f121 (diff) |
Disambiguate between C++11 lambda expressions and C99 array
designators in the parser. In the worst case, this disambiguation
requires tentative parsing just past the closing ']', but for most
cases we'll be able to tell by looking ahead just one token (without
going into the heavyweight tentative parsing machinery).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150790 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Parser/cxx0x-lambda-expressions.cpp')
-rw-r--r-- | test/Parser/cxx0x-lambda-expressions.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/test/Parser/cxx0x-lambda-expressions.cpp b/test/Parser/cxx0x-lambda-expressions.cpp index a25116b460..87d14051e9 100644 --- a/test/Parser/cxx0x-lambda-expressions.cpp +++ b/test/Parser/cxx0x-lambda-expressions.cpp @@ -25,5 +25,16 @@ class C { return 1; } + void designator_or_lambda() { + typedef int T; + const int b = 0; + const int c = 1; + int a1[1] = {[b] (T()) {}}; // expected-error{{no viable conversion from 'C::<lambda}} + int a2[1] = {[b] = 1 }; + int a3[1] = {[b,c] = 1 }; // expected-error{{expected body of lambda expression}} + int a4[1] = {[&b] = 1 }; // expected-error{{integral constant expression must have integral or unscoped enumeration type, not 'const int *'}} + int a5[3] = { []{return 0;}() }; + int a6[1] = {[this] = 1 }; // expected-error{{integral constant expression must have integral or unscoped enumeration type, not 'C *'}} + } }; |