Skip to content

Commit 64e8d5b

Browse files
authored
[clang] Add tests from CWG156 to CWG1111 (dual-scope lookup for conversion-function-ids) (#121654)
This patch adds test from [CWG156](https://cplusplus.github.io/CWG/issues/156.html) to [CWG1111](https://cplusplus.github.io/CWG/issues/1111.html) test, and downgrades the latter to partial availability. The most relevant piece of current wording is [[basic.lookup.unqual]/5](https://eel.is/c++draft/basic.lookup#unqual-5): > An unqualified name that is a component name ([[expr.prim.id.unqual]](https://eel.is/c++draft/expr.prim.id.unqual)) of a [type-specifier](https://eel.is/c++draft/dcl.type.general#nt:type-specifier) or [ptr-operator](https://eel.is/c++draft/dcl.decl.general#nt:ptr-operator) of a [conversion-type-id](https://eel.is/c++draft/class.conv.fct#nt:conversion-type-id) is looked up in the same fashion as the [conversion-function-id](https://eel.is/c++draft/class.conv.fct#nt:conversion-function-id) in which it appears[.](https://eel.is/c++draft/basic.lookup#unqual-5.sentence-1) If that lookup finds nothing, it undergoes unqualified name lookup; in each case, only names that denote types or templates whose specializations are types are considered[.](https://eel.is/c++draft/basic.lookup#unqual-5.sentence-2) Per resolution of [CWG1111](https://cplusplus.github.io/CWG/issues/1111.html), additional lookup in the context of the entire postfix-expression, which originally was intended to cross-check lookup in the context of object-expression, was effectively turned into a fallback for it. Check out "Calling a conversion function" example in [P1787R6](https://wg21.link/p1787r6) for step-by-step explanation of the current lookup mechanics for conversion functions. Clang rejects one of the well-formed examples, hence partial status. Clang is the only implementation which rejects it: https://godbolt.org/z/ohhbx8Mfs
1 parent df4a615 commit 64e8d5b

File tree

3 files changed

+46
-3
lines changed

3 files changed

+46
-3
lines changed

clang/test/CXX/drs/cwg11xx.cpp

+43-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ decltype(return_T<B<int>>())* b;
1919
#endif
2020
} // namespace cwg1110
2121

22-
namespace cwg1111 { // cwg1111: 3.2
22+
namespace cwg1111 { // cwg1111: partial
2323
namespace example1 {
2424
template <typename> struct set; // #cwg1111-struct-set
2525

@@ -57,6 +57,48 @@ void baz() {
5757
a.operator A();
5858
}
5959
} // namespace example2
60+
61+
namespace example3 {
62+
struct A {
63+
operator int();
64+
} a;
65+
void foo() {
66+
typedef int T;
67+
a.operator T(); // T is found using unqualified lookup
68+
// after qualified lookup in A fails.
69+
}
70+
} // namespace example3
71+
72+
namespace example4 {
73+
struct A {
74+
typedef int T; // #cwg1111-A-T
75+
operator T();
76+
};
77+
struct B : A {
78+
operator T();
79+
} b;
80+
void foo() {
81+
b.A::operator T(); // FIXME: qualified lookup should find T in A.
82+
// expected-error@-1 {{unknown type name 'T'}}
83+
// expected-note@#cwg1111-A-T {{'A::T' declared here}}
84+
}
85+
} // namespace example4
86+
87+
namespace example5 {
88+
template <class T1> struct A {
89+
operator T1();
90+
};
91+
template <class T2> struct B : A<T2> {
92+
operator T2();
93+
void foo() {
94+
// In both cases, during instantiation, qualified lookup for T2 wouldn't be able
95+
// to find anything, so T2 has to be found by unqualified lookup.
96+
// After that, 'operator T2()' is found in A<T2> by qualfied lookup.
97+
T2 a = A<T2>::operator T2();
98+
T2 b = ((A<T2> *)this)->operator T2();
99+
}
100+
};
101+
} // namespace example5
60102
} // namespace cwg1111
61103

62104
namespace cwg1113 { // cwg1113: partial

clang/test/CXX/drs/cwg1xx.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -922,6 +922,7 @@ namespace cwg155 { // cwg155: dup 632
922922
// expected-warning@-1 {{braces around scalar initializer}}
923923
}
924924

925+
// cwg156: sup 1111
925926
// cwg158 is in cwg158.cpp
926927

927928
namespace cwg159 { // cwg159: 3.5

clang/www/cxx_dr_status.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -981,7 +981,7 @@ <h2 id="cxxdr">C++ defect report implementation status</h2>
981981
<td><a href="https://cplusplus.github.io/CWG/issues/156.html">156</a></td>
982982
<td>NAD</td>
983983
<td>Name lookup for conversion functions</td>
984-
<td class="unknown" align="center">Unknown</td>
984+
<td class="partial-superseded" align="center">Superseded by <a href="#1111">1111</a></td>
985985
</tr>
986986
<tr class="open" id="157">
987987
<td><a href="https://cplusplus.github.io/CWG/issues/157.html">157</a></td>
@@ -6485,7 +6485,7 @@ <h2 id="cxxdr">C++ defect report implementation status</h2>
64856485
<td><a href="https://cplusplus.github.io/CWG/issues/1111.html">1111</a></td>
64866486
<td>C++11</td>
64876487
<td>Remove dual-scope lookup of member template names</td>
6488-
<td class="full" align="center">Clang 3.2</td>
6488+
<td class="partial" align="center">Partial</td>
64896489
</tr>
64906490
<tr id="1112">
64916491
<td><a href="https://cplusplus.github.io/CWG/issues/1112.html">1112</a></td>

0 commit comments

Comments
 (0)