blob: 610d814443753d42b2a11adb16d1df5187890aeb [file] [log] [blame]
Faisal Valia734ab92016-03-26 16:11:37 +00001// RUN: %clang_cc1 -std=c++1z -verify -fsyntax-only -fblocks %s
2// RUN: %clang_cc1 -std=c++1z -verify -fsyntax-only -fblocks -fdelayed-template-parsing %s
Faisal Valic6b9be22016-07-23 04:05:19 +00003// RUN: %clang_cc1 -std=c++14 -verify -fsyntax-only -fblocks %s -DCPP14_AND_EARLIER
Faisal Valia734ab92016-03-26 16:11:37 +00004
Faisal Valic6b9be22016-07-23 04:05:19 +00005#ifndef CPP14_AND_EARLIER
Faisal Valia734ab92016-03-26 16:11:37 +00006namespace test_constexpr_checking {
7
8namespace ns1 {
9 struct NonLit { ~NonLit(); }; //expected-note{{not literal}}
10 auto L = [](NonLit NL) constexpr { }; //expected-error{{not a literal type}}
11} // end ns1
12
13namespace ns2 {
14 auto L = [](int I) constexpr { asm("non-constexpr"); }; //expected-error{{not allowed in constexpr function}}
15} // end ns1
16
17} // end ns test_constexpr_checking
18
19namespace test_constexpr_call {
20
21namespace ns1 {
22 auto L = [](int I) { return I; };
23 static_assert(L(3) == 3);
24} // end ns1
25namespace ns2 {
26 auto L = [](auto a) { return a; };
27 static_assert(L(3) == 3);
28 static_assert(L(3.14) == 3.14);
29}
30namespace ns3 {
31 auto L = [](auto a) { asm("non-constexpr"); return a; }; //expected-note{{declared here}}
32 constexpr int I = //expected-error{{must be initialized by a constant expression}}
33 L(3); //expected-note{{non-constexpr function}}
34}
35
Faisal Valic6b9be22016-07-23 04:05:19 +000036} // end ns test_constexpr_call
37
38#endif
39
40namespace test_lambda_is_literal {
41#ifdef CPP14_AND_EARLIER
42//expected-error@+4{{not a literal type}}
43//expected-note@+2{{not an aggregate and has no constexpr constructors}}
44#endif
45auto L = [] { };
46constexpr int foo(decltype(L) l) { return 0; }
47
48}