20 lines · cpp
1// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify2// RUN: %clang_cc1 -fsyntax-only -std=c++14 %s -verify3// RUN: %clang_cc1 -fsyntax-only -std=c++17 %s -verify4 5void test_nonaggregate(int i) {6 auto lambda = [i]() -> void {}; // expected-note 2{{candidate constructor}}7 decltype(lambda) foo = { 1 }; // expected-error{{no matching constructor}}8 static_assert(__is_literal(decltype(lambda)) == (__cplusplus >= 201703L), "");9 10 auto lambda2 = []{}; // expected-note 2{{candidate constructor}}11 decltype(lambda2) bar = {}; // expected-error{{no matching constructor}}12 static_assert(__is_literal(decltype(lambda2)) == (__cplusplus >= 201703L), "");13}14 15constexpr auto literal = []{};16#if __cplusplus < 201703L17// expected-error@-2 {{constexpr variable cannot have non-literal type}}18// expected-note@-3 {{lambda closure types are non-literal types before C++17}}19#endif20