Skip to content

Commit ec44a71

Browse files
committed
[clang] Add test for CWG170 "Pointer-to-member conversions"
1 parent 9a95c09 commit ec44a71

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

clang/test/CXX/drs/cwg1xx.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,6 +1074,26 @@ namespace cwg169 { // cwg169: yes
10741074
};
10751075
}
10761076

1077+
namespace cwg170 { // cwg170: 3.1
1078+
#if __cplusplus >= 201103L
1079+
struct A {};
1080+
struct B : A { int i; };
1081+
struct C : A {};
1082+
struct D : C {};
1083+
1084+
constexpr int f(int A::*) { return 0; }
1085+
constexpr int g(int C::*) { return 0; }
1086+
constexpr int h(int D::*) { return 0; }
1087+
1088+
constexpr auto p = static_cast<int A::*>(&B::i);
1089+
constexpr auto q = f(p);
1090+
constexpr auto r = g(p);
1091+
// since-cxx11-error@-1 {{constexpr variable 'r' must be initialized by a constant expression}}
1092+
constexpr auto s = h(p);
1093+
// since-cxx11-error@-1 {{constexpr variable 's' must be initialized by a constant expression}}
1094+
#endif
1095+
} // namespace cwg170
1096+
10771097
namespace { // cwg171: 3.4
10781098
int cwg171a;
10791099
}

clang/www/cxx_dr_status.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1065,7 +1065,7 @@ <h2 id="cxxdr">C++ defect report implementation status</h2>
10651065
<td><a href="https://cplusplus.github.io/CWG/issues/170.html">170</a></td>
10661066
<td>DRWP</td>
10671067
<td>Pointer-to-member conversions</td>
1068-
<td class="unknown" align="center">Unknown</td>
1068+
<td class="full" align="center">Clang 3.1</td>
10691069
</tr>
10701070
<tr id="171">
10711071
<td><a href="https://cplusplus.github.io/CWG/issues/171.html">171</a></td>

0 commit comments

Comments
 (0)