Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -956,6 +956,8 @@ Bug Fixes to C++ Support
(#GH135281)
- Fix a crash in the presence of invalid base classes. (#GH147186)
- Fix a crash with NTTP when instantiating local class.
- Fixed a crash involving list-initialization of an empty class with a
non-empty initializer list. (#GH147949)

Bug Fixes to AST Handling
^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
4 changes: 4 additions & 0 deletions clang/lib/AST/Expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3393,6 +3393,10 @@ bool Expr::isConstantInitializer(ASTContext &Ctx, bool IsForRef,
// an anonymous union, in declaration order.
const InitListExpr *ILE = cast<InitListExpr>(this);
assert(ILE->isSemanticForm() && "InitListExpr must be in semantic form");

if (ILE->isTransparent())
return ILE->getInit(0)->isConstantInitializer(Ctx, false, Culprit);

if (ILE->getType()->isArrayType()) {
unsigned numInits = ILE->getNumInits();
for (unsigned i = 0; i < numInits; i++) {
Expand Down
9 changes: 9 additions & 0 deletions clang/test/CodeGenCXX/const-init-cxx11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,15 @@ struct PR69979 {
const char (&d)[9];
} e {"12345678"};

namespace GH147949 {
struct Coordinate {};
Coordinate Make();
void TestBody() {
// CHECK: call {{.*}} @_ZN8GH1479494MakeEv
const Coordinate x{Make()};
}
}

// VirtualMembers::TemplateClass::templateMethod() must be defined in this TU,
// not just declared.
// CHECK: define linkonce_odr void @_ZN14VirtualMembers13TemplateClassIiE14templateMethodEv(ptr {{[^,]*}} %this)
8 changes: 8 additions & 0 deletions clang/test/SemaCXX/compound-literal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,11 @@ int f();
#endif
Foo o = (Foo){ {}, 1, f() };
}

#if __cplusplus >= 201103L
namespace GH147949 {
// Make sure we handle transparent InitListExprs correctly.
struct S { int x : 3; };
const S* x = (const S[]){S{S{3}}};
}
#endif
Loading