blob: 8e7657fb6e8d5685c836e148cb58084a92bbdb76 [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
3// RUN: %clang_cc1 -std=c++1z -verify -fsyntax-only -fblocks -fms-extensions %s
4// RUN: %clang_cc1 -std=c++1z -verify -fsyntax-only -fblocks -fdelayed-template-parsing -fms-extensions %s
5
6namespace 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
36} // end ns test_constexpr_call