Skip to content

Commit a51cf6e

Browse files
author
git apple-llvm automerger
committed
Merge commit 'cffe7cb745a1' from llvm.org/main into next
2 parents 11d3175 + cffe7cb commit a51cf6e

File tree

4 files changed

+23
-0
lines changed

4 files changed

+23
-0
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -956,6 +956,8 @@ Bug Fixes to C++ Support
956956
(#GH135281)
957957
- Fix a crash in the presence of invalid base classes. (#GH147186)
958958
- Fix a crash with NTTP when instantiating local class.
959+
- Fixed a crash involving list-initialization of an empty class with a
960+
non-empty initializer list. (#GH147949)
959961

960962
Bug Fixes to AST Handling
961963
^^^^^^^^^^^^^^^^^^^^^^^^^

clang/lib/AST/Expr.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3721,6 +3721,10 @@ bool Expr::isConstantInitializer(ASTContext &Ctx, bool IsForRef,
37213721
// an anonymous union, in declaration order.
37223722
const InitListExpr *ILE = cast<InitListExpr>(this);
37233723
assert(ILE->isSemanticForm() && "InitListExpr must be in semantic form");
3724+
3725+
if (ILE->isTransparent())
3726+
return ILE->getInit(0)->isConstantInitializer(Ctx, false, Culprit);
3727+
37243728
if (ILE->getType()->isArrayType()) {
37253729
unsigned numInits = ILE->getNumInits();
37263730
for (unsigned i = 0; i < numInits; i++) {

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -638,6 +638,15 @@ struct PR69979 {
638638
const char (&d)[9];
639639
} e {"12345678"};
640640

641+
namespace GH147949 {
642+
struct Coordinate {};
643+
Coordinate Make();
644+
void TestBody() {
645+
// CHECK: call {{.*}} @_ZN8GH1479494MakeEv
646+
const Coordinate x{Make()};
647+
}
648+
}
649+
641650
// VirtualMembers::TemplateClass::templateMethod() must be defined in this TU,
642651
// not just declared.
643652
// CHECK: define linkonce_odr void @_ZN14VirtualMembers13TemplateClassIiE14templateMethodEv(ptr {{[^,]*}} %this)

clang/test/SemaCXX/compound-literal.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,3 +129,11 @@ int f();
129129
#endif
130130
Foo o = (Foo){ {}, 1, f() };
131131
}
132+
133+
#if __cplusplus >= 201103L
134+
namespace GH147949 {
135+
// Make sure we handle transparent InitListExprs correctly.
136+
struct S { int x : 3; };
137+
const S* x = (const S[]){S{S{3}}};
138+
}
139+
#endif

0 commit comments

Comments
 (0)