Skip to content

Commit 7da6e68

Browse files
committed
verify that alloca for constexpr local variable has const attribute
1 parent 6247c4a commit 7da6e68

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

clang/test/CIR/CodeGen/const-alloca.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// RUN: FileCheck --input-file=%t.cir %s
33

44
int produce_int();
5+
void blackbox(const int &);
56

67
void local_const_int() {
78
const int x = produce_int();
@@ -17,6 +18,15 @@ void param_const_int(const int x) {}
1718
// CHECK: %{{.+}} = cir.alloca !s32i, !cir.ptr<!s32i>, ["x", init, const]
1819
// CHECK: }
1920

21+
void local_constexpr_int() {
22+
constexpr int x = 42;
23+
blackbox(x);
24+
}
25+
26+
// CHECK-LABEL: @_Z19local_constexpr_intv
27+
// CHECK: %{{.+}} = cir.alloca !s32i, !cir.ptr<!s32i>, ["x", init, const]
28+
// CHECK: }
29+
2030
struct Foo {
2131
int a;
2232
int b;

0 commit comments

Comments
 (0)