From patchwork Wed May 1 11:04:50 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 240763 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 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id ACA112C00C4 for ; Wed, 1 May 2013 21:05:03 +1000 (EST) 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=hBOmALL3Fmyv6+wjw65mG/qUrVZLO2RDYW/aivL0glY e73ufEtDR2xItb4ovAkutibDhwCm3DXxY03gMQcJUJK8GutjdBfQKtGmIKwffd9R zakJMt+DsHy8E9UEN6Otv31aVtggp4LFowpME6UNNcbAiLwOYLSP065PrFfLCRKg = 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=RlFmDGy6QfFeSucM37H6d2JOUuM=; b=MewtA4pVyVLJ/cMQe IerLMRzbq1Ly+LsGslh/WqktXBUiG27T38nmbYmiqZhLv1ZUiM5h9rmjDNaqalFs XLTeBjHCqiPQcH0K7g09/JIHudVcxjYTXGonSgyVKOFQyGV9Dvebd3WR2gVEuTzq KQPcjsvL8E4YnkA7OESuq1GUNc= Received: (qmail 6581 invoked by alias); 1 May 2013 11:04:57 -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 6570 invoked by uid 89); 1 May 2013 11:04:57 -0000 X-Spam-SWARE-Status: No, score=-6.6 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_MED, RCVD_IN_HOSTKARMA_NO, RCVD_IN_HOSTKARMA_YE, RP_MATCHES_RCVD, SPF_PASS, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from userp1040.oracle.com (HELO userp1040.oracle.com) (156.151.31.81) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Wed, 01 May 2013 11:04:56 +0000 Received: from acsinet21.oracle.com (acsinet21.oracle.com [141.146.126.237]) by userp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id r41B4rZm022930 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 1 May 2013 11:04:54 GMT Received: from userz7022.oracle.com (userz7022.oracle.com [156.151.31.86]) by acsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r41B4qCU028510 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Wed, 1 May 2013 11:04:53 GMT Received: from abhmt108.oracle.com (abhmt108.oracle.com [141.146.116.60]) by userz7022.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r41B4qhN000940; Wed, 1 May 2013 11:04:52 GMT Received: from poldo4.casa (/79.33.221.138) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 01 May 2013 04:04:52 -0700 Message-ID: <5180F6D2.5020406@oracle.com> Date: Wed, 01 May 2013 13:04:50 +0200 From: Paolo Carlini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130329 Thunderbird/17.0.5 MIME-Version: 1.0 To: "gcc-patches@gcc.gnu.org" CC: Jason Merrill Subject: [C++ Patch] PR 57132 X-Virus-Found: No Hi, in tsubst_copy_and_build, particularly so after c++/11856, we are already wrapping the evaluation of most expressions in ++c_inhibit_evaluation_warnings/--c_inhibit_evaluation_warnings, but we are failing to do so in case MODOP_EXPR. Tested x86_64-linux. Ok for mainline? Thanks, Paolo. /////////////////////////// /cp 2013-05-01 Paolo Carlini PR c++/57132 * pt.c (tsubst_copy_and_build, MODOP_EXPR): Increase / decrease c_inhibit_evaluation_warnings around build_x_modify_expr call. /testsuite 2013-05-01 Paolo Carlini PR c++/57132 * g++.dg/warn/Wdiv-by-zero-bogus-2.C: New. Index: cp/pt.c =================================================================== --- cp/pt.c (revision 198488) +++ cp/pt.c (working copy) @@ -13810,7 +13810,11 @@ tsubst_copy_and_build (tree t, case MODOP_EXPR: { - tree r = build_x_modify_expr + tree r; + + ++c_inhibit_evaluation_warnings; + + r = build_x_modify_expr (EXPR_LOCATION (t), RECUR (TREE_OPERAND (t, 0)), TREE_CODE (TREE_OPERAND (t, 1)), @@ -13824,6 +13828,9 @@ tsubst_copy_and_build (tree t, here. */ if (TREE_NO_WARNING (t)) TREE_NO_WARNING (r) = TREE_NO_WARNING (t); + + --c_inhibit_evaluation_warnings; + RETURN (r); } Index: testsuite/g++.dg/warn/Wdiv-by-zero-bogus-2.C =================================================================== --- testsuite/g++.dg/warn/Wdiv-by-zero-bogus-2.C (revision 0) +++ testsuite/g++.dg/warn/Wdiv-by-zero-bogus-2.C (working copy) @@ -0,0 +1,18 @@ +// PR c++/57132 + +template +struct mod +{ + static unsigned calc(unsigned x) { + unsigned res = a * x; + if (m) + res %= m; + return res; + } +}; + +int main() +{ + mod<3,2>::calc(7); + mod<0,2>::calc(7); +}