Index: clang/include/clang/Basic/DiagnosticSemaKinds.td =================================================================== --- clang/include/clang/Basic/DiagnosticSemaKinds.td +++ clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -2214,6 +2214,9 @@ "reference %0 is not yet bound to a value when used within its own" " initialization">, InGroup; +def warn_uninit_fixed_size_array : Warning< + "fixed-size array contains uninitialized elements">, + DefaultIgnore; def warn_uninit_var : Warning< "variable %0 is uninitialized when %select{used here|captured by block}1">, InGroup, DefaultIgnore; Index: clang/lib/Sema/SemaInit.cpp =================================================================== --- clang/lib/Sema/SemaInit.cpp +++ clang/lib/Sema/SemaInit.cpp @@ -980,6 +980,22 @@ if (RequiresSecondPass && !hadError) FillInEmptyInitializations(Entity, FullyStructuredList, RequiresSecondPass, nullptr, 0); + + if (const ConstantArrayType *CAType = dyn_cast(T)) { + if (FullyStructuredList->getNumInits() < CAType->getSize().getZExtValue()) { + S.Diag(IL->getBeginLoc(), diag::warn_uninit_fixed_size_array) + << IL->getSourceRange(); + } else { + Expr **inits = FullyStructuredList->getInits(); + for (unsigned i = 0, e = FullyStructuredList->getNumInits(); i != e; ++i) { + if (inits[i] == nullptr) { + S.Diag(IL->getBeginLoc(), diag::warn_uninit_fixed_size_array) + << IL->getSourceRange(); + break; + } + } + } + } } if (hadError && FullyStructuredList) FullyStructuredList->markError();