[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / PCH / cxx1y-default-initializer.cpp
bloba971ba6477d7e7ac9890ec4ec88b788e8e0271d1
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
6 // RUN: %clang_cc1 -pedantic -std=c++1y -emit-pch -fpch-instantiate-templates -o %t.1 %s
7 // RUN: %clang_cc1 -pedantic -std=c++1y -include-pch %t.1 -emit-pch -fpch-instantiate-templates -o %t.2 %s
8 // RUN: %clang_cc1 -pedantic -std=c++1y -include-pch %t.2 -verify %s
10 #ifndef HEADER_1
11 #define HEADER_1
13 struct A {
14 int x;
15 int y = 3;
16 int z = x + y;
18 template<typename T> constexpr A make() { return A {}; }
19 template<typename T> constexpr A make(T t) { return A { t }; }
21 struct B {
22 int z1, z2 = z1;
23 constexpr B(int k) : z1(k) {}
26 template<typename T> struct C {
27 constexpr C() {}
28 T c = T();
29 struct U {};
31 // Instantiate C<int> but not the default initializer.
32 C<int>::U ciu;
34 #elif !defined(HEADER_2)
35 #define HEADER_2
37 // Instantiate the default initializer now, should create an update record.
38 C<int> ci;
40 #else
42 static_assert(A{}.z == 3, "");
43 static_assert(A{1}.z == 4, "");
44 static_assert(A{.y = 5}.z == 5, ""); // expected-warning {{C++20}}
45 static_assert(A{3, .y = 1}.z == 4, ""); // expected-warning {{C99}} expected-note {{here}}
46 static_assert(make<int>().z == 3, "");
47 static_assert(make<int>(12).z == 15, "");
48 static_assert(C<int>().c == 0, "");
50 #endif