From patchwork Wed Dec 10 19:24:34 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 419827 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 861DD1400D5 for ; Thu, 11 Dec 2014 06:24:54 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:content-type; q=dns; s=default; b=teJHNJcfciSmtyp6V76glIGYos8QN9xryB1LjhbumfX vfx3w332+5ucFgfY6y0mrSkrbLdgoD99WACyGt4A/OYCsC5H95b02qEux4T6FDHg K3O4uX0jvnl6/Yu7WfA9c0cOlTyN+s4mIlLQRtugn6TXxSaRHupYNrcupfZWheFQ = 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 :message-id:date:from:mime-version:to:cc:subject:content-type; s=default; bh=wRkgat0McW1kZhzOgXeP1OkoEdY=; b=VAkLKDfGKb6fJv1xc SzvH6UxeFgi4F2YYIDic1cHHQoS9tt6irXP4StSQbb3sFwnXZrtpCXO5TFdNWpj3 c5/a2zpEoQAQf8fHkz4qkVoZwrDAMfLBb4nYAfT8ek6AGmsJ9RpJ30+GIoDQ1s0J NiSJbi8PbBTm6i1U/NYp7GB/+k= Received: (qmail 23144 invoked by alias); 10 Dec 2014 19:24:47 -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 23134 invoked by uid 89); 10 Dec 2014 19:24:46 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.2 required=5.0 tests=AWL, BAYES_00, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: userp1040.oracle.com Received: from userp1040.oracle.com (HELO userp1040.oracle.com) (156.151.31.81) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Wed, 10 Dec 2014 19:24:45 +0000 Received: from ucsinet22.oracle.com (ucsinet22.oracle.com [156.151.31.94]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id sBAJOgf3025691 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 10 Dec 2014 19:24:42 GMT Received: from userz7022.oracle.com (userz7022.oracle.com [156.151.31.86]) by ucsinet22.oracle.com (8.14.5+Sun/8.14.5) with ESMTP id sBAJOf40022080 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 10 Dec 2014 19:24:41 GMT Received: from abhmp0011.oracle.com (abhmp0011.oracle.com [141.146.116.17]) by userz7022.oracle.com (8.14.5+Sun/8.14.4) with ESMTP id sBAJOego022030; Wed, 10 Dec 2014 19:24:41 GMT Received: from [192.168.1.4] (/79.27.111.67) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 10 Dec 2014 11:24:40 -0800 Message-ID: <54889DF2.7060704@oracle.com> Date: Wed, 10 Dec 2014 20:24:34 +0100 From: Paolo Carlini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: "gcc-patches@gcc.gnu.org" CC: Jason Merrill Subject: [C++ Patch] PR 60955 X-IsSubscribed: yes Hi, this regression, a spurious warning about taking the address of a register parameter, happens in C++14 mode due to the use of force_paren_expr, called by finish_parenthesized_expr, which ends up calling build_static_cast. Manuel mentioned in the audit trail that TREE_NO_WARNING can be used for DECLs too, and indeed I noticed today that we are *already* using it for EXPRs, at the beginning of finish_parenthesized_expr. I experimented a bit with restricting the setting, eg, to PARM_DECLs only, but in fact we have an identical issue for, eg, register VAR_DECLs. Tested x86_64-linux. Thanks, Paolo. //////////////////////////// /cp 2014-12-10 Paolo Carlini PR c++/60955 * semantics.c (finish_parenthesized_expr): Set TREE_NO_WARNING on non-EXPRs too. * typeck.c (cxx_mark_addressable): Check TREE_NO_WARNING. /testsuite 2014-12-10 Paolo Carlini PR c++/60955 * g++.dg/warn/register-parm-1.C: New. Index: cp/semantics.c =================================================================== --- cp/semantics.c (revision 218586) +++ cp/semantics.c (working copy) @@ -1674,10 +1674,13 @@ force_paren_expr (tree expr) tree finish_parenthesized_expr (tree expr) { - if (EXPR_P (expr)) - /* This inhibits warnings in c_common_truthvalue_conversion. */ - TREE_NO_WARNING (expr) = 1; + if (expr == error_mark_node) + return error_mark_node; + /* Inhibit warnings in c_common_truthvalue_conversion and in + cxx_mark_addressable. */ + TREE_NO_WARNING (expr) = 1; + if (TREE_CODE (expr) == OFFSET_REF || TREE_CODE (expr) == SCOPE_REF) /* [expr.unary.op]/3 The qualified id of a pointer-to-member must not be Index: cp/typeck.c =================================================================== --- cp/typeck.c (revision 218586) +++ cp/typeck.c (working copy) @@ -6068,7 +6068,8 @@ cxx_mark_addressable (tree exp) ("address of explicit register variable %qD requested", x); return false; } - else if (extra_warnings) + else if (extra_warnings + && !TREE_NO_WARNING (x)) warning (OPT_Wextra, "address requested for %qD, which is declared %", x); } Index: testsuite/g++.dg/warn/register-parm-1.C =================================================================== --- testsuite/g++.dg/warn/register-parm-1.C (revision 0) +++ testsuite/g++.dg/warn/register-parm-1.C (working copy) @@ -0,0 +1,9 @@ +// PR c++/60955 +// { dg-options "-Wextra" } + +unsigned int erroneous_warning(register int a) { + if ((a) & 0xff) return 1; else return 0; +} +unsigned int no_erroneous_warning(register int a) { + if (a & 0xff) return 1; else return 0; +}