diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2018-05-14 20:15:04 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2018-05-14 20:15:04 +0000 |
commit | d699da427a4c49bc01c9ee3d031c7885383568f9 (patch) | |
tree | 01cd593aac8dad7f8b5760864ce5737ef39f7638 /clang/test/CXX/expr/expr.prim | |
parent | 771f2422d06b1aca660333ff89ef62529e395f27 (diff) | |
download | bcm5719-llvm-d699da427a4c49bc01c9ee3d031c7885383568f9.tar.gz bcm5719-llvm-d699da427a4c49bc01c9ee3d031c7885383568f9.zip |
PR37450: Fix bug that disabled some type checks for variables with deduced types.
Also improve diagnostic for the case where a type is non-literal because it's a lambda.
llvm-svn: 332286
Diffstat (limited to 'clang/test/CXX/expr/expr.prim')
-rw-r--r-- | clang/test/CXX/expr/expr.prim/expr.prim.lambda/p3.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p3.cpp b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p3.cpp index 80771d7a229..db40bd5d142 100644 --- a/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p3.cpp +++ b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p3.cpp @@ -1,11 +1,19 @@ // RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify +// RUN: %clang_cc1 -fsyntax-only -std=c++14 %s -verify +// RUN: %clang_cc1 -fsyntax-only -std=c++17 %s -verify void test_nonaggregate(int i) { auto lambda = [i]() -> void {}; // expected-note 2{{candidate constructor}} decltype(lambda) foo = { 1 }; // expected-error{{no matching constructor}} - static_assert(!__is_literal(decltype(lambda)), ""); + static_assert(__is_literal(decltype(lambda)) == (__cplusplus >= 201703L), ""); auto lambda2 = []{}; // expected-note 2{{candidate constructor}} decltype(lambda2) bar = {}; // expected-error{{no matching constructor}} - static_assert(!__is_literal(decltype(lambda2)), ""); + static_assert(__is_literal(decltype(lambda2)) == (__cplusplus >= 201703L), ""); } + +constexpr auto literal = []{}; +#if __cplusplus < 201703L +// expected-error@-2 {{constexpr variable cannot have non-literal type}} +// expected-note@-3 {{lambda closure types are non-literal types before C++17}} +#endif |