Skip to content

Commit 4f2dba3

Browse files
authored
[clang] Add tests for some CWG issues from 2024-05-31 telecon (#94167)
This patch adds tests for some CWG issues that were discussed at 2024-05-31 telecon. While all of them are tentatively ready at the moment, I'm expecting them to be moved to DRs without changes. CWG issues that are expected to have follow-ups are not included in this PR. I also realized that `cwg28xx.cpp` has been testing without `-pedantic-errors`. I fixed that. Fortunately, no existing tests had anything hidden by the lack of this flag. The following CWG issues are covered: [CWG2877](https://cplusplus.github.io/CWG/issues/2877.html) "Type-only lookup for _using-enum-declarator_" [CWG2882](https://cplusplus.github.io/CWG/issues/2882.html) "Unclear treatment of conversion to `void`" [CWG2883](https://cplusplus.github.io/CWG/issues/2883.html) "Definition of "odr-usable" ignores lambda scopes" [CWG2885](https://cplusplus.github.io/CWG/issues/2885.html) "Non-eligible trivial default constructors" [CWG2886](https://cplusplus.github.io/CWG/issues/2886.html) "Temporaries and trivial potentially-throwing special member functions"
1 parent e28b070 commit 4f2dba3

File tree

2 files changed

+93
-12
lines changed

2 files changed

+93
-12
lines changed

clang/test/CXX/drs/cwg28xx.cpp

Lines changed: 88 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
// RUN: %clang_cc1 -std=c++98 -verify=expected %s
2-
// RUN: %clang_cc1 -std=c++11 -verify=expected %s
3-
// RUN: %clang_cc1 -std=c++14 -verify=expected %s
4-
// RUN: %clang_cc1 -std=c++17 -verify=expected %s
5-
// RUN: %clang_cc1 -std=c++20 -verify=expected,since-cxx20 %s
6-
// RUN: %clang_cc1 -std=c++23 -verify=expected,since-cxx20,since-cxx23 %s
7-
// RUN: %clang_cc1 -std=c++2c -verify=expected,since-cxx20,since-cxx23,since-cxx26 %s
1+
// RUN: %clang_cc1 -std=c++98 -pedantic-errors -verify=expected,cxx98 %s
2+
// RUN: %clang_cc1 -std=c++11 -pedantic-errors -verify=expected %s
3+
// RUN: %clang_cc1 -std=c++14 -pedantic-errors -verify=expected %s
4+
// RUN: %clang_cc1 -std=c++17 -pedantic-errors -verify=expected %s
5+
// RUN: %clang_cc1 -std=c++20 -pedantic-errors -verify=expected,since-cxx20 %s
6+
// RUN: %clang_cc1 -std=c++23 -pedantic-errors -verify=expected,since-cxx20,since-cxx23 %s
7+
// RUN: %clang_cc1 -std=c++2c -pedantic-errors -verify=expected,since-cxx20,since-cxx23,since-cxx26 %s
88

99
namespace cwg2819 { // cwg2819: 19 tentatively ready 2023-12-01
1010
#if __cpp_constexpr >= 202306L
@@ -110,6 +110,26 @@ struct A {
110110

111111
} // namespace cwg2858
112112

113+
namespace cwg2877 { // cwg2877: no tentatively ready 2024-05-31
114+
#if __cplusplus >= 202002L
115+
enum E { x };
116+
void f() {
117+
int E;
118+
// FIXME: OK, names ::E
119+
using enum E;
120+
// since-cxx20-error@-1 {{unknown type name E}}
121+
}
122+
using F = E;
123+
using enum F; // OK, designates ::E
124+
template<class T> using EE = T;
125+
void g() {
126+
// FIXME: OK, designates ::E
127+
using enum EE<E>;
128+
// since-cxx20-error@-1 {{using enum requires an enum or typedef name}}
129+
}
130+
#endif
131+
} // namespace cwg2877
132+
113133
namespace cwg2881 { // cwg2881: 19 tentatively ready 2024-04-19
114134

115135
#if __cplusplus >= 202302L
@@ -180,3 +200,64 @@ void f() {
180200

181201
} // namespace cwg2881
182202

203+
namespace cwg2882 { // cwg2882: 2.7 tentatively ready 2024-05-31
204+
struct C {
205+
operator void() = delete;
206+
// expected-warning@-1 {{conversion function converting 'cwg2882::C' to 'void' will never be used}}
207+
// cxx98-error@-2 {{deleted function definitions are a C++11 extension}}
208+
};
209+
210+
void f(C c) {
211+
(void)c;
212+
}
213+
} // namespace cwg2882
214+
215+
namespace cwg2883 { // cwg2883: no tentatively ready 2024-05-31
216+
#if __cplusplus >= 201103L
217+
void f() {
218+
int x;
219+
(void)[&] {
220+
return x;
221+
};
222+
}
223+
#endif
224+
#if __cplusplus >= 202002L
225+
struct A {
226+
A() = default;
227+
A(const A &) = delete; // #cwg2883-A-copy-ctor
228+
constexpr operator int() { return 42; }
229+
};
230+
void g() {
231+
constexpr A a;
232+
// FIXME: OK, not odr-usable from a default template argument, and not odr-used
233+
(void)[=]<typename T, int = a> {};
234+
// since-cxx20-error@-1 {{call to deleted constructor of 'const A'}}
235+
// since-cxx20-note@#cwg2883-A-copy-ctor {{'A' has been explicitly marked deleted here}}
236+
}
237+
#endif
238+
} // namespace cwg2883
239+
240+
namespace cwg2885 { // cwg2885: 16 tentatively ready 2024-05-31
241+
#if __cplusplus >= 202002L
242+
template <class T>
243+
struct A {
244+
A() requires (false) = default;
245+
A() : t(42) {}
246+
T t;
247+
};
248+
249+
struct B : A<int> {};
250+
static_assert(!__is_trivially_constructible(B));
251+
#endif
252+
} // namespace cwg2885
253+
254+
namespace cwg2886 { // cwg2886: 9 tentatively ready 2024-05-31
255+
#if __cplusplus >= 201103L
256+
struct C {
257+
C() = default;
258+
~C() noexcept(false) = default;
259+
};
260+
261+
static_assert(noexcept(C()), "");
262+
#endif
263+
} // namespace cwg2886

clang/www/cxx_dr_status.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17071,7 +17071,7 @@ <h2 id="cxxdr">C++ defect report implementation status</h2>
1707117071
<td><a href="https://cplusplus.github.io/CWG/issues/2877.html">2877</a></td>
1707217072
<td>tentatively ready</td>
1707317073
<td>Type-only lookup for <I>using-enum-declarator</I></td>
17074-
<td align="center">Not resolved</td>
17074+
<td title="Clang does not implement 2024-05-31 resolution" align="center">Not Resolved*</td>
1707517075
</tr>
1707617076
<tr class="open" id="2878">
1707717077
<td><a href="https://cplusplus.github.io/CWG/issues/2878.html">2878</a></td>
@@ -17101,13 +17101,13 @@ <h2 id="cxxdr">C++ defect report implementation status</h2>
1710117101
<td><a href="https://cplusplus.github.io/CWG/issues/2882.html">2882</a></td>
1710217102
<td>tentatively ready</td>
1710317103
<td>Unclear treatment of conversion to <TT>void</TT></td>
17104-
<td align="center">Not resolved</td>
17104+
<td title="Clang 2.7 implements 2024-05-31 resolution" align="center">Not Resolved*</td>
1710517105
</tr>
1710617106
<tr class="open" id="2883">
1710717107
<td><a href="https://cplusplus.github.io/CWG/issues/2883.html">2883</a></td>
1710817108
<td>tentatively ready</td>
1710917109
<td>Definition of "odr-usable" ignores lambda scopes</td>
17110-
<td align="center">Not resolved</td>
17110+
<td title="Clang does not implement 2024-05-31 resolution" align="center">Not Resolved*</td>
1711117111
</tr>
1711217112
<tr id="2884">
1711317113
<td><a href="https://cplusplus.github.io/CWG/issues/2884.html">2884</a></td>
@@ -17119,13 +17119,13 @@ <h2 id="cxxdr">C++ defect report implementation status</h2>
1711917119
<td><a href="https://cplusplus.github.io/CWG/issues/2885.html">2885</a></td>
1712017120
<td>tentatively ready</td>
1712117121
<td>Non-eligible trivial default constructors</td>
17122-
<td align="center">Not resolved</td>
17122+
<td title="Clang 16 implements 2024-05-31 resolution" align="center">Not Resolved*</td>
1712317123
</tr>
1712417124
<tr class="open" id="2886">
1712517125
<td><a href="https://cplusplus.github.io/CWG/issues/2886.html">2886</a></td>
1712617126
<td>tentatively ready</td>
1712717127
<td>Temporaries and trivial potentially-throwing special member functions</td>
17128-
<td align="center">Not resolved</td>
17128+
<td title="Clang 9 implements 2024-05-31 resolution" align="center">Not Resolved*</td>
1712917129
</tr>
1713017130
<tr class="open" id="2887">
1713117131
<td><a href="https://cplusplus.github.io/CWG/issues/2887.html">2887</a></td>

0 commit comments

Comments
 (0)