// RUN: %clang_cc1 -pedantic -std=c++1y -include %s -include %s -verify %s // RUN: %clang_cc1 -pedantic -std=c++1y -emit-pch -o %t.1 %s // RUN: %clang_cc1 -pedantic -std=c++1y -include-pch %t.1 -emit-pch -o %t.2 %s // RUN: %clang_cc1 -pedantic -std=c++1y -include-pch %t.2 -verify %s // RUN: %clang_cc1 -pedantic -std=c++1y -emit-pch -fpch-instantiate-templates -o %t.1 %s // RUN: %clang_cc1 -pedantic -std=c++1y -include-pch %t.1 -emit-pch -fpch-instantiate-templates -o %t.2 %s // RUN: %clang_cc1 -pedantic -std=c++1y -include-pch %t.2 -verify %s #ifndef HEADER_1 #define HEADER_1 struct A { int x; int y = 3; int z = x + y; }; template constexpr A make() { return A {}; } template constexpr A make(T t) { return A { t }; } struct B { int z1, z2 = z1; constexpr B(int k) : z1(k) {} }; template struct C { constexpr C() {} T c = T(); struct U {}; }; // Instantiate C but not the default initializer. C::U ciu; #elif !defined(HEADER_2) #define HEADER_2 // Instantiate the default initializer now, should create an update record. C ci; #else static_assert(A{}.z == 3, ""); static_assert(A{1}.z == 4, ""); static_assert(A{.y = 5}.z == 5, ""); // expected-warning {{C++20}} static_assert(A{3, .y = 1}.z == 4, ""); // expected-warning {{C99}} expected-note {{here}} static_assert(make().z == 3, ""); static_assert(make(12).z == 15, ""); static_assert(C().c == 0, ""); #endif