@@ -5880,6 +5880,12 @@ static void TryOrBuildParenListInitialization(
58805880 } else {
58815881 // We've processed all of the args, but there are still members that
58825882 // have to be initialized.
5883+ if (!VerifyOnly && FD->hasAttr <ExplicitInitAttr>()) {
5884+ S.Diag (Kind.getLocation (), diag::warn_field_requires_explicit_init)
5885+ << /* Var-in-Record */ 0 << FD;
5886+ S.Diag (FD->getLocation (), diag::note_entity_declared_at) << FD;
5887+ }
5888+
58835889 if (FD->hasInClassInitializer ()) {
58845890 if (!VerifyOnly) {
58855891 // C++ [dcl.init]p16.6.2.2
@@ -7351,6 +7357,22 @@ PerformConstructorInitialization(Sema &S,
73517357 if (S.DiagnoseUseOfDecl (Step.Function .FoundDecl , Loc))
73527358 return ExprError ();
73537359
7360+ if (Kind.getKind () == InitializationKind::IK_Value &&
7361+ Constructor->isImplicit ()) {
7362+ auto *RD = Step.Type .getCanonicalType ()->getAsCXXRecordDecl ();
7363+ if (RD && RD->isAggregate () && RD->hasUninitializedExplicitInitFields ()) {
7364+ unsigned I = 0 ;
7365+ for (const FieldDecl *FD : RD->fields ()) {
7366+ if (I >= ConstructorArgs.size () && FD->hasAttr <ExplicitInitAttr>()) {
7367+ S.Diag (Loc, diag::warn_field_requires_explicit_init)
7368+ << /* Var-in-Record */ 0 << FD;
7369+ S.Diag (FD->getLocation (), diag::note_entity_declared_at) << FD;
7370+ }
7371+ ++I;
7372+ }
7373+ }
7374+ }
7375+
73547376 TypeSourceInfo *TSInfo = Entity.getTypeSourceInfo ();
73557377 if (!TSInfo)
73567378 TSInfo = S.Context .getTrivialTypeSourceInfo (Entity.getType (), Loc);
0 commit comments