From patchwork Fri Mar 4 18:03:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Polacek X-Patchwork-Id: 592169 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 5A536140144 for ; Sat, 5 Mar 2016 05:03:23 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=DpJXx4U4; dkim-atps=neutral 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:references:mime-version :content-type:in-reply-to; q=dns; s=default; b=J4smnGCe3t78hiUQn rgTaMFLMhHK4xoa0grssSHqqAbbtsL1RYbC+8hd0kaJHLKcW+Dpq4JkE+rskPtXz v9eyYgZCNlibAyFeQTc6WojoMn5ZJXR079KELbWMVQmmyeGalWIU5vTJ5JFpzyMW L5ST15v3Qm5dozVql8ALNxvApo= 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:references:mime-version :content-type:in-reply-to; s=default; bh=bsylHX+mTF4G/M4MrUGcYtO XfWc=; b=DpJXx4U4377ZTvpqcjeI0diSC8ppNgLd/jv8ks6jVW8IoK4u/JvPhDH ACztYif4GKnEUUoQx5+oBqwMmknS2DawFaTtGxVAYnFP6tVBinAbXxP2hOxVEtsX oJ40EEW/HJR3oHRAVCMOs8LOBm8oa6AZDYY865vylVadMfZ+d7dU= Received: (qmail 109353 invoked by alias); 4 Mar 2016 18:03:16 -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 109342 invoked by uid 89); 4 Mar 2016 18:03:15 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.9 required=5.0 tests=BAYES_00, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=no version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 04 Mar 2016 18:03:14 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id C36FA51D; Fri, 4 Mar 2016 18:03:13 +0000 (UTC) Received: from redhat.com (ovpn-204-101.brq.redhat.com [10.40.204.101]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u24I3ARO005747 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 4 Mar 2016 13:03:12 -0500 Date: Fri, 4 Mar 2016 19:03:09 +0100 From: Marek Polacek To: Jakub Jelinek Cc: GCC Patches , Joseph Myers Subject: Re: [C PATCH] Prevent -Wunused-value warning with __atomic_fetch_* (PR c/69407) Message-ID: <20160304180309.GN10006@redhat.com> References: <20160304173040.GM10006@redhat.com> <20160304174126.GG3017@tucnak.redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20160304174126.GG3017@tucnak.redhat.com> User-Agent: Mutt/1.5.24 (2015-08-30) On Fri, Mar 04, 2016 at 06:41:26PM +0100, Jakub Jelinek wrote: > I'm ok with it for gcc6. Cool. > But IMHO you should add dg-bogus directives here. Ok, version with dg-bogus: Bootstrapped/regtested on x86_64-linux, ok for trunk? 2016-03-04 Marek Polacek PR c/69407 * c-common.c (resolve_overloaded_builtin): Set TREE_USED for the fetch operations. * gcc.dg/atomic-op-6.c: New test. Marek diff --git gcc/c-family/c-common.c gcc/c-family/c-common.c index 965cf49..25afa9c 100644 --- gcc/c-family/c-common.c +++ gcc/c-family/c-common.c @@ -11443,6 +11443,10 @@ resolve_overloaded_builtin (location_t loc, tree function, && orig_code != BUILT_IN_ATOMIC_STORE_N) result = sync_resolve_return (first_param, result, orig_format); + if (fetch_op) + /* Prevent -Wunused-value warning. */ + TREE_USED (result) = true; + /* If new_return is set, assign function to that expr and cast the result to void since the generic interface returned void. */ if (new_return) diff --git gcc/testsuite/gcc.dg/atomic-op-6.c gcc/testsuite/gcc.dg/atomic-op-6.c index e69de29..f88c293 100644 --- gcc/testsuite/gcc.dg/atomic-op-6.c +++ gcc/testsuite/gcc.dg/atomic-op-6.c @@ -0,0 +1,11 @@ +/* Test we don't generate bogus warnings. */ +/* PR c/69407 */ +/* { dg-do compile } */ +/* { dg-options "-Wall -Wextra" } */ + +void +foo (int *p, int a) +{ + __atomic_fetch_add (&p, a, 0); /* { dg-bogus "value computed is not used" } */ + __atomic_add_fetch (&p, a, 0); /* { dg-bogus "value computed is not used" } */ +}