mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-26 00:16:05 +00:00
[clang] Add some CodeGen tests for CWG 2xx issues (#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).
This commit is contained in:
parent
e892f323ea
commit
346e7c7f68
42
clang/test/CXX/drs/dr201.cpp
Normal file
42
clang/test/CXX/drs/dr201.cpp
Normal file
@ -0,0 +1,42 @@
|
||||
// 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
|
||||
// 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
|
||||
// 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
|
||||
// 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
|
||||
// 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
|
||||
// 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
|
||||
// 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
|
||||
|
||||
#if __cplusplus == 199711L
|
||||
#define NOTHROW throw()
|
||||
#else
|
||||
#define NOTHROW noexcept(true)
|
||||
#endif
|
||||
|
||||
namespace dr201 { // dr201: 2.8
|
||||
|
||||
extern void full_expr_fence() NOTHROW;
|
||||
|
||||
struct A {
|
||||
~A() NOTHROW {}
|
||||
};
|
||||
|
||||
struct B {
|
||||
B(A) NOTHROW {}
|
||||
~B() NOTHROW {}
|
||||
};
|
||||
|
||||
void foo() {
|
||||
full_expr_fence();
|
||||
B b = A();
|
||||
full_expr_fence();
|
||||
}
|
||||
|
||||
// CHECK-LABEL: define {{.*}} void @dr201::foo()
|
||||
// CHECK: call void @dr201::full_expr_fence()
|
||||
// CHECK: call void @dr201::B::B(dr201::A)
|
||||
// CHECK: call void @dr201::A::~A()
|
||||
// CHECK: call void @dr201::full_expr_fence()
|
||||
// CHECK: call void @dr201::B::~B()
|
||||
// CHECK-LABEL: }
|
||||
|
||||
} // namespace dr201
|
41
clang/test/CXX/drs/dr210.cpp
Normal file
41
clang/test/CXX/drs/dr210.cpp
Normal file
@ -0,0 +1,41 @@
|
||||
// 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
|
||||
// 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
|
||||
// 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
|
||||
// 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
|
||||
// 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
|
||||
// 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
|
||||
// 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
|
||||
|
||||
#if __cplusplus == 199711L
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wvariadic-macros"
|
||||
#define static_assert(...) __extension__ _Static_assert(__VA_ARGS__)
|
||||
#pragma clang diagnostic pop
|
||||
#endif
|
||||
|
||||
namespace dr210 { // dr210: 2.7
|
||||
struct B {
|
||||
long i;
|
||||
B();
|
||||
virtual ~B();
|
||||
};
|
||||
|
||||
static_assert(sizeof(B) == 16, "");
|
||||
|
||||
struct D : B {
|
||||
long j;
|
||||
D();
|
||||
};
|
||||
|
||||
static_assert(sizeof(D) == 24, "");
|
||||
|
||||
void toss(const B* b) {
|
||||
throw *b;
|
||||
}
|
||||
|
||||
// CHECK-LABEL: define {{.*}} void @dr210::toss(dr210::B const*)
|
||||
// CHECK: %[[EXCEPTION:.*]] = call ptr @__cxa_allocate_exception(i64 16)
|
||||
// CHECK: call void @__cxa_throw(ptr %[[EXCEPTION]], ptr @typeinfo for dr210::B, ptr @dr210::B::~B())
|
||||
// CHECK-LABEL: }
|
||||
|
||||
} // namespace dr210
|
30
clang/test/CXX/drs/dr292.cpp
Normal file
30
clang/test/CXX/drs/dr292.cpp
Normal file
@ -0,0 +1,30 @@
|
||||
// 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
|
||||
// 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
|
||||
// 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
|
||||
// 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
|
||||
// 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
|
||||
// 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
|
||||
// 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
|
||||
|
||||
namespace dr292 { // dr292: 2.9
|
||||
|
||||
extern int g();
|
||||
|
||||
struct A {
|
||||
A(int) throw() {}
|
||||
};
|
||||
|
||||
void f() {
|
||||
new A(g());
|
||||
}
|
||||
|
||||
// CHECK-LABEL: define {{.*}} void @dr292::f()()
|
||||
// CHECK: %[[CALL:.+]] = call {{.*}} @operator new(unsigned long)({{.*}})
|
||||
// CHECK: invoke {{.*}} i32 @dr292::g()()
|
||||
// CHECK-NEXT: to {{.*}} unwind label %lpad
|
||||
// CHECK-LABEL: lpad:
|
||||
// CHECK: call void @operator delete(void*)(ptr {{.*}} %[[CALL]])
|
||||
// CHECK-LABEL: eh.resume:
|
||||
// CHECK-LABEL: }
|
||||
|
||||
} // namespace dr292
|
@ -26,7 +26,7 @@ namespace dr200 { // dr200: dup 214
|
||||
}
|
||||
}
|
||||
|
||||
// dr201 FIXME: write codegen test
|
||||
// dr201 is in dr201.cpp
|
||||
|
||||
namespace dr202 { // dr202: 3.1
|
||||
template<typename T> T f();
|
||||
@ -76,7 +76,7 @@ namespace dr209 { // dr209: 3.2
|
||||
};
|
||||
}
|
||||
|
||||
// dr210 FIXME: write codegen test
|
||||
// dr210 is in dr210.cpp
|
||||
|
||||
namespace dr211 { // dr211: yes
|
||||
struct A {
|
||||
@ -1188,7 +1188,7 @@ namespace dr289 { // dr289: yes
|
||||
|
||||
// dr290: na
|
||||
// dr291: dup 391
|
||||
// dr292 FIXME: write a codegen test
|
||||
// dr292 is in dr292.cpp
|
||||
|
||||
namespace dr294 { // dr294: no
|
||||
void f() throw(int);
|
||||
|
@ -1244,7 +1244,7 @@
|
||||
<td><a href="https://cplusplus.github.io/CWG/issues/201.html">201</a></td>
|
||||
<td>CD1</td>
|
||||
<td>Order of destruction of temporaries in initializers</td>
|
||||
<td class="unknown" align="center">Unknown</td>
|
||||
<td class="full" align="center">Clang 2.8</td>
|
||||
</tr>
|
||||
<tr id="202">
|
||||
<td><a href="https://cplusplus.github.io/CWG/issues/202.html">202</a></td>
|
||||
@ -1299,7 +1299,7 @@ accessible?</td>
|
||||
<td><a href="https://cplusplus.github.io/CWG/issues/210.html">210</a></td>
|
||||
<td>TC1</td>
|
||||
<td>What is the type matched by an exception handler?</td>
|
||||
<td class="unknown" align="center">Unknown</td>
|
||||
<td class="full" align="center">Clang 2.7</td>
|
||||
</tr>
|
||||
<tr id="211">
|
||||
<td><a href="https://cplusplus.github.io/CWG/issues/211.html">211</a></td>
|
||||
@ -1792,7 +1792,7 @@ of class templates</td>
|
||||
<td><a href="https://cplusplus.github.io/CWG/issues/292.html">292</a></td>
|
||||
<td>CD3</td>
|
||||
<td>Deallocation on exception in <TT>new</TT> before arguments evaluated</td>
|
||||
<td class="unknown" align="center">Unknown</td>
|
||||
<td class="full" align="center">Clang 2.9</td>
|
||||
</tr>
|
||||
<tr class="open" id="293">
|
||||
<td><a href="https://cplusplus.github.io/CWG/issues/293.html">293</a></td>
|
||||
|
Loading…
x
Reference in New Issue
Block a user