Skip to content

Commit 93e2a9a

Browse files
authored
[clang] Add CodeGen tests for CWG 6xx issues (#87876)
This patch covers [CWG605](https://cplusplus.github.io/CWG/issues/605.html) "Linkage of explicit specializations", [CWG650](https://cplusplus.github.io/CWG/issues/650.html) "Order of destruction for temporaries bound to the returned value of a function", [CWG653](https://cplusplus.github.io/CWG/issues/653.html) "Copy assignment of unions", [CWG658](https://cplusplus.github.io/CWG/issues/658.html) "Defining `reinterpret_cast` for pointer types", [CWG661](https://cplusplus.github.io/CWG/issues/661.html) "Semantics of arithmetic comparisons", [CWG672](https://cplusplus.github.io/CWG/issues/672.html) "Sequencing of initialization in _new-expression_s". [CWG624](https://cplusplus.github.io/CWG/issues/624.html) "Overflow in calculating size of allocation" and [CWG668](https://cplusplus.github.io/CWG/issues/668.html) "Throwing an exception from the destructor of a local static object" are marked as requiring libc++abi tests.
1 parent d345f6a commit 93e2a9a

File tree

8 files changed

+188
-14
lines changed

8 files changed

+188
-14
lines changed

clang/test/CXX/drs/dr605.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// RUN: %clang_cc1 -std=c++98 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
2+
// RUN: %clang_cc1 -std=c++11 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
3+
// RUN: %clang_cc1 -std=c++14 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
4+
// RUN: %clang_cc1 -std=c++17 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
5+
// RUN: %clang_cc1 -std=c++20 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
6+
// RUN: %clang_cc1 -std=c++23 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
7+
// RUN: %clang_cc1 -std=c++2c %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
8+
9+
namespace dr605 { // dr605: 2.7
10+
11+
template <class T>
12+
static T f(T t) {}
13+
14+
template <>
15+
int f(int t) {}
16+
17+
void g(int a) {
18+
f(a);
19+
}
20+
21+
} // namespace dr605
22+
23+
// CHECK: define internal {{.*}} i32 @int dr605::f<int>(int)

clang/test/CXX/drs/dr650.cpp

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// RUN: %clang_cc1 -std=c++98 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
2+
// RUN: %clang_cc1 -std=c++11 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
3+
// RUN: %clang_cc1 -std=c++14 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
4+
// RUN: %clang_cc1 -std=c++17 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
5+
// RUN: %clang_cc1 -std=c++20 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
6+
// RUN: %clang_cc1 -std=c++23 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
7+
// RUN: %clang_cc1 -std=c++2c %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
8+
9+
#if __cplusplus == 199711L
10+
#define NOTHROW throw()
11+
#else
12+
#define NOTHROW noexcept(true)
13+
#endif
14+
15+
namespace dr650 { // dr650: 2.8
16+
17+
struct Q {
18+
~Q() NOTHROW;
19+
};
20+
21+
struct R {
22+
~R() NOTHROW;
23+
};
24+
25+
struct S {
26+
~S() NOTHROW;
27+
};
28+
29+
const S& f() {
30+
Q q;
31+
return (R(), S());
32+
}
33+
34+
} // namespace dr650
35+
36+
// CHECK-LABEL: define {{.*}} @dr650::f()()
37+
// CHECK: call void @dr650::S::~S()
38+
// CHECK: call void @dr650::R::~R()
39+
// CHECK: call void @dr650::Q::~Q()
40+
// CHECK-LABEL: }

clang/test/CXX/drs/dr653.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// RUN: %clang_cc1 -std=c++98 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
2+
// RUN: %clang_cc1 -std=c++11 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
3+
// RUN: %clang_cc1 -std=c++14 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
4+
// RUN: %clang_cc1 -std=c++17 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
5+
// RUN: %clang_cc1 -std=c++20 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
6+
// RUN: %clang_cc1 -std=c++23 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
7+
// RUN: %clang_cc1 -std=c++2c %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
8+
9+
namespace dr653 { // dr653: 2.7
10+
11+
union U {
12+
int a;
13+
float b;
14+
};
15+
16+
void f(U u) {
17+
U v;
18+
v = u;
19+
}
20+
21+
} // namespace dr653
22+
23+
// CHECK-LABEL: define {{.*}} void @dr653::f(dr653::U)
24+
// CHECK: call void @llvm.memcpy.p0.p0.i64(ptr {{.*}} %v, ptr {{.*}} %u, {{.*}})
25+
// CHECK-LABEL: }

clang/test/CXX/drs/dr658.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// RUN: %clang_cc1 -std=c++98 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
2+
// RUN: %clang_cc1 -std=c++11 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
3+
// RUN: %clang_cc1 -std=c++14 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
4+
// RUN: %clang_cc1 -std=c++17 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
5+
// RUN: %clang_cc1 -std=c++20 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
6+
// RUN: %clang_cc1 -std=c++23 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
7+
// RUN: %clang_cc1 -std=c++2c %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
8+
9+
namespace dr658 { // dr658: 2.7
10+
11+
void f(int* p1) {
12+
char* p2 = reinterpret_cast<char*>(p1);
13+
}
14+
15+
} // namespace dr658
16+
17+
// We're checking that p1 is stored into p2 without changes.
18+
19+
// CHECK-LABEL: define {{.*}} void @dr658::f(int*)(ptr noundef %p1)
20+
// CHECK: [[P1_ADDR:%.+]] = alloca ptr, align 8
21+
// CHECK-NEXT: [[P2:%.+]] = alloca ptr, align 8
22+
// CHECK: store ptr %p1, ptr [[P1_ADDR]]
23+
// CHECK-NEXT: [[TEMP:%.+]] = load ptr, ptr [[P1_ADDR]]
24+
// CHECK-NEXT: store ptr [[TEMP]], ptr [[P2]]
25+
// CHECK-LABEL: }

clang/test/CXX/drs/dr661.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// RUN: %clang_cc1 -std=c++98 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
2+
// RUN: %clang_cc1 -std=c++11 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
3+
// RUN: %clang_cc1 -std=c++14 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
4+
// RUN: %clang_cc1 -std=c++17 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
5+
// RUN: %clang_cc1 -std=c++20 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
6+
// RUN: %clang_cc1 -std=c++23 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
7+
// RUN: %clang_cc1 -std=c++2c %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
8+
9+
namespace dr661 {
10+
11+
void f(int a, int b) { // dr661: 2.7
12+
a == b;
13+
a != b;
14+
a < b;
15+
a <= b;
16+
a > b;
17+
a >= b;
18+
}
19+
20+
} // namespace dr661
21+
22+
// CHECK-LABEL: define {{.*}} void @dr661::f(int, int)
23+
// CHECK: icmp eq
24+
// CHECK: icmp ne
25+
// CHECK: icmp slt
26+
// CHECK: icmp sle
27+
// CHECK: icmp sgt
28+
// CHECK: icmp sge
29+
// CHECK-LABEL: }

clang/test/CXX/drs/dr672.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// RUN: %clang_cc1 -std=c++98 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
2+
// RUN: %clang_cc1 -std=c++11 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
3+
// RUN: %clang_cc1 -std=c++14 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
4+
// RUN: %clang_cc1 -std=c++17 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
5+
// RUN: %clang_cc1 -std=c++20 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
6+
// RUN: %clang_cc1 -std=c++23 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
7+
// RUN: %clang_cc1 -std=c++2c %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
8+
9+
#if __cplusplus == 199711L
10+
#define NOTHROW throw()
11+
#else
12+
#define NOTHROW noexcept(true)
13+
#endif
14+
15+
namespace dr672 { // dr672: 2.7
16+
17+
struct A {
18+
A() NOTHROW;
19+
};
20+
21+
void f() {
22+
A *a = new A;
23+
}
24+
25+
} // namespace dr672
26+
27+
// CHECK-LABEL: define {{.*}} void @dr672::f()()
28+
// CHECK: [[A:%.+]] = alloca ptr
29+
// CHECK: [[CALL:%.+]] = call {{.*}} ptr @operator new(unsigned long)
30+
// CHECK: call void @dr672::A::A()
31+
// CHECK: store ptr [[CALL]], ptr [[A]]
32+
// CHECK-LABEL: }

clang/test/CXX/drs/dr6xx.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ namespace dr603 { // dr603: yes
8181
}
8282

8383
// dr604: na
84-
// dr605 needs IRGen test
84+
// dr605 is in dr605.cpp
8585

8686
namespace dr606 { // dr606: 3.0
8787
#if __cplusplus >= 201103L
@@ -253,7 +253,7 @@ namespace dr621 { // dr621: yes
253253
// dr623: na
254254
// FIXME: Add documentation saying we allow invalid pointer values.
255255

256-
// dr624 needs an IRGen check.
256+
// dr624 needs a libc++abi test.
257257

258258
namespace dr625 { // dr625: yes
259259
template<typename T> struct A {};
@@ -650,7 +650,7 @@ struct Y {
650650
}
651651
#endif
652652

653-
// dr650 FIXME: add codegen test
653+
// dr650 is in dr650.cpp
654654

655655
#if __cplusplus >= 201103L
656656
namespace dr651 { // dr651: yes
@@ -672,7 +672,7 @@ namespace dr652 { // dr652: yes
672672
}
673673
#endif
674674

675-
// dr653 FIXME: add codegen test
675+
// dr653 is in dr653.cpp
676676

677677
#if __cplusplus >= 201103L
678678
namespace dr654 { // dr654: sup 1423
@@ -798,7 +798,7 @@ namespace dr657 { // dr657: partial
798798
Cnvt2<Abs>::type err;
799799
}
800800

801-
// dr658 FIXME: add codegen test
801+
// dr658 is in dr658.cpp
802802

803803
#if __cplusplus >= 201103L
804804
namespace dr659 { // dr659: 3.0
@@ -829,7 +829,7 @@ namespace dr660 { // dr660: 3.0
829829
}
830830
#endif
831831

832-
// dr661 FIXME: add codegen test
832+
// dr661 is in dr661.cpp
833833

834834
namespace dr662 { // dr662: yes
835835
template <typename T> void f(T t) {
@@ -931,7 +931,7 @@ namespace dr667 { // dr667: 8
931931
}
932932
#endif
933933

934-
// dr668 FIXME: add codegen test
934+
// dr668 needs an libc++abi test
935935

936936
#if __cplusplus >= 201103L
937937
namespace dr669 { // dr669: yes
@@ -971,7 +971,7 @@ namespace dr671 { // dr671: 2.9
971971
int m = static_cast<int>(e);
972972
}
973973

974-
// dr672 FIXME: add codegen test
974+
// dr672 is in dr672.cpp
975975

976976
namespace dr673 { // dr673: yes
977977
template<typename> struct X { static const int n = 0; };

clang/www/cxx_dr_status.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3672,7 +3672,7 @@ <h2 id="cxxdr">C++ defect report implementation status</h2>
36723672
<td><a href="https://cplusplus.github.io/CWG/issues/605.html">605</a></td>
36733673
<td>C++11</td>
36743674
<td>Linkage of explicit specializations</td>
3675-
<td class="unknown" align="center">Unknown</td>
3675+
<td class="full" align="center">Clang 2.7</td>
36763676
</tr>
36773677
<tr id="606">
36783678
<td><a href="https://cplusplus.github.io/CWG/issues/606.html">606</a></td>
@@ -3942,7 +3942,7 @@ <h2 id="cxxdr">C++ defect report implementation status</h2>
39423942
<td><a href="https://cplusplus.github.io/CWG/issues/650.html">650</a></td>
39433943
<td>CD2</td>
39443944
<td>Order of destruction for temporaries bound to the returned value of a function</td>
3945-
<td class="unknown" align="center">Unknown</td>
3945+
<td class="full" align="center">Clang 2.8</td>
39463946
</tr>
39473947
<tr id="651">
39483948
<td><a href="https://cplusplus.github.io/CWG/issues/651.html">651</a></td>
@@ -3960,7 +3960,7 @@ <h2 id="cxxdr">C++ defect report implementation status</h2>
39603960
<td><a href="https://cplusplus.github.io/CWG/issues/653.html">653</a></td>
39613961
<td>CD2</td>
39623962
<td>Copy assignment of unions</td>
3963-
<td class="unknown" align="center">Unknown</td>
3963+
<td class="full" align="center">Clang 2.7</td>
39643964
</tr>
39653965
<tr id="654">
39663966
<td><a href="https://cplusplus.github.io/CWG/issues/654.html">654</a></td>
@@ -3990,7 +3990,7 @@ <h2 id="cxxdr">C++ defect report implementation status</h2>
39903990
<td><a href="https://cplusplus.github.io/CWG/issues/658.html">658</a></td>
39913991
<td>CD2</td>
39923992
<td>Defining <TT>reinterpret_cast</TT> for pointer types</td>
3993-
<td class="unknown" align="center">Unknown</td>
3993+
<td class="full" align="center">Clang 2.7</td>
39943994
</tr>
39953995
<tr id="659">
39963996
<td><a href="https://cplusplus.github.io/CWG/issues/659.html">659</a></td>
@@ -4008,7 +4008,7 @@ <h2 id="cxxdr">C++ defect report implementation status</h2>
40084008
<td><a href="https://cplusplus.github.io/CWG/issues/661.html">661</a></td>
40094009
<td>CD1</td>
40104010
<td>Semantics of arithmetic comparisons</td>
4011-
<td class="unknown" align="center">Unknown</td>
4011+
<td class="full" align="center">Clang 2.7</td>
40124012
</tr>
40134013
<tr id="662">
40144014
<td><a href="https://cplusplus.github.io/CWG/issues/662.html">662</a></td>
@@ -4074,7 +4074,7 @@ <h2 id="cxxdr">C++ defect report implementation status</h2>
40744074
<td><a href="https://cplusplus.github.io/CWG/issues/672.html">672</a></td>
40754075
<td>CD2</td>
40764076
<td>Sequencing of initialization in <I>new-expression</I>s</td>
4077-
<td class="unknown" align="center">Unknown</td>
4077+
<td class="full" align="center">Clang 2.7</td>
40784078
</tr>
40794079
<tr id="673">
40804080
<td><a href="https://cplusplus.github.io/CWG/issues/673.html">673</a></td>

0 commit comments

Comments
 (0)