Skip to content

Commit d0918a2

Browse files
authored
[clang] Add tests for CWG1800-1804 (#77509)
Covers C++ core issues 1800, 1801, 1802, 1803, 1804.
1 parent 084f1c2 commit d0918a2

File tree

2 files changed

+166
-13
lines changed

2 files changed

+166
-13
lines changed

clang/test/CXX/drs/dr18xx.cpp

Lines changed: 160 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,169 @@
1-
// RUN: %clang_cc1 -std=c++98 -triple x86_64-unknown-unknown %s -verify=expected,cxx98 -fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
2-
// RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s -verify=expected,cxx11-17,since-cxx11 -fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
3-
// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s -verify=expected,cxx11-17,since-cxx11,since-cxx14 -fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
4-
// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-unknown %s -verify=expected,cxx11-17,since-cxx11,since-cxx14 -fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
5-
// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-unknown %s -verify=expected,since-cxx20,since-cxx11,since-cxx14 -fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
6-
// RUN: %clang_cc1 -std=c++23 -triple x86_64-unknown-unknown %s -verify=expected,since-cxx20,since-cxx11,since-cxx14 -fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
7-
// RUN: %clang_cc1 -std=c++2c -triple x86_64-unknown-unknown %s -verify=expected,since-cxx20,since-cxx11,since-cxx14 -fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
1+
// RUN: %clang_cc1 -std=c++98 -triple x86_64-unknown-unknown %s -verify=expected,cxx98-14,cxx98 -fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
2+
// RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s -verify=expected,cxx98-14,cxx11-17,since-cxx11 -fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
3+
// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s -verify=expected,cxx98-14,cxx11-17,since-cxx11,since-cxx14 -fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
4+
// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-unknown %s -verify=expected,since-cxx17,cxx11-17,since-cxx11,since-cxx14 -fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
5+
// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-unknown %s -verify=expected,since-cxx17,since-cxx20,since-cxx11,since-cxx14 -fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
6+
// RUN: %clang_cc1 -std=c++23 -triple x86_64-unknown-unknown %s -verify=expected,since-cxx17,since-cxx20,since-cxx11,since-cxx14 -fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
7+
// RUN: %clang_cc1 -std=c++2c -triple x86_64-unknown-unknown %s -verify=expected,since-cxx17,since-cxx20,since-cxx11,since-cxx14 -fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
88

99
#if __cplusplus == 199711L
1010
#define static_assert(...) __extension__ _Static_assert(__VA_ARGS__)
1111
// cxx98-error@-1 {{variadic macros are a C99 feature}}
1212
#endif
1313

14+
namespace dr1800 { // dr1800: 2.9
15+
struct A { union { int n; }; };
16+
static_assert(__is_same(__decltype(&A::n), int A::*), "");
17+
} // namespace dr1800
18+
19+
namespace dr1801 { // dr1801: 2.8
20+
static union {
21+
int i;
22+
};
23+
24+
template <int &> struct S {}; // #dr1801-S
25+
S<i> V; // #dr1801-S-i
26+
// cxx98-14-error@-1 {{non-type template argument does not refer to any declaration}}
27+
// cxx98-14-note@#dr1801-S {{template parameter is declared here}}
28+
// since-cxx17-error@#dr1801-S-i {{non-type template argument refers to subobject '.i'}}
29+
}
30+
31+
namespace dr1802 { // dr1802: 3.1
32+
#if __cplusplus >= 201103L
33+
// Using a Uncyclopedia example of surrogate pair:
34+
// https://en.wikipedia.org/wiki/UTF-16#Examples
35+
constexpr char16_t a[3] = u"\U00010437";
36+
static_assert(a[0] == 0xD801, "");
37+
static_assert(a[1] == 0xDC37, "");
38+
static_assert(a[2] == 0x0, "");
39+
#endif
40+
} // namespace dr1802
41+
42+
namespace dr1803 { // dr1803: 2.9
43+
#if __cplusplus >= 201103L
44+
struct A {
45+
enum E : int;
46+
enum E : int {};
47+
enum class EC;
48+
enum class EC {};
49+
enum struct ES;
50+
enum struct ES {};
51+
};
52+
#endif
53+
} // namespace dr1803
54+
55+
namespace dr1804 { // dr1804: 2.7
56+
template <typename, typename>
57+
struct A {
58+
void f1();
59+
60+
template <typename V>
61+
void f2(V);
62+
63+
class B {
64+
void f3();
65+
};
66+
67+
template <typename>
68+
class C {
69+
void f4();
70+
};
71+
};
72+
73+
template <typename U>
74+
struct A<int, U> {
75+
void f1();
76+
77+
template <typename V>
78+
void f2(V);
79+
80+
class B {
81+
void f3();
82+
};
83+
84+
template <typename>
85+
class C {
86+
void f4();
87+
};
88+
};
89+
90+
class D {
91+
int i;
92+
93+
template <typename, typename>
94+
friend struct A;
95+
};
96+
97+
template <typename U>
98+
struct A<double, U> {
99+
void f1();
100+
101+
template <typename V>
102+
void f2(V);
103+
104+
class B {
105+
void f3();
106+
};
107+
108+
template <typename>
109+
class C {
110+
void f4();
111+
};
112+
};
113+
114+
template <typename U>
115+
void A<int, U>::f1() {
116+
D d;
117+
d.i = 0;
118+
}
119+
120+
template <typename U>
121+
void A<double, U>::f1() {
122+
D d;
123+
d.i = 0;
124+
}
125+
126+
template <typename U>
127+
template <typename V>
128+
void A<int, U>::f2(V) {
129+
D d;
130+
d.i = 0;
131+
}
132+
133+
template <typename U>
134+
template <typename V>
135+
void A<double, U>::f2(V) {
136+
D d;
137+
d.i = 0;
138+
}
139+
140+
template <typename U>
141+
void A<int, U>::B::f3() {
142+
D d;
143+
d.i = 0;
144+
}
145+
146+
template <typename U>
147+
void A<double, U>::B::f3() {
148+
D d;
149+
d.i = 0;
150+
}
151+
152+
template <typename U>
153+
template <typename V>
154+
void A<int, U>::C<V>::f4() {
155+
D d;
156+
d.i = 0;
157+
}
158+
159+
template <typename U>
160+
template <typename V>
161+
void A<double, U>::C<V>::f4() {
162+
D d;
163+
d.i = 0;
164+
}
165+
} // namespace dr1804
166+
14167
namespace dr1812 { // dr1812: no
15168
// NB: dup 1710
16169
#if __cplusplus >= 201103L

clang/www/cxx_dr_status.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2661,7 +2661,7 @@ <h2 id="cxxdr">C++ defect report implementation status</h2>
26612661
<td><a href="https://cplusplus.github.io/CWG/issues/437.html">437</a></td>
26622662
<td>CD1</td>
26632663
<td>Is type of class allowed in member function exception specification?</td>
2664-
<td class="full" align="center">Superseded by <a href="#1308">1308</a></td>
2664+
<td class="none" align="center">Superseded by <a href="#1308">1308</a></td>
26652665
</tr>
26662666
<tr id="438">
26672667
<td><a href="https://cplusplus.github.io/CWG/issues/438.html">438</a></td>
@@ -10607,31 +10607,31 @@ <h2 id="cxxdr">C++ defect report implementation status</h2>
1060710607
<td><a href="https://cplusplus.github.io/CWG/issues/1800.html">1800</a></td>
1060810608
<td>CD4</td>
1060910609
<td>Pointer to member of nested anonymous union</td>
10610-
<td class="none" align="center">Unknown</td>
10610+
<td class="full" align="center">Clang 2.9</td>
1061110611
</tr>
1061210612
<tr id="1801">
1061310613
<td><a href="https://cplusplus.github.io/CWG/issues/1801.html">1801</a></td>
1061410614
<td>CD4</td>
1061510615
<td>Kind of expression referring to member of anonymous union</td>
10616-
<td class="none" align="center">Unknown</td>
10616+
<td class="full" align="center">Clang 2.8</td>
1061710617
</tr>
1061810618
<tr id="1802">
1061910619
<td><a href="https://cplusplus.github.io/CWG/issues/1802.html">1802</a></td>
1062010620
<td>CD4</td>
1062110621
<td><TT>char16_t</TT> string literals and surrogate pairs</td>
10622-
<td class="none" align="center">Unknown</td>
10622+
<td class="full" align="center">Clang 3.1</td>
1062310623
</tr>
1062410624
<tr id="1803">
1062510625
<td><a href="https://cplusplus.github.io/CWG/issues/1803.html">1803</a></td>
1062610626
<td>CD5</td>
1062710627
<td><I>opaque-enum-declaration</I> as <I>member-declaration</I></td>
10628-
<td class="none" align="center">Unknown</td>
10628+
<td class="full" align="center">Clang 2.9</td>
1062910629
</tr>
1063010630
<tr id="1804">
1063110631
<td><a href="https://cplusplus.github.io/CWG/issues/1804.html">1804</a></td>
1063210632
<td>CD4</td>
1063310633
<td>Partial specialization and friendship</td>
10634-
<td class="none" align="center">Unknown</td>
10634+
<td class="full" align="center">Clang 2.7</td>
1063510635
</tr>
1063610636
<tr id="1805">
1063710637
<td><a href="https://cplusplus.github.io/CWG/issues/1805.html">1805</a></td>

0 commit comments

Comments
 (0)