summaryrefslogtreecommitdiffstats
path: root/test/Parser/cxx0x-lambda-expressions.cpp
diff options
context:
space:
mode:
authordim <dim@FreeBSD.org>2014-11-24 09:15:30 +0000
committerdim <dim@FreeBSD.org>2014-11-24 09:15:30 +0000
commit173a4f43a911175643bda81ee675e8d9269056ea (patch)
tree47df2c12b57214af6c31e47404b005675b8b7ffc /test/Parser/cxx0x-lambda-expressions.cpp
parent88f7a7d5251a2d813460274c92decc143a11569b (diff)
downloadFreeBSD-src-173a4f43a911175643bda81ee675e8d9269056ea.zip
FreeBSD-src-173a4f43a911175643bda81ee675e8d9269056ea.tar.gz
Vendor import of clang RELEASE_350/final tag r216957 (effectively, 3.5.0 release):
https://llvm.org/svn/llvm-project/cfe/tags/RELEASE_350/final@216957
Diffstat (limited to 'test/Parser/cxx0x-lambda-expressions.cpp')
-rw-r--r--test/Parser/cxx0x-lambda-expressions.cpp30
1 files changed, 28 insertions, 2 deletions
diff --git a/test/Parser/cxx0x-lambda-expressions.cpp b/test/Parser/cxx0x-lambda-expressions.cpp
index 289d03c..8cfe7f3 100644
--- a/test/Parser/cxx0x-lambda-expressions.cpp
+++ b/test/Parser/cxx0x-lambda-expressions.cpp
@@ -2,6 +2,8 @@
enum E { e };
+constexpr int id(int n) { return n; }
+
class C {
int f() {
@@ -34,12 +36,18 @@ class C {
typedef int T;
const int b = 0;
const int c = 1;
- int a1[1] = {[b] (T()) {}}; // expected-error{{no viable conversion from '<lambda}}
+ int d;
+ int a1[1] = {[b] (T()) {}}; // expected-error{{no viable conversion from '(lambda}}
int a2[1] = {[b] = 1 };
- int a3[1] = {[b,c] = 1 }; // expected-error{{expected body of lambda expression}}
+ int a3[1] = {[b,c] = 1 }; // expected-error{{expected ']'}} expected-note {{to match}}
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 *'}}
+ int a7[1] = {[d(0)] { return d; } ()}; // expected-warning{{extension}}
+ int a8[1] = {[d = 0] { return d; } ()}; // expected-warning{{extension}}
+ int a9[1] = {[d = 0] = 1}; // expected-error{{is not an integral constant expression}}
+ int a10[1] = {[id(0)] { return id; } ()}; // expected-warning{{extension}}
+ int a11[1] = {[id(0)] = 1};
}
void delete_lambda(int *p) {
@@ -64,4 +72,22 @@ class C {
return x + 2;
} ();
}
+
+ void attributes() {
+ [] [[]] {}; // expected-error {{lambda requires '()' before attribute specifier}}
+ [] __attribute__((noreturn)) {}; // expected-error {{lambda requires '()' before attribute specifier}}
+ []() [[]]
+ mutable {}; // expected-error {{expected body of lambda expression}}
+
+ []() [[]] {};
+ []() [[]] -> void {};
+ []() mutable [[]] -> void {};
+ []() mutable noexcept [[]] -> void {};
+
+ // Testing GNU-style attributes on lambdas -- the attribute is specified
+ // before the mutable specifier instead of after (unlike C++11).
+ []() __attribute__((noreturn)) mutable { while(1); };
+ []() mutable
+ __attribute__((noreturn)) { while(1); }; // expected-error {{expected body of lambda expression}}
+ }
};
OpenPOWER on IntegriCloud