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 | a80cae11f6cdbc92b0a5c47c454534ac564452d3 (patch) | |
tree | 29104cd844ec33802bb558a549bd1dfb9b44fbc8 /clang/test/Parser/cxx0x-lambda-expressions.cpp | |
parent | 14a941380a8171800a41b418a7f63830693c5cfa (diff) | |
download | llvm-a80cae11f6cdbc92b0a5c47c454534ac564452d3.zip llvm-a80cae11f6cdbc92b0a5c47c454534ac564452d3.tar.gz llvm-a80cae11f6cdbc92b0a5c47c454534ac564452d3.tar.bz2 |
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).
llvm-svn: 150790
Diffstat (limited to 'clang/test/Parser/cxx0x-lambda-expressions.cpp')
-rw-r--r-- | clang/test/Parser/cxx0x-lambda-expressions.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/clang/test/Parser/cxx0x-lambda-expressions.cpp b/clang/test/Parser/cxx0x-lambda-expressions.cpp index a25116b..87d1405 100644 --- a/clang/test/Parser/cxx0x-lambda-expressions.cpp +++ b/clang/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 *'}} + } }; |