Skip to content

Commit 346e7c7

Browse files
authored
[clang] Add some CodeGen tests for CWG 2xx issues (llvm#80823)
This patch covers CWG issues [201](https://cplusplus.github.io/CWG/issues/201.html), [210](https://cplusplus.github.io/CWG/issues/210.html), [292](https://cplusplus.github.io/CWG/issues/292.html). [CWG208](https://cplusplus.github.io/CWG/issues/208.html) is not covered, as it actually requires a libcxxabi test. Resolution of CWG292 has been superseded by [P0145R3](https://wg21.link/p0145r3) "Refining Expression Evaluation Order for Idiomatic C++" (see changes to paragraph 5.3.4/18).
1 parent e892f32 commit 346e7c7

File tree

5 files changed

+119
-6
lines changed

5 files changed

+119
-6
lines changed

clang/test/CXX/drs/dr201.cpp

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// RUN: %clang_cc1 -std=c++98 %s -triple x86_64-linux-gnu -emit-llvm -disable-llvm-passes -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 -disable-llvm-passes -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 -disable-llvm-passes -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 -disable-llvm-passes -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 -disable-llvm-passes -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 -disable-llvm-passes -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 -disable-llvm-passes -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 dr201 { // dr201: 2.8
16+
17+
extern void full_expr_fence() NOTHROW;
18+
19+
struct A {
20+
~A() NOTHROW {}
21+
};
22+
23+
struct B {
24+
B(A) NOTHROW {}
25+
~B() NOTHROW {}
26+
};
27+
28+
void foo() {
29+
full_expr_fence();
30+
B b = A();
31+
full_expr_fence();
32+
}
33+
34+
// CHECK-LABEL: define {{.*}} void @dr201::foo()
35+
// CHECK: call void @dr201::full_expr_fence()
36+
// CHECK: call void @dr201::B::B(dr201::A)
37+
// CHECK: call void @dr201::A::~A()
38+
// CHECK: call void @dr201::full_expr_fence()
39+
// CHECK: call void @dr201::B::~B()
40+
// CHECK-LABEL: }
41+
42+
} // namespace dr201

clang/test/CXX/drs/dr210.cpp

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// RUN: %clang_cc1 -std=c++98 %s -triple x86_64-linux-gnu -emit-llvm -disable-llvm-passes -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 -disable-llvm-passes -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 -disable-llvm-passes -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 -disable-llvm-passes -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 -disable-llvm-passes -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 -disable-llvm-passes -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 -disable-llvm-passes -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
8+
9+
#if __cplusplus == 199711L
10+
#pragma clang diagnostic push
11+
#pragma clang diagnostic ignored "-Wvariadic-macros"
12+
#define static_assert(...) __extension__ _Static_assert(__VA_ARGS__)
13+
#pragma clang diagnostic pop
14+
#endif
15+
16+
namespace dr210 { // dr210: 2.7
17+
struct B {
18+
long i;
19+
B();
20+
virtual ~B();
21+
};
22+
23+
static_assert(sizeof(B) == 16, "");
24+
25+
struct D : B {
26+
long j;
27+
D();
28+
};
29+
30+
static_assert(sizeof(D) == 24, "");
31+
32+
void toss(const B* b) {
33+
throw *b;
34+
}
35+
36+
// CHECK-LABEL: define {{.*}} void @dr210::toss(dr210::B const*)
37+
// CHECK: %[[EXCEPTION:.*]] = call ptr @__cxa_allocate_exception(i64 16)
38+
// CHECK: call void @__cxa_throw(ptr %[[EXCEPTION]], ptr @typeinfo for dr210::B, ptr @dr210::B::~B())
39+
// CHECK-LABEL: }
40+
41+
} // namespace dr210

clang/test/CXX/drs/dr292.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// RUN: %clang_cc1 -std=c++98 %s -triple x86_64-linux-gnu -emit-llvm -disable-llvm-passes -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 -disable-llvm-passes -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 -disable-llvm-passes -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 -disable-llvm-passes -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 -disable-llvm-passes -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 -disable-llvm-passes -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 -disable-llvm-passes -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
8+
9+
namespace dr292 { // dr292: 2.9
10+
11+
extern int g();
12+
13+
struct A {
14+
A(int) throw() {}
15+
};
16+
17+
void f() {
18+
new A(g());
19+
}
20+
21+
// CHECK-LABEL: define {{.*}} void @dr292::f()()
22+
// CHECK: %[[CALL:.+]] = call {{.*}} @operator new(unsigned long)({{.*}})
23+
// CHECK: invoke {{.*}} i32 @dr292::g()()
24+
// CHECK-NEXT: to {{.*}} unwind label %lpad
25+
// CHECK-LABEL: lpad:
26+
// CHECK: call void @operator delete(void*)(ptr {{.*}} %[[CALL]])
27+
// CHECK-LABEL: eh.resume:
28+
// CHECK-LABEL: }
29+
30+
} // namespace dr292

clang/test/CXX/drs/dr2xx.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ namespace dr200 { // dr200: dup 214
2626
}
2727
}
2828

