Debian Codegraph @

gcc/testsuite/g++.dg/modules/internal-7_a.C

raw
1 // { dg-additional-options "-fmodules-ts -Wtemplate-names-tu-local" }
2 // Test streaming and instantiations of various kinds of exposures
3
4 export module M;
5
6 namespace {
7 int x;
8 constexpr int y = 1;
9
10 struct S { int m; void d(); };
11 enum class E { e };
12
13 template <typename T> int f(T t) { return (int)t; }
14 }
15
16 template <auto N> void g() {}
17
18 template <typename T>
19 int expose_1() { // { dg-warning "TU-local" }
20 return x;
21 }
22
23 template <typename T>
24 void expose_2() { // { dg-warning "TU-local" }
25 T t = &y;
26 }
27
28 template <typename T>
29 bool expose_3() { // { dg-warning "TU-local" }
30 return !(T{} * (x + 5) > 123);
31 }
32
33 template <typename T>
34 bool expose_4() { // { dg-warning "TU-local" }
35 return __is_same(S, T);
36 }
37
38 template <typename T>
39 void expose_5() { // { dg-warning "TU-local" }
40 static_assert(T{} == (int)E::e);
41 }
42
43 template <typename T>
44 void expose_6() { // { dg-warning "TU-local" }
45 f(T{});
46 }
47
48 template <typename T>
49 void expose_7() { // { dg-warning "TU-local" }
50 g<&y>();
51 }
52
53 template <typename T>
54 void expose_8() { // { dg-warning "TU-local" }
55 decltype(T{} .* &S::m)* (*x)[5][10];
56 };
57
58 template <typename T>
59 bool expose_9() { // { dg-warning "TU-local" }
60 return noexcept((T{} .* &S::d)());
61 }
62
63 template <typename T>
64 void expose_10() { // { dg-warning "TU-local" }
65 using U = decltype(f<T>());
66 }
67
68 template <typename T>
69 void expose_11() { // { dg-warning "TU-local" }
70 static thread_local E r;
71 }
72
73 template <typename T>
74 int expose_var // { dg-warning "TU-local" }
75 = f(sizeof(T));