From owner-svn-src-projects@freebsd.org Sun Aug 28 19:28:02 2016 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4BEDFBC59A3 for ; Sun, 28 Aug 2016 19:28:02 +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 mx1.freebsd.org (Postfix) with ESMTPS id 0364766B; Sun, 28 Aug 2016 19:28:01 +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 u7SJS1Hq023989; Sun, 28 Aug 2016 19:28:01 GMT (envelope-from dim@FreeBSD.org) Received: (from dim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u7SJS1dV023988; Sun, 28 Aug 2016 19:28:01 GMT (envelope-from dim@FreeBSD.org) Message-Id: <201608281928.u7SJS1dV023988@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dim set sender to dim@FreeBSD.org using -f From: Dimitry Andric Date: Sun, 28 Aug 2016 19:28:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r304960 - projects/clang390-import/contrib/llvm/tools/clang/lib/Sema X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 28 Aug 2016 19:28:02 -0000 Author: dim Date: Sun Aug 28 19:28:00 2016 New Revision: 304960 URL: https://svnweb.freebsd.org/changeset/base/304960 Log: Tentatively apply https://reviews.llvm.org/D23921, to get rid of false positive diagnostics from -Wvarargs about enum parameters, e.g.: cddl/contrib/opensolaris/lib/libnvpair/libnvpair.c:388:15: error: passing an object that undergoes default argument promotion to 'va_start' has undefined behavior [-Werror,-Wvarargs] va_start(ap, which); ^ cddl/contrib/opensolaris/lib/libnvpair/libnvpair.c:382:66: note: parameter of type 'enum nvlist_prtctl_fmt' is declared here nvlist_prtctl_dofmt(nvlist_prtctl_t pctl, enum nvlist_prtctl_fmt which, ...) ^ Modified: projects/clang390-import/contrib/llvm/tools/clang/lib/Sema/SemaChecking.cpp Modified: projects/clang390-import/contrib/llvm/tools/clang/lib/Sema/SemaChecking.cpp ============================================================================== --- projects/clang390-import/contrib/llvm/tools/clang/lib/Sema/SemaChecking.cpp Sun Aug 28 18:10:29 2016 (r304959) +++ projects/clang390-import/contrib/llvm/tools/clang/lib/Sema/SemaChecking.cpp Sun Aug 28 19:28:00 2016 (r304960) @@ -3189,8 +3189,17 @@ bool Sema::SemaBuiltinVAStartImpl(CallEx Diag(TheCall->getArg(1)->getLocStart(), diag::warn_second_arg_of_va_start_not_last_named_param); else if (IsCRegister || Type->isReferenceType() || - Type->isPromotableIntegerType() || - Type->isSpecificBuiltinType(BuiltinType::Float)) { + Type->isSpecificBuiltinType(BuiltinType::Float) || [=] { + // Promotable integers are UB, but enumerations need a bit of + // extra checking to see what their promotable type actually is. + if (!Type->isPromotableIntegerType()) + return false; + if (!Type->isEnumeralType()) + return true; + const EnumDecl *ED = Type->getAs()->getDecl(); + return !(ED && + Context.typesAreCompatible(ED->getPromotionType(), Type)); + }()) { unsigned Reason = 0; if (Type->isReferenceType()) Reason = 1; else if (IsCRegister) Reason = 2;