brintos

brintos / llvm-project-archived public Read only

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