From patchwork Tue May 7 20:43:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 1096557 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-500274-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="tsvz+keI"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44zBQW4Hwhz9s4Y for ; Wed, 8 May 2019 06:43:31 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version :content-transfer-encoding; q=dns; s=default; b=oFXEiImDzBKeMMqC 5u7iRkQwSVG+996hDXjD1++DFBTiutJQVV5VkAWierElSPS0PCh31UNarCGW36LC FGi76HW21YGDQDmB/5uvu3yLaZ0UjZ0srRnK2Z5AIxu0giHMMpSmjX4DSoe9Zy47 ff79VmO/ThFac1lJwmZKQgrqQ7g= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version :content-transfer-encoding; s=default; bh=5t+fM0gV/Jxq+01KGMH3Ce OZ4Rk=; b=tsvz+keICMvVm7pM2+scFp+aac/zRK2rOVszbw8bL/lLOKo4VRqYid T9W4PAQT00pgYLRnH4nWI/yFZ8kVyN/B8vc20xuSlGasWe2VRgv9z0pYOBZMlwgN L+tG34LRVhcJU7Y2VLKT7lobAxLQz9u+msbZhawIjVC9EuQ4mmvd0= Received: (qmail 83550 invoked by alias); 7 May 2019 20:43:24 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 83541 invoked by uid 89); 7 May 2019 20:43:24 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-19.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy=HX-Languages-Length:1781, HContent-Transfer-Encoding:8bit X-HELO: mail-qt1-f175.google.com Received: from mail-qt1-f175.google.com (HELO mail-qt1-f175.google.com) (209.85.160.175) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 07 May 2019 20:43:22 +0000 Received: by mail-qt1-f175.google.com with SMTP id j6so20740094qtq.1 for ; Tue, 07 May 2019 13:43:22 -0700 (PDT) Received: from orpheus.redhat.com (209-6-216-142.s141.c3-0.smr-cbr1.sbo-smr.ma.cable.rcncustomer.com. [209.6.216.142]) by smtp.gmail.com with ESMTPSA id 50sm9815769qtq.7.2019.05.07.13.43.20 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 07 May 2019 13:43:20 -0700 (PDT) From: Jason Merrill To: gcc-patches@gcc.gnu.org Subject: [C++ PATCH] PR c++/86485 - -Wmaybe-unused with empty class ?: Date: Tue, 7 May 2019 16:43:18 -0400 Message-Id: <20190507204318.15031-1-jason@redhat.com> MIME-Version: 1.0 X-IsSubscribed: yes * typeck.c (build_static_cast_1): Use cp_build_addr_expr. For GCC 9 I fixed this bug with a patch to gimplify_cond_expr, but this function was also doing the wrong thing. Using build_address does not push the ADDR_EXPR down into the arms of a COND_EXPR, which we need for proper handling of conversion of an lvalue ?: to another reference type. --- gcc/cp/typeck.c | 5 +++-- gcc/cp/ChangeLog | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) base-commit: 1f51079362f27895c9c4e125549f6cc1b4d50568 prerequisite-patch-id: f9e234ae0c68beb8fed9e212e3da578a940c2995 diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index c107a321949..f039a3b3eb0 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -5916,7 +5916,8 @@ condition_conversion (tree expr) } /* Returns the address of T. This function will fold away - ADDR_EXPR of INDIRECT_REF. */ + ADDR_EXPR of INDIRECT_REF. This is only for low-level usage; + most places should use cp_build_addr_expr instead. */ tree build_address (tree t) @@ -7114,7 +7115,7 @@ build_static_cast_1 (tree type, tree expr, bool c_cast_p, base = lookup_base (TREE_TYPE (type), intype, c_cast_p ? ba_unique : ba_check, NULL, complain); - expr = build_address (expr); + expr = cp_build_addr_expr (expr, complain); if (sanitize_flags_p (SANITIZE_VPTR)) { diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index bd0914b8ffa..d90cc099767 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2019-05-07 Jason Merrill + PR c++/86485 - -Wmaybe-unused with empty class ?: + * typeck.c (build_static_cast_1): Use cp_build_addr_expr. + * pt.c (type_dependent_expression_p): A non-type template parm with a placeholder type is type-dependent.