29-
// dr201 FIXME: write codegen test
29+
// dr201 is in dr201.cpp
3030

3131
namespace dr202 { // dr202: 3.1
3232
template<typename T> T f();
@@ -76,7 +76,7 @@ namespace dr209 { // dr209: 3.2
7676
};
7777
}
7878

79-
// dr210 FIXME: write codegen test
79+
// dr210 is in dr210.cpp
8080

8181
namespace dr211 { // dr211: yes
8282
struct A {
@@ -1188,7 +1188,7 @@ namespace dr289 { // dr289: yes
11881188

11891189
// dr290: na
11901190
// dr291: dup 391
1191-
// dr292 FIXME: write a codegen test
1191+
// dr292 is in dr292.cpp
11921192

11931193
namespace dr294 { // dr294: no
11941194
void f() throw(int);

clang/www/cxx_dr_status.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1244,7 +1244,7 @@ <h2 id="cxxdr">C++ defect report implementation status</h2>
12441244
<td><a href="https://cplusplus.github.io/CWG/issues/201.html">201</a></td>
12451245
<td>CD1</td>
12461246
<td>Order of destruction of temporaries in initializers</td>
1247-
<td class="unknown" align="center">Unknown</td>
1247+
<td class="full" align="center">Clang 2.8</td>
12481248
</tr>
12491249
<tr id="202">
12501250
<td><a href="https://cplusplus.github.io/CWG/issues/202.html">202</a></td>
@@ -1299,7 +1299,7 @@ <h2 id="cxxdr">C++ defect report implementation status</h2>
12991299
<td><a href="https://cplusplus.github.io/CWG/issues/210.html">210</a></td>
13001300
<td>TC1</td>
13011301
<td>What is the type matched by an exception handler?</td>
1302-
<td class="unknown" align="center">Unknown</td>
1302+
<td class="full" align="center">Clang 2.7</td>
13031303
</tr>
13041304
<tr id="211">
13051305
<td><a href="https://cplusplus.github.io/CWG/issues/211.html">211</a></td>
@@ -1792,7 +1792,7 @@ <h2 id="cxxdr">C++ defect report implementation status</h2>
17921792
<td><a href="https://cplusplus.github.io/CWG/issues/292.html">292</a></td>
17931793
<td>CD3</td>
17941794
<td>Deallocation on exception in <TT>new</TT> before arguments evaluated</td>
1795-
<td class="unknown" align="center">Unknown</td>
1795+
<td class="full" align="center">Clang 2.9</td>
17961796
</tr>
17971797
<tr class="open" id="293">
17981798
<td><a href="https://cplusplus.github.io/CWG/issues/293.html">293</a></td>

0 commit comments

Comments
 (0)