@@ -13774,17 +13774,22 @@ void Sema::AddInitializerToDecl(Decl *RealDecl, Expr *Init, bool DirectInit) {
13774
13774
}
13775
13775
13776
13776
// Perform the initialization.
13777
- ParenListExpr *CXXDirectInit = dyn_cast<ParenListExpr>(Init) ;
13777
+ bool InitializedFromParenListExpr = false ;
13778
13778
bool IsParenListInit = false;
13779
13779
if (!VDecl->isInvalidDecl()) {
13780
13780
InitializedEntity Entity = InitializedEntity::InitializeVariable(VDecl);
13781
13781
InitializationKind Kind = InitializationKind::CreateForInit(
13782
13782
VDecl->getLocation(), DirectInit, Init);
13783
13783
13784
13784
MultiExprArg Args = Init;
13785
- if (CXXDirectInit)
13786
- Args = MultiExprArg(CXXDirectInit->getExprs(),
13787
- CXXDirectInit->getNumExprs());
13785
+ if (auto *CXXDirectInit = dyn_cast<ParenListExpr>(Init)) {
13786
+ Args =
13787
+ MultiExprArg(CXXDirectInit->getExprs(), CXXDirectInit->getNumExprs());
13788
+ InitializedFromParenListExpr = true;
13789
+ } else if (auto *CXXDirectInit = dyn_cast<CXXParenListInitExpr>(Init)) {
13790
+ Args = CXXDirectInit->getInitExprs();
13791
+ InitializedFromParenListExpr = true;
13792
+ }
13788
13793
13789
13794
// Try to correct any TypoExprs in the initialization arguments.
13790
13795
for (size_t Idx = 0; Idx < Args.size(); ++Idx) {
@@ -14082,10 +14087,9 @@ void Sema::AddInitializerToDecl(Decl *RealDecl, Expr *Init, bool DirectInit) {
14082
14087
// special case code.
14083
14088
14084
14089
// C++ 8.5p11:
14085
- // The form of initialization (using parentheses or '=') is generally
14086
- // insignificant, but does matter when the entity being initialized has a
14087
- // class type.
14088
- if (CXXDirectInit) {
14090
+ // The form of initialization (using parentheses or '=') matters
14091
+ // when the entity being initialized has class type.
14092
+ if (InitializedFromParenListExpr) {
14089
14093
assert(DirectInit && "Call-style initializer must be direct init.");
14090
14094
VDecl->setInitStyle(IsParenListInit ? VarDecl::ParenListInit
14091
14095
: VarDecl::CallInit);
0 commit comments