Skip to content

Commit dcd29ca

Browse files
committed
[clang] Add test for CWG156 "Name lookup for conversion functions"
1 parent da2a9ed commit dcd29ca

File tree

2 files changed

+44
-1
lines changed

2 files changed

+44
-1
lines changed

clang/test/CXX/drs/cwg1xx.cpp

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -922,6 +922,49 @@ namespace cwg155 { // cwg155: dup 632
922922
// expected-warning@-1 {{braces around scalar initializer}}
923923
}
924924

925+
namespace cwg156 { // cwg156: partial
926+
namespace ex1 {
927+
struct A {
928+
operator int();
929+
} a;
930+
void foo() {
931+
typedef int T;
932+
a.operator T(); // T is found using unqualified lookup
933+
// after qualified lookup in A fails.
934+
}
935+
} // namespace ex1
936+
937+
namespace ex2 {
938+
struct A {
939+
typedef int T;
940+
operator T();
941+
};
942+
struct B : A {
943+
operator T();
944+
} b;
945+
void foo() {
946+
b.A::operator T(); // FIXME: qualified lookup should find T in A.
947+
// expected-error@-1 {{unknown type name 'T'}}
948+
}
949+
} // namespace ex2
950+
951+
namespace ex3 {
952+
template <class T1> struct A {
953+
operator T1();
954+
};
955+
template <class T2> struct B : A<T2> {
956+
operator T2();
957+
void foo() {
958+
// In both cases, during instantiation, qualified lookup for T2 wouldn't be able
959+
// to find anything, so T2 has to be found by unqualified lookup.
960+
// After that, 'operator T2()' is found in A<T2> by qualfied lookup.
961+
T2 a = A<T2>::operator T2();
962+
T2 b = ((A<T2> *)this)->operator T2();
963+
}
964+
};
965+
} // namespace ex3
966+
} // namespace cwg156
967+
925968
// cwg158 is in cwg158.cpp
926969

927970
namespace cwg159 { // cwg159: 3.5

clang/www/cxx_dr_status.html

Lines changed: 1 addition & 1 deletion
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" align="center">Partial</td>
985985
</tr>
986986
<tr class="open" id="157">
987987
<td><a href="https://cplusplus.github.io/CWG/issues/157.html">157</a></td>

0 commit comments

Comments
 (0)