|
1 | 1 | // RUN: %clang_cc1 -std=c++23 -Wno-unused %s -verify
|
2 | 2 |
|
3 |
| -struct A { |
4 |
| - int x; |
| 3 | +namespace Unambiguous { |
| 4 | + struct A { |
| 5 | + int x; |
| 6 | + |
| 7 | + template<typename T> |
| 8 | + using C = A; |
| 9 | + }; |
| 10 | + |
| 11 | + using B = A; |
5 | 12 |
|
6 | 13 | template<typename T>
|
7 |
| - using C = A; |
8 |
| -}; |
| 14 | + using D = A; |
| 15 | + |
| 16 | + using E = void; |
9 | 17 |
|
10 |
| -using B = A; |
| 18 | + struct F : A { |
| 19 | + void non_template() { |
| 20 | + this->x; |
| 21 | + this->A::x; |
| 22 | + this->B::x; |
| 23 | + this->C<int>::x; |
| 24 | + this->D<int>::x; |
| 25 | + this->E::x; // expected-error {{'Unambiguous::E' (aka 'void') is not a class, namespace, or enumeration}} |
| 26 | + } |
| 27 | + }; |
11 | 28 |
|
12 |
| -template<typename T> |
13 |
| -using D = A; |
| 29 | + template<typename T> |
| 30 | + void not_instantiated(T t) { |
| 31 | + t.x; |
| 32 | + t.A::x; |
| 33 | + t.B::x; |
| 34 | + t.C<int>::x; // expected-error {{use 'template' keyword to treat 'C' as a dependent template name}} |
| 35 | + t.template C<int>::x; |
| 36 | + t.D<int>::x; // expected-error {{use 'template' keyword to treat 'D' as a dependent template name}} |
| 37 | + t.template D<int>::x; |
| 38 | + t.E::x; |
| 39 | + } |
14 | 40 |
|
15 |
| -using E = void; |
| 41 | + template<typename T> |
| 42 | + void instantiated_valid(T t) { |
| 43 | + t.x; |
| 44 | + t.A::x; |
| 45 | + t.B::x; |
| 46 | + t.template C<int>::x; |
| 47 | + t.template D<int>::x; |
| 48 | + t.E::x; |
| 49 | + } |
16 | 50 |
|
17 |
| -struct F : A { |
18 |
| - void non_template() { |
19 |
| - this->x; |
20 |
| - this->A::x; |
21 |
| - this->B::x; |
22 |
| - this->C<int>::x; |
23 |
| - this->D<int>::x; |
24 |
| - this->E::x; // expected-error {{'E' (aka 'void') is not a class, namespace, or enumeration}} |
| 51 | + template<typename T> |
| 52 | + void instantiated_invalid(T t) { |
| 53 | + t.x; |
| 54 | + t.A::x; |
| 55 | + t.B::x; // expected-error {{'Unambiguous::Invalid::B' (aka 'void') is not a class, namespace, or enumeration}} |
| 56 | + t.template C<int>::x; |
| 57 | + t.template D<int>::x; // expected-error {{'D' following the 'template' keyword does not refer to a template}} |
| 58 | + t.E::x; // expected-error {{'Unambiguous::E' (aka 'void') is not a class, namespace, or enumeration}} |
25 | 59 | }
|
26 |
| -}; |
27 |
| - |
28 |
| -template<typename T> |
29 |
| -void not_instantiated(T t) { |
30 |
| - t.x; |
31 |
| - t.A::x; |
32 |
| - t.B::x; |
33 |
| - t.C<int>::x; // expected-error {{use 'template' keyword to treat 'C' as a dependent template name}} |
34 |
| - t.template C<int>::x; |
35 |
| - t.D<int>::x; // expected-error {{use 'template' keyword to treat 'D' as a dependent template name}} |
36 |
| - t.template D<int>::x; |
37 |
| - t.E::x; |
38 |
| -} |
39 |
| - |
40 |
| -template<typename T> |
41 |
| -void instantiated_valid(T t) { |
42 |
| - t.x; |
43 |
| - t.A::x; |
44 |
| - t.B::x; |
45 |
| - t.template C<int>::x; |
46 |
| - t.template D<int>::x; |
47 |
| - t.E::x; |
48 |
| -} |
49 |
| - |
50 |
| -template<typename T> |
51 |
| -void instantiated_invalid(T t) { |
52 |
| - t.x; |
53 |
| - t.A::x; |
54 |
| - t.B::x; // expected-error {{'Invalid::B' (aka 'void') is not a class, namespace, or enumeration}} |
55 |
| - t.template C<int>::x; |
56 |
| - t.template D<int>::x; // expected-error {{'D' following the 'template' keyword does not refer to a template}} |
57 |
| - t.E::x; // expected-error {{'E' (aka 'void') is not a class, namespace, or enumeration}} |
58 |
| -} |
59 |
| - |
60 |
| -struct Valid : A { |
61 |
| - using E = A; |
62 |
| -}; |
63 |
| - |
64 |
| -template void instantiated_valid(Valid); |
65 |
| - |
66 |
| -struct Invalid : A { |
67 |
| - using B = void; |
68 |
| - using D = A; // expected-note {{declared as a non-template here}} |
69 |
| -}; |
70 |
| - |
71 |
| -template void instantiated_invalid(Invalid); // expected-note {{in instantiation of}} |
| 60 | + |
| 61 | + struct Valid : A { |
| 62 | + using E = A; |
| 63 | + }; |
| 64 | + |
| 65 | + template void instantiated_valid(Valid); |
| 66 | + |
| 67 | + struct Invalid : A { |
| 68 | + using B = void; |
| 69 | + using D = A; // expected-note {{declared as a non-template here}} |
| 70 | + }; |
| 71 | + |
| 72 | + template void instantiated_invalid(Invalid); // expected-note {{in instantiation of}} |
| 73 | +} // namespace Unambiguous |
| 74 | + |
| 75 | +namespace Ambiguous { |
| 76 | + inline namespace N { |
| 77 | + struct A { }; // expected-note {{candidate found by name lookup is 'Ambiguous::N::A'}} |
| 78 | + } |
| 79 | + |
| 80 | + struct A { }; // expected-note {{candidate found by name lookup is 'Ambiguous::A'}} |
| 81 | + |
| 82 | + template<typename T> |
| 83 | + void f(T t) { |
| 84 | + t.A::x; // expected-error {{reference to 'A' is ambiguous}} |
| 85 | + } |
| 86 | + |
| 87 | + struct B { |
| 88 | + using A = B; |
| 89 | + |
| 90 | + int x; |
| 91 | + }; |
| 92 | + |
| 93 | + struct C { }; |
| 94 | + |
| 95 | + template void f(B); |
| 96 | + template void f(C); // expected-note {{in instantiation of}} |
| 97 | + |
| 98 | +} // namespace Ambiguous |
0 commit comments