diff options
Diffstat (limited to 'clang/test/SemaCXX/compound-literal.cpp')
-rw-r--r-- | clang/test/SemaCXX/compound-literal.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/clang/test/SemaCXX/compound-literal.cpp b/clang/test/SemaCXX/compound-literal.cpp index 3fc61505dfe..5480b1fef44 100644 --- a/clang/test/SemaCXX/compound-literal.cpp +++ b/clang/test/SemaCXX/compound-literal.cpp @@ -86,3 +86,13 @@ int PR17415 = (int){PR17415}; // expected-error {{initializer element is not a c template<unsigned> struct Value { }; template<typename T> int &check_narrowed(Value<sizeof((T){1.1})>); + +#if __cplusplus >= 201103L +// Compound literals in global lambdas have automatic storage duration +// and are not subject to the constant-initialization rules. +int computed_with_lambda = [] { + int x = 5; + int result = ((int[]) { x, x + 2, x + 4, x + 6 })[0]; + return result; +}(); +#endif |