@@ -13774,17 +13774,22 @@ void Sema::AddInitializerToDecl(Decl *RealDecl, Expr *Init, bool DirectInit) {
1377413774 }
1377513775
1377613776 // Perform the initialization.
13777- ParenListExpr *CXXDirectInit = dyn_cast<ParenListExpr>(Init) ;
13777+ bool InitializedFromParenListExpr = false ;
1377813778 bool IsParenListInit = false;
1377913779 if (!VDecl->isInvalidDecl()) {
1378013780 InitializedEntity Entity = InitializedEntity::InitializeVariable(VDecl);
1378113781 InitializationKind Kind = InitializationKind::CreateForInit(
1378213782 VDecl->getLocation(), DirectInit, Init);
1378313783
1378413784 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+ }
1378813793
1378913794 // Try to correct any TypoExprs in the initialization arguments.
1379013795 for (size_t Idx = 0; Idx < Args.size(); ++Idx) {
@@ -14082,10 +14087,9 @@ void Sema::AddInitializerToDecl(Decl *RealDecl, Expr *Init, bool DirectInit) {
1408214087 // special case code.
1408314088
1408414089 // 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) {
1408914093 assert(DirectInit && "Call-style initializer must be direct init.");
1409014094 VDecl->setInitStyle(IsParenListInit ? VarDecl::ParenListInit
1409114095 : VarDecl::CallInit);
0 commit comments