Skip to content

Commit 5ebeaf2

Browse files
authored
[clang] Add tests for some CWG 5xx issues (#87909)
This patch covers [CWG393](https://cplusplus.github.io/CWG/issues/393.html) "Pointer to array of unknown bound in template argument list in parameter", [CWG528](https://cplusplus.github.io/CWG/issues/528.html) "Why are incomplete class types not allowed with `typeid`?", [CWG550](https://cplusplus.github.io/CWG/issues/550.html) "Pointer to array of unknown bound in parameter declarations", [CWG553](https://cplusplus.github.io/CWG/issues/553.html) "Problems with friend allocation and deallocation functions", [CWG555](https://cplusplus.github.io/CWG/issues/555.html) "Pseudo-destructor name lookup", [CWG560](https://cplusplus.github.io/CWG/issues/560.html) "Use of the `typename` keyword in return types". CWG393 is on this list, because CWG550 is marked as a duplicate of CWG393. Test for CWG553 has been already written, but it was missing a status comment. As a drive-by fix, I'm adding missing status comments to CWG1584 and CWG1903 as well. CWG555 used CWG466 test, and also a variation of that test to test references. CWG466 is now testing non-reference non-pointer case. CWG560 showcases again that converting warnings to errors in DR tests via `-pedantic-errors` doesn't make things more clear. By default that test is accepted with an extension warning since we implemented [P0634R3](https://wg21.link/p0634r3) "Down with `typename`!" in Clang 16.
1 parent 33779b8 commit 5ebeaf2

File tree

6 files changed

+149
-39
lines changed

6 files changed

+149
-39
lines changed

clang/test/CXX/drs/dr15xx.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ auto DR1579_lambda_invalid = []() -> GenericMoveOnly<char> {
555555
#endif
556556
} // end namespace dr1579
557557

558-
namespace dr1584 {
558+
namespace dr1584 { // dr1584: 7 drafting 2015-05
559559
#if __cplusplus >= 201103L
560560
// Deducing function types from cv-qualified types
561561
template<typename T> void f(const T *); // #dr1584-f

clang/test/CXX/drs/dr19xx.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ namespace dr1902 { // dr1902: 3.7
3434
#endif
3535
}
3636

37-
namespace dr1903 {
37+
namespace dr1903 { // dr1903: 2.7
3838
namespace A {
3939
struct a {};
4040
int a;

clang/test/CXX/drs/dr3xx.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1568,6 +1568,25 @@ namespace dr391 { // dr391: 2.8 c++11
15681568
}
15691569

15701570
// dr392 is in dr392.cpp
1571+
1572+
namespace dr393 { // dr393: 2.7
1573+
template <typename T>
1574+
struct S {};
1575+
1576+
void f1(S<int (*)[]>);
1577+
void f2(S<int (&)[]>);
1578+
void g(int(*S<int>::*)[]);
1579+
1580+
template<typename T>
1581+
void sp_assert_convertible( T* ) {}
1582+
1583+
template<typename T, typename U>
1584+
void h() {
1585+
T (*p) [] = (U(*)[])0;
1586+
sp_assert_convertible<T[]>( (U(*)[])0 );
1587+
}
1588+
} // namespace dr393
1589+
15711590
// dr394: na
15721591

15731592
namespace dr395 { // dr395: 3.0

clang/test/CXX/drs/dr4xx.cpp

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
// RUN: env ASAN_OPTIONS=detect_stack_use_after_return=0 %clang_cc1 -std=c++11 %s -verify=expected,cxx98-14,cxx98-17,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors
33
// RUN: env ASAN_OPTIONS=detect_stack_use_after_return=0 %clang_cc1 -std=c++14 %s -verify=expected,cxx98-14,cxx98-17,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors
44
// RUN: env ASAN_OPTIONS=detect_stack_use_after_return=0 %clang_cc1 -std=c++17 %s -verify=expected,since-cxx17,cxx98-17,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors
5-
// RUN: env ASAN_OPTIONS=detect_stack_use_after_return=0 %clang_cc1 -std=c++20 %s -verify=expected,since-cxx17,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors
6-
// RUN: env ASAN_OPTIONS=detect_stack_use_after_return=0 %clang_cc1 -std=c++23 %s -verify=expected,since-cxx17,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors
5+
// RUN: env ASAN_OPTIONS=detect_stack_use_after_return=0 %clang_cc1 -std=c++20 %s -verify=expected,since-cxx20,since-cxx17,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors
6+
// RUN: env ASAN_OPTIONS=detect_stack_use_after_return=0 %clang_cc1 -std=c++23 %s -verify=expected,since-cxx20,since-cxx17,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors
7+
// RUN: env ASAN_OPTIONS=detect_stack_use_after_return=0 %clang_cc1 -std=c++2c %s -verify=expected,since-cxx20,since-cxx17,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors
78

89
// FIXME: __SIZE_TYPE__ expands to 'long long' on some targets.
910
__extension__ typedef __SIZE_TYPE__ size_t;
@@ -949,33 +950,34 @@ namespace dr460 { // dr460: yes
949950
// dr465: na
950951

951952
namespace dr466 { // dr466: 2.8
952-
typedef int I;
953-
typedef const int CI;
954-
typedef volatile int VI;
955-
void f(int *a, CI *b, VI *c) {
956-
a->~I();
957-
a->~CI();
958-
a->~VI();
959-
a->I::~I();
960-
a->CI::~CI();
961-
a->VI::~VI();
962-
963-
a->CI::~VI(); // allowed by changes to [expr.id.prim.qual]/2 introduced in P1131R2
964-
965-
b->~I();
966-
b->~CI();
967-
b->~VI();
968-
b->I::~I();
969-
b->CI::~CI();
970-
b->VI::~VI();
971-
972-
c->~I();
973-
c->~CI();
974-
c->~VI();
975-
c->I::~I();
976-
c->CI::~CI();
977-
c->VI::~VI();
978-
}
953+
typedef int I;
954+
typedef const int CI;
955+
typedef volatile int VI;
956+
void g(int a, CI b, VI c) {
957+
// since-cxx20-warning@-1 {{volatile-qualified parameter type 'VI' (aka 'volatile int') is deprecated}}
958+
a.~I();
959+
a.~CI();
960+
a.~VI();
961+
a.I::~I();
962+
a.CI::~CI();
963+
a.VI::~VI();
964+
965+
a.CI::~VI(); // allowed by changes to [expr.id.prim.qual]/2 introduced in P1131R2
966+
967+
b.~I();
968+
b.~CI();
969+
b.~VI();
970+
b.I::~I();
971+
b.CI::~CI();
972+
b.VI::~VI();
973+
974+
c.~I();
975+
c.~CI();
976+
c.~VI();
977+
c.I::~I();
978+
c.CI::~CI();
979+
c.VI::~VI();
980+
}
979981
}
980982

981983
namespace dr467 { // dr467: yes

clang/test/CXX/drs/dr5xx.cpp

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ namespace std {
1818
void *operator new(size_t, std::align_val_t); // #dr5xx-global-operator-new-aligned
1919
#endif
2020

21+
namespace std {
22+
struct type_info;
23+
}
24+
2125
namespace dr500 { // dr500: dup 372
2226
class D;
2327
class A {
@@ -265,6 +269,18 @@ namespace dr527 { // dr527: na
265269
int ax = a.x, bx = b.x, cx = c.x, dx = d.x, ex = E::e->x, fx = F::f->x;
266270
}
267271

272+
namespace dr528 { // dr528: 2.7
273+
274+
struct S; // #dr528-S
275+
276+
void f() {
277+
typeid(S);
278+
// expected-error@-1 {{'typeid' of incomplete type 'S'}}
279+
// expected-note@#dr528-S {{forward declaration of 'dr528::S'}}
280+
}
281+
282+
} // namespace dr528
283+
268284
namespace dr530 { // dr530: yes
269285
template<int*> struct S { enum { N = 1 }; };
270286
template<void(*)()> struct T { enum { N = 1 }; };
@@ -618,6 +634,8 @@ namespace dr548 { // dr548: dup 482
618634
template void dr548::f<int>();
619635
}
620636

637+
// dr550: dup 393
638+
621639
namespace dr551 { // dr551: yes c++11
622640
// FIXME: This obviously should apply in C++98 mode too.
623641
template<typename T> void f() {}
@@ -641,6 +659,7 @@ namespace dr552 { // dr552: yes
641659
X<Y, 0> x;
642660
}
643661

662+
// dr553: 2.7
644663
struct dr553_class {
645664
friend void *operator new(size_t, dr553_class);
646665
};
@@ -661,6 +680,62 @@ namespace dr553 {
661680
}
662681

663682
// dr554: na
683+
684+
namespace dr555 { // dr555: 2.8
685+
typedef int I;
686+
typedef const int CI;
687+
typedef volatile int VI;
688+
void f(int *a, CI *b, VI *c) {
689+
a->~I();
690+
a->~CI();
691+
a->~VI();
692+
a->I::~I();
693+
a->CI::~CI();
694+
a->VI::~VI();
695+
696+
a->CI::~VI(); // allowed by changes to [expr.id.prim.qual]/2 introduced in P1131R2
697+
698+
b->~I();
699+
b->~CI();
700+
b->~VI();
701+
b->I::~I();
702+
b->CI::~CI();
703+
b->VI::~VI();
704+
705+
c->~I();
706+
c->~CI();
707+
c->~VI();
708+
c->I::~I();
709+
c->CI::~CI();
710+
c->VI::~VI();
711+
}
712+
713+
void g(int &a, CI &b, VI &c) {
714+
a.~I();
715+
a.~CI();
716+
a.~VI();
717+
a.I::~I();
718+
a.CI::~CI();
719+
a.VI::~VI();
720+
721+
a.CI::~VI(); // allowed by changes to [expr.id.prim.qual]/2 introduced in P1131R2
722+
723+
b.~I();
724+
b.~CI();
725+
b.~VI();
726+
b.I::~I();
727+
b.CI::~CI();
728+
b.VI::~VI();
729+
730+
c.~I();
731+
c.~CI();
732+
c.~VI();
733+
c.I::~I();
734+
c.CI::~CI();
735+
c.VI::~VI();
736+
}
737+
} // namespace dr555
738+
664739
// dr556: na
665740

666741
namespace dr557 { // dr557: 3.1
@@ -689,6 +764,20 @@ namespace dr558 { // dr558: 2.9
689764

690765
template<typename> struct dr559 { typedef int T; dr559::T u; }; // dr559: yes
691766

767+
namespace dr560 { // dr560: 16
768+
769+
template <class T>
770+
struct Outer {
771+
struct Inner {
772+
Inner* self();
773+
};
774+
};
775+
template <class T>
776+
Outer<T>::Inner* Outer<T>::Inner::self() { return this; }
777+
// cxx98-17-error@-1 {{missing 'typename' prior to dependent type name Outer<T>::Inner; implicit 'typename' is a C++20 extension}}
778+
779+
} // namespace dr560
780+
692781
namespace dr561 { // dr561: yes
693782
template<typename T> void f(int);
694783
template<typename T> void g(T t) {

clang/www/cxx_dr_status.html

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2398,7 +2398,7 @@ <h2 id="cxxdr">C++ defect report implementation status</h2>
23982398
<td><a href="https://cplusplus.github.io/CWG/issues/393.html">393</a></td>
23992399
<td>CD4</td>
24002400
<td>Pointer to array of unknown bound in template argument list in parameter</td>
2401-
<td class="unknown" align="center">Unknown</td>
2401+
<td class="full" align="center">Clang 2.7</td>
24022402
</tr>
24032403
<tr id="394">
24042404
<td><a href="https://cplusplus.github.io/CWG/issues/394.html">394</a></td>
@@ -3208,7 +3208,7 @@ <h2 id="cxxdr">C++ defect report implementation status</h2>
32083208
<td><a href="https://cplusplus.github.io/CWG/issues/528.html">528</a></td>
32093209
<td>NAD</td>
32103210
<td>Why are incomplete class types not allowed with <TT>typeid</TT>?</td>
3211-
<td class="unknown" align="center">Unknown</td>
3211+
<td class="full" align="center">Clang 2.7</td>
32123212
</tr>
32133213
<tr class="open" id="529">
32143214
<td><a href="https://cplusplus.github.io/CWG/issues/529.html">529</a></td>
@@ -3342,7 +3342,7 @@ <h2 id="cxxdr">C++ defect report implementation status</h2>
33423342
<td><a href="https://cplusplus.github.io/CWG/issues/550.html">550</a></td>
33433343
<td>dup</td>
33443344
<td>Pointer to array of unknown bound in parameter declarations</td>
3345-
<td class="unknown" align="center">Unknown</td>
3345+
<td class="full" align="center">Duplicate of <a href="#393">393</a></td>
33463346
</tr>
33473347
<tr id="551">
33483348
<td><a href="https://cplusplus.github.io/CWG/issues/551.html">551</a></td>
@@ -3360,7 +3360,7 @@ <h2 id="cxxdr">C++ defect report implementation status</h2>
33603360
<td><a href="https://cplusplus.github.io/CWG/issues/553.html">553</a></td>
33613361
<td>NAD</td>
33623362
<td>Problems with friend allocation and deallocation functions</td>
3363-
<td class="unknown" align="center">Unknown</td>
3363+
<td class="full" align="center">Clang 2.7</td>
33643364
</tr>
33653365
<tr id="554">
33663366
<td><a href="https://cplusplus.github.io/CWG/issues/554.html">554</a></td>
@@ -3372,7 +3372,7 @@ <h2 id="cxxdr">C++ defect report implementation status</h2>
33723372
<td><a href="https://cplusplus.github.io/CWG/issues/555.html">555</a></td>
33733373
<td>CD5</td>
33743374
<td>Pseudo-destructor name lookup</td>
3375-
<td class="unknown" align="center">Unknown</td>
3375+
<td class="full" align="center">Clang 2.8</td>
33763376
</tr>
33773377
<tr id="556">
33783378
<td><a href="https://cplusplus.github.io/CWG/issues/556.html">556</a></td>
@@ -3402,7 +3402,7 @@ <h2 id="cxxdr">C++ defect report implementation status</h2>
34023402
<td><a href="https://cplusplus.github.io/CWG/issues/560.html">560</a></td>
34033403
<td>NAD</td>
34043404
<td>Use of the <TT>typename</TT> keyword in return types</td>
3405-
<td class="unknown" align="center">Unknown</td>
3405+
<td class="full" align="center">Clang 16</td>
34063406
</tr>
34073407
<tr id="561">
34083408
<td><a href="https://cplusplus.github.io/CWG/issues/561.html">561</a></td>
@@ -9312,7 +9312,7 @@ <h2 id="cxxdr">C++ defect report implementation status</h2>
93129312
<td><a href="https://cplusplus.github.io/CWG/issues/1584.html">1584</a></td>
93139313
<td>drafting</td>
93149314
<td>Deducing function types from cv-qualified types</td>
9315-
<td align="center">Not resolved</td>
9315+
<td title="Clang 7 implements 2015-05 resolution" align="center">Not Resolved*</td>
93169316
</tr>
93179317
<tr id="1585">
93189318
<td><a href="https://cplusplus.github.io/CWG/issues/1585.html">1585</a></td>
@@ -11226,7 +11226,7 @@ <h2 id="cxxdr">C++ defect report implementation status</h2>
1122611226
<td><a href="https://cplusplus.github.io/CWG/issues/1903.html">1903</a></td>
1122711227
<td>CD4</td>
1122811228
<td>What declarations are introduced by a non-member <I>using-declaration</I>?</td>
11229-
<td class="unknown" align="center">Unknown</td>
11229+
<td class="full" align="center">Clang 2.7</td>
1123011230
</tr>
1123111231
<tr id="1904">
1123211232
<td><a href="https://cplusplus.github.io/CWG/issues/1904.html">1904</a></td>

0 commit comments

Comments
 (0)