51 lines · cpp
1// RUN: %clang_cc1 -pedantic -std=c++1y -include %s -include %s -verify %s2// RUN: %clang_cc1 -pedantic -std=c++1y -emit-pch -o %t.1 %s3// RUN: %clang_cc1 -pedantic -std=c++1y -include-pch %t.1 -emit-pch -o %t.2 %s4// RUN: %clang_cc1 -pedantic -std=c++1y -include-pch %t.2 -verify %s5 6// RUN: %clang_cc1 -pedantic -std=c++1y -emit-pch -fpch-instantiate-templates -o %t.1 %s7// RUN: %clang_cc1 -pedantic -std=c++1y -include-pch %t.1 -emit-pch -fpch-instantiate-templates -o %t.2 %s8// RUN: %clang_cc1 -pedantic -std=c++1y -include-pch %t.2 -verify %s9 10#ifndef HEADER_111#define HEADER_112 13struct A {14 int x;15 int y = 3;16 int z = x + y;17};18template<typename T> constexpr A make() { return A {}; }19template<typename T> constexpr A make(T t) { return A { t }; }20 21struct B {22 int z1, z2 = z1;23 constexpr B(int k) : z1(k) {}24};25 26template<typename T> struct C {27 constexpr C() {}28 T c = T();29 struct U {};30};31// Instantiate C<int> but not the default initializer.32C<int>::U ciu;33 34#elif !defined(HEADER_2)35#define HEADER_236 37// Instantiate the default initializer now, should create an update record.38C<int> ci;39 40#else41 42static_assert(A{}.z == 3, "");43static_assert(A{1}.z == 4, "");44static_assert(A{.y = 5}.z == 5, ""); // expected-warning {{C++20}}45static_assert(A{3, .y = 1}.z == 4, ""); // expected-warning {{C99}} expected-note {{here}}46static_assert(make<int>().z == 3, "");47static_assert(make<int>(12).z == 15, "");48static_assert(C<int>().c == 0, "");49 50#endif51