From patchwork Tue Apr 29 21:19:57 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Polacek X-Patchwork-Id: 344001 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 CB2E5140094 for ; Wed, 30 Apr 2014 07:34:28 +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:mime-version:content-type; q=dns; s=default; b=Zzf1yk6QxzfQ9IItFA6kR1i2j6aeAgFpS23tNTRQuFRbISgJjA TrEiC0ZLTnf0aVOHo43FCSwrNHLLUGLSLeH3U53zYpRfS/YP6XDTwi17nM6lq8UH +l6hFApoEbfUEbgE4/wHp0xgV+n+sSJGgqVhB8r+kQ8NULQwiuGUQ3zg0= 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:mime-version:content-type; s= default; bh=XQ+VwgRt2Ayre0r/VjynHpHfthE=; b=IO/OFwvlMksWdADozQvy j9uFrfjazau1tCPmZPD4ItSuDr/BqVwqpXHKVSuFk0tSqrUz5mLr4RCo0jM2j163 sF7pmS0xzEdLp3R431lWVjLfeTyPXSPeQ3HTOts3jt0vk2ni6niWFFOKQf4Cpaiy cylpTUPHL1oUBRFTX2so9WQ= Received: (qmail 20786 invoked by alias); 29 Apr 2014 21:34:20 -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 20774 invoked by uid 89); 29 Apr 2014 21:34:20 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.1 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 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 ESMTP; Tue, 29 Apr 2014 21:34:19 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s3TLK152031814 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 29 Apr 2014 17:20:01 -0400 Received: from redhat.com (ovpn-116-53.ams2.redhat.com [10.36.116.53]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id s3TLJv3V014311 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO); Tue, 29 Apr 2014 17:20:00 -0400 Date: Tue, 29 Apr 2014 23:19:57 +0200 From: Marek Polacek To: GCC Patches Cc: "Joseph S. Myers" Subject: [C PATCH] Another column info tweak (PR c/56989) Message-ID: <20140429211957.GE11802@redhat.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) At least for function calls we can use their location info to generate better diagnostics. Regtested/bootstrapped on x86_64-linux, ok for trunk? 2014-04-29 Marek Polacek PR c/56989 * c-typeck.c (default_conversion): Use better location for error call. * gcc.dg/pr56989.c: New test. Marek diff --git gcc/c/c-typeck.c gcc/c/c-typeck.c index 62c72df..0eee40a 100644 --- gcc/c/c-typeck.c +++ gcc/c/c-typeck.c @@ -2107,7 +2107,8 @@ default_conversion (tree exp) if (code == VOID_TYPE) { - error ("void value not ignored as it ought to be"); + error_at (EXPR_LOC_OR_LOC (exp, input_location), + "void value not ignored as it ought to be"); return error_mark_node; } diff --git gcc/testsuite/gcc.dg/pr56989.c gcc/testsuite/gcc.dg/pr56989.c index e69de29..beb9806 100644 --- gcc/testsuite/gcc.dg/pr56989.c +++ gcc/testsuite/gcc.dg/pr56989.c @@ -0,0 +1,19 @@ +/* PR c/56989 */ +/* { dg-do compile } */ + +extern void voidf (void); +extern int intf (void); + +int +f (void) +{ + if (intf () < 0 + || voidf () < 0) /* { dg-error "10:void value not ignored as it ought to be" } */ + return 1; + + if (voidf () < 0 /* { dg-error "7:void value not ignored as it ought to be" } */ + || intf () < 0) + return 1; + + return 0; +}