xref: /minix3/external/bsd/llvm/dist/clang/test/PCH/cxx1y-default-initializer.cpp (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -pedantic -std=c++1y -emit-pch %s -o %t
2*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -pedantic -std=c++1y -include-pch %t -verify %s
3*f4a2713aSLionel Sambuc 
4*f4a2713aSLionel Sambuc #ifndef HEADER_INCLUDED
5*f4a2713aSLionel Sambuc 
6*f4a2713aSLionel Sambuc #define HEADER_INCLUDED
7*f4a2713aSLionel Sambuc 
8*f4a2713aSLionel Sambuc struct A {
9*f4a2713aSLionel Sambuc   int x;
10*f4a2713aSLionel Sambuc   int y = 3;
11*f4a2713aSLionel Sambuc   int z = x + y;
12*f4a2713aSLionel Sambuc };
make()13*f4a2713aSLionel Sambuc template<typename T> constexpr A make() { return A {}; }
make(T t)14*f4a2713aSLionel Sambuc template<typename T> constexpr A make(T t) { return A { t }; }
15*f4a2713aSLionel Sambuc 
16*f4a2713aSLionel Sambuc struct B {
17*f4a2713aSLionel Sambuc   int z1, z2 = z1;
BB18*f4a2713aSLionel Sambuc   constexpr B(int k) : z1(k) {}
19*f4a2713aSLionel Sambuc };
20*f4a2713aSLionel Sambuc 
21*f4a2713aSLionel Sambuc #else
22*f4a2713aSLionel Sambuc 
23*f4a2713aSLionel Sambuc static_assert(A{}.z == 3, "");
24*f4a2713aSLionel Sambuc static_assert(A{1}.z == 4, "");
25*f4a2713aSLionel Sambuc static_assert(A{.y = 5}.z == 5, ""); // expected-warning {{C99}}
26*f4a2713aSLionel Sambuc static_assert(A{3, .y = 1}.z == 4, ""); // expected-warning {{C99}}
27*f4a2713aSLionel Sambuc static_assert(make<int>().z == 3, "");
28*f4a2713aSLionel Sambuc static_assert(make<int>(12).z == 15, "");
29*f4a2713aSLionel Sambuc 
30*f4a2713aSLionel Sambuc #endif
31