Skip to content

Commit 150de85

Browse files
author
git apple-llvm automerger
committed
Merge commit '582f0469dae1' from llvm.org/release/17.x into stable/20230725
2 parents ea3a029 + 582f046 commit 150de85

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

clang/lib/CodeGen/CGExprConstant.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1765,9 +1765,10 @@ llvm::Constant *ConstantEmitter::tryEmitPrivate(const Expr *E,
17651765
QualType destType) {
17661766
assert(!destType->isVoidType() && "can't emit a void constant");
17671767

1768-
if (llvm::Constant *C =
1769-
ConstExprEmitter(*this).Visit(const_cast<Expr *>(E), destType))
1770-
return C;
1768+
if (!destType->isReferenceType())
1769+
if (llvm::Constant *C =
1770+
ConstExprEmitter(*this).Visit(const_cast<Expr *>(E), destType))
1771+
return C;
17711772

17721773
Expr::EvalResult Result;
17731774

clang/test/CodeGenCXX/const-init-cxx11.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,8 @@ namespace DR2126 {
424424
// CHECK: @_ZN33ClassTemplateWithStaticDataMember3useE ={{.*}} constant ptr @_ZGRN33ClassTemplateWithStaticDataMember1SIvE1aE_
425425
// CHECK: @_ZGRN39ClassTemplateWithHiddenStaticDataMember1SIvE1aE_ = linkonce_odr hidden constant i32 5, comdat
426426
// CHECK: @_ZN39ClassTemplateWithHiddenStaticDataMember3useE ={{.*}} constant ptr @_ZGRN39ClassTemplateWithHiddenStaticDataMember1SIvE1aE_
427+
// CHECK: @.str.[[STR:[0-9]+]] ={{.*}} constant [9 x i8] c"12345678\00"
428+
// CHECK-NEXT: @e = global %struct.PR69979 { ptr @.str.[[STR]] }
427429
// CHECK: @_ZGRZN20InlineStaticConstRef3funEvE1i_ = linkonce_odr constant i32 10, comdat
428430
// CHECK20: @_ZZN12LocalVarInit4dtorEvE1a = internal constant {{.*}} i32 103
429431

@@ -632,6 +634,10 @@ struct X {
632634
const char *f() { return &X::p; }
633635
}
634636

637+
struct PR69979 {
638+
const char (&d)[9];
639+
} e {"12345678"};
640+
635641
// VirtualMembers::TemplateClass::templateMethod() must be defined in this TU,
636642
// not just declared.
637643
// CHECK: define linkonce_odr void @_ZN14VirtualMembers13TemplateClassIiE14templateMethodEv(ptr {{[^,]*}} %this)

0 commit comments

Comments
 (0)