Mercurial > hg > CbC > CbC_llvm
comparison clang/test/PCH/cxx1y-default-initializer.cpp @ 150:1d019706d866
LLVM10
author | anatofuz |
---|---|
date | Thu, 13 Feb 2020 15:10:13 +0900 |
parents | |
children | 2e18cbf3894f |
comparison
equal
deleted
inserted
replaced
147:c2174574ed3a | 150:1d019706d866 |
---|---|
1 // RUN: %clang_cc1 -pedantic -std=c++1y -include %s -include %s -verify %s | |
2 // RUN: %clang_cc1 -pedantic -std=c++1y -emit-pch -o %t.1 %s | |
3 // RUN: %clang_cc1 -pedantic -std=c++1y -include-pch %t.1 -emit-pch -o %t.2 %s | |
4 // RUN: %clang_cc1 -pedantic -std=c++1y -include-pch %t.2 -verify %s | |
5 | |
6 #ifndef HEADER_1 | |
7 #define HEADER_1 | |
8 | |
9 struct A { | |
10 int x; | |
11 int y = 3; | |
12 int z = x + y; | |
13 }; | |
14 template<typename T> constexpr A make() { return A {}; } | |
15 template<typename T> constexpr A make(T t) { return A { t }; } | |
16 | |
17 struct B { | |
18 int z1, z2 = z1; | |
19 constexpr B(int k) : z1(k) {} | |
20 }; | |
21 | |
22 template<typename T> struct C { | |
23 constexpr C() {} | |
24 T c = T(); | |
25 struct U {}; | |
26 }; | |
27 // Instantiate C<int> but not the default initializer. | |
28 C<int>::U ciu; | |
29 | |
30 #elif !defined(HEADER_2) | |
31 #define HEADER_2 | |
32 | |
33 // Instantiate the default initializer now, should create an update record. | |
34 C<int> ci; | |
35 | |
36 #else | |
37 | |
38 static_assert(A{}.z == 3, ""); | |
39 static_assert(A{1}.z == 4, ""); | |
40 static_assert(A{.y = 5}.z == 5, ""); // expected-warning {{C++20}} | |
41 static_assert(A{3, .y = 1}.z == 4, ""); // expected-warning {{C99}} expected-note {{here}} | |
42 static_assert(make<int>().z == 3, ""); | |
43 static_assert(make<int>(12).z == 15, ""); | |
44 static_assert(C<int>().c == 0, ""); | |
45 | |
46 #endif |