Debian Codegraph @

clang/test/PCH/cxx20-template-args.cpp

raw
1 // RUN: %clang_cc1 -std=c++20 -include %s %s -o %t
2
3 // RUN: %clang_cc1 -std=c++20 -emit-pch %s -o %t
4 // RUN: %clang_cc1 -std=c++20 -include-pch %t -verify %s
5
6 // expected-no-diagnostics
7
8 #ifndef HEADER
9 #define HEADER
10
11 int g;
12 struct A { union { int n, m; }; int *p; int A::*q; char buffer[32]; };
13
14 template<A a> constexpr const A &get = a;
15
16 constexpr const A &v = get<A{}>;
17 constexpr const A &w = get<A{1, &g, &A::n, "hello"}>;
18
19 #else /*included pch*/
20
21 template<A a> constexpr const A &get2 = a;
22
23 constexpr const A &v2 = get2<A{}>;
24 constexpr const A &w2 = get2<A{1, &g, &A::n, "hello\0\0\0\0\0"}>;
25
26 static_assert(&v == &v2);
27 static_assert(&w == &w2);
28
29 static_assert(&v != &w);
30 static_assert(&v2 != &w);
31 static_assert(&v != &w2);
32 static_assert(&v2 != &w2);
33
34 constexpr const A &v3 = get2<A{.n = 0}>;
35 constexpr const A &x = get2<A{.m = 0}>;
36
37 static_assert(&v == &v3);
38 static_assert(&v != &x);
39
40 #endif // HEADER