Skip to content

Commit 6ca1c58

Browse files
committed
add new test cases
1 parent bb08584 commit 6ca1c58

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// FIXME: These test cases currently crash during codegen, despite initializers
2+
// for CLEs being constant.
3+
// RUN: not --crash %clang_cc1 -verify -std=c++20 -emit-llvm %s
4+
// expected-no-diagnostics
5+
namespace case1 {
6+
struct RR { int&& r; };
7+
struct Z { RR* x; };
8+
constinit Z z = { (RR[1]){1} };
9+
}
10+
11+
12+
namespace case2 {
13+
struct RR { int r; };
14+
struct Z { int x; const RR* y; int z; };
15+
inline int f() { return 0; }
16+
Z z2 = { 10, (const RR[1]){__builtin_constant_p(z2.x)}, z2.y->r+f() };
17+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Test that we can successfully compile this code, especially under ASAN.
2+
// RUN: %clang_cc1 -emit-llvm -std=c++20 %s -o- | FileCheck %s
3+
struct RR { int r; };
4+
struct Z { int x; const RR* y; int z; };
5+
constinit Z z = { 10, (const RR[1]){__builtin_constant_p(z.x)}, z.y->r };
6+
// Check that we zero-initialize z.y->r.
7+
// CHECK: @.compoundliteral = internal constant [1 x %struct.RR] zeroinitializer
8+
// FIXME: Despite of z.y->r being 0, we evaluate z.z to 1.
9+
// CHECK: @z = global %struct.Z { i32 10, ptr @.compoundliteral, i32 1 }

0 commit comments

Comments
 (0)