From patchwork Tue May 14 18:50:05 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 243800 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 D343F2C00A8 for ; Wed, 15 May 2013 04:50:23 +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:date :from:to:cc:subject:message-id:reply-to:mime-version :content-type; q=dns; s=default; b=a+PPqCWZe6BuRaIdTE/uxOpjqpt5X t8zFDkfYFZqxRay/aKO2RTsuXSYGuPslxhvtGV/235ONDSThyeszgImLR6TSLfL+ 1XuCYqEtjLVioMzwGZGq/Rx8NF7GZS34DMbS7LufR7DAs8W3Rhej7Pk2aPz3odZ1 sHkePZ/PHlPNxo= 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:date :from:to:cc:subject:message-id:reply-to:mime-version :content-type; s=default; bh=6/MF0bgcoeb9S7Uysvxuq12o/io=; b=r9g lkYHDs6UOcpzcjXVBNhREcYYxD7FbQ63/csCw2DPLMfOXCmHK8+xZGyuaellTpUy vJwFflj2bdMqZhfX9H/hF/ED8prEcOB98mVUIr4o8TPrCTxCM2L59TXyedx2zQNx G7TT/9+3H6HEqX+fwS1cHXVwX0kaBjMjXphcRVR8= Received: (qmail 13262 invoked by alias); 14 May 2013 18:50:17 -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 13250 invoked by uid 89); 14 May 2013 18:50:17 -0000 X-Spam-SWARE-Status: No, score=-6.7 required=5.0 tests=AWL, BAYES_00, RCVD_IN_HOSTKARMA_W, RCVD_IN_HOSTKARMA_WL, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.1 Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Tue, 14 May 2013 18:50:16 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r4EIoEkg007662 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 14 May 2013 14:50:15 -0400 Received: from zalov.cz (vpn-60-24.rdu2.redhat.com [10.10.60.24]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r4EIo9WS004825 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 14 May 2013 14:50:12 -0400 Received: from zalov.cz (localhost [127.0.0.1]) by zalov.cz (8.14.5/8.14.5) with ESMTP id r4EIo8N2001835; Tue, 14 May 2013 20:50:09 +0200 Received: (from jakub@localhost) by zalov.cz (8.14.5/8.14.5/Submit) id r4EIo7q5001834; Tue, 14 May 2013 20:50:07 +0200 Date: Tue, 14 May 2013 20:50:05 +0200 From: Jakub Jelinek To: Jason Merrill Cc: gcc-patches@gcc.gnu.org Subject: [C++ PATCH] Fix -Wsequence-point with SIZEOF_EXPR (PR c++/57274) Message-ID: <20130514185005.GT1377@tucnak.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Hi! Another regression caused by the delayed SIZEOF_EXPR evaluation. For the purposes of -Wsequence-point warnings we should never recurse into SIZEOF_EXPR operand, the expressions in there aren't evaluated there. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk/4.8? 2013-05-14 Jakub Jelinek PR c++/57274 * c-common.c (verify_tree): Don't recurse into SIZEOF_EXPR. * c-c++-common/Wsequence-point-1.c: New test. Jakub --- gcc/c-family/c-common.c.jj 2013-05-13 09:44:53.000000000 +0200 +++ gcc/c-family/c-common.c 2013-05-14 17:04:59.273912576 +0200 @@ -3032,6 +3032,7 @@ verify_tree (tree x, struct tlist **pbef switch (code) { case CONSTRUCTOR: + case SIZEOF_EXPR: return; case COMPOUND_EXPR: --- gcc/testsuite/c-c++-common/Wsequence-point-1.c.jj 2013-05-14 17:02:55.588608130 +0200 +++ gcc/testsuite/c-c++-common/Wsequence-point-1.c 2013-05-14 17:01:06.000000000 +0200 @@ -0,0 +1,17 @@ +/* PR c++/57274 */ +/* { dg-do compile } */ +/* { dg-options "-Wsequence-point" } */ + +void foo (int, int); + +void +bar (int *x) +{ + foo (*x++, sizeof (*x)); /* { dg-bogus "may be undefined" } */ +} + +void +baz (int *x) +{ + foo (*x, sizeof (*x++) + sizeof (*x++)); /* { dg-bogus "may be undefined" } */ +}