From owner-svn-src-stable-10@freebsd.org Mon Jan 29 18:11:28 2018 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 46CC9ED58D2; Mon, 29 Jan 2018 18:11:28 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id EBFC27EB09; Mon, 29 Jan 2018 18:11:27 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E6E263C7D; Mon, 29 Jan 2018 18:11:27 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w0TIBRnN095948; Mon, 29 Jan 2018 18:11:27 GMT (envelope-from dim@FreeBSD.org) Received: (from dim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w0TIBRdX095946; Mon, 29 Jan 2018 18:11:27 GMT (envelope-from dim@FreeBSD.org) Message-Id: <201801291811.w0TIBRdX095946@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dim set sender to dim@FreeBSD.org using -f From: Dimitry Andric Date: Mon, 29 Jan 2018 18:11:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r328555 - in stable: 10/contrib/llvm/tools/clang/include/clang/Basic 10/contrib/llvm/tools/clang/lib/Sema 9/contrib/llvm/tools/clang/include/clang/Basic 9/contrib/llvm/tools/clang/lib/Sema X-SVN-Group: stable-10 X-SVN-Commit-Author: dim X-SVN-Commit-Paths: in stable: 10/contrib/llvm/tools/clang/include/clang/Basic 10/contrib/llvm/tools/clang/lib/Sema 9/contrib/llvm/tools/clang/include/clang/Basic 9/contrib/llvm/tools/clang/lib/Sema X-SVN-Commit-Revision: 328555 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 29 Jan 2018 18:11:28 -0000 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: ajcbowhill@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, 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()->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() &&