Skip to content

Commit cd0f5b2

Browse files
authored
[clang] Add test for CWG392 (llvm#87744)
[CWG392](https://cplusplus.github.io/CWG/issues/392.html) "Use of full expression lvalue before temporary destruction". We're testing that `operator bool()` is called before destructor of `C`. I'm also marking CWG388 as requiring libc++abi test instead of codegen test, as we need to test matching between exception object and exception handlers.
1 parent 813f68c commit cd0f5b2

File tree

3 files changed

+43
-3
lines changed

3 files changed

+43
-3
lines changed

clang/test/CXX/drs/dr392.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 -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 dr392 { // dr392: 2.8
16+
17+
struct A {
18+
operator bool() NOTHROW;
19+
};
20+
21+
class C {
22+
public:
23+
C() NOTHROW;
24+
~C() NOTHROW;
25+
A& get() NOTHROW { return p; }
26+
private:
27+
A p;
28+
};
29+
30+
void f()
31+
{
32+
if (C().get()) {}
33+
}
34+
35+
} // namespace dr392
36+
37+
// CHECK-LABEL: define {{.*}} void @dr392::f()()
38+
// CHECK: call {{.*}} i1 @dr392::A::operator bool()
39+
// CHECK: call void @dr392::C::~C()
40+
// CHECK-LABEL: }

clang/test/CXX/drs/dr3xx.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1401,7 +1401,7 @@ namespace dr387 { // dr387: 2.8
14011401
}
14021402
}
14031403

1404-
// FIXME: dr388 needs codegen test
1404+
// FIXME: dr388 needs libc++abi test
14051405

14061406
namespace dr389 { // dr389: no
14071407
struct S {
@@ -1567,7 +1567,7 @@ namespace dr391 { // dr391: 2.8 c++11
15671567
const C<int> &c = fc();
15681568
}
15691569

1570-
// dr392 FIXME write codegen test
1570+
// dr392 is in dr392.cpp
15711571
// dr394: na
15721572

15731573
namespace dr395 { // dr395: 3.0

clang/www/cxx_dr_status.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2392,7 +2392,7 @@ <h2 id="cxxdr">C++ defect report implementation status</h2>
23922392
<td><a href="https://cplusplus.github.io/CWG/issues/392.html">392</a></td>
23932393
<td>CD1</td>
23942394
<td>Use of full expression lvalue before temporary destruction</td>
2395-
<td class="unknown" align="center">Unknown</td>
2395+
<td class="full" align="center">Clang 2.8</td>
23962396
</tr>
23972397
<tr id="393">
23982398
<td><a href="https://cplusplus.github.io/CWG/issues/393.html">393</a></td>

0 commit comments

Comments
 (0)