Author: dim Date: Mon Jan 29 18:11:27 2018 New Revision: 328555 URL: https://svnweb.freebsd.org/changeset/base/328555
Log: Pull in r217197 from upstream clang trunk (by Richard Smith): PR20844: If we fail to list-initialize a reference, map to the referenced type before retrying the initialization to produce diagnostics. Otherwise, we may fail to produce any diagnostics, and silently produce invalid AST in a -Asserts build. Also add a note to this codepath to make it more clear why we were trying to create a temporary. This should fix assertions when parsing some forms of incomplete list intializers. Direct commit to stable/9 and stable/10, since stable/11 and head already have this upstream fix. Reported by: ajcbowh...@gmail.com PR: 202665 Modified: stable/10/contrib/llvm/tools/clang/include/clang/Basic/DiagnosticSemaKinds.td stable/10/contrib/llvm/tools/clang/lib/Sema/SemaInit.cpp Changes in other areas also in this revision: Modified: stable/9/contrib/llvm/tools/clang/include/clang/Basic/DiagnosticSemaKinds.td stable/9/contrib/llvm/tools/clang/lib/Sema/SemaInit.cpp Modified: stable/10/contrib/llvm/tools/clang/include/clang/Basic/DiagnosticSemaKinds.td ============================================================================== --- stable/10/contrib/llvm/tools/clang/include/clang/Basic/DiagnosticSemaKinds.td Mon Jan 29 18:07:14 2018 (r328554) +++ stable/10/contrib/llvm/tools/clang/include/clang/Basic/DiagnosticSemaKinds.td Mon Jan 29 18:11:27 2018 (r328555) @@ -1419,6 +1419,9 @@ def warn_uninit_byref_blockvar_captured_by_block : War InGroup<Uninitialized>, DefaultIgnore; def note_block_var_fixit_add_initialization : Note< "maybe you meant to use __block %0">; +def note_in_reference_temporary_list_initializer : Note< + "in initialization of temporary of type %0 created to " + "list-initialize this reference">; def note_var_fixit_add_initialization : Note< "initialize the variable %0 to silence this warning">; def note_uninit_fixit_remove_cond : Note< Modified: stable/10/contrib/llvm/tools/clang/lib/Sema/SemaInit.cpp ============================================================================== --- stable/10/contrib/llvm/tools/clang/lib/Sema/SemaInit.cpp Mon Jan 29 18:07:14 2018 (r328554) +++ stable/10/contrib/llvm/tools/clang/lib/Sema/SemaInit.cpp Mon Jan 29 18:11:27 2018 (r328555) @@ -6309,6 +6309,19 @@ static void diagnoseListInit(Sema &S, const Initialize return diagnoseListInit(S, HiddenArray, InitList); } + if (DestType->isReferenceType()) { + // A list-initialization failure for a reference means that we tried to + // create a temporary of the inner type (per [dcl.init.list]p3.6) and the + // inner initialization failed. + QualType T = DestType->getAs<ReferenceType>()->getPointeeType(); + diagnoseListInit(S, InitializedEntity::InitializeTemporary(T), InitList); + SourceLocation Loc = InitList->getLocStart(); + if (auto *D = Entity.getDecl()) + Loc = D->getLocation(); + S.Diag(Loc, diag::note_in_reference_temporary_list_initializer) << T; + return; + } + InitListChecker DiagnoseInitList(S, Entity, InitList, DestType, /*VerifyOnly=*/false); assert(DiagnoseInitList.HadError() && _______________________________________________ svn-src-stable-10@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10 To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"