From patchwork Thu Jun 5 09:17:37 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Polacek X-Patchwork-Id: 356243 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 4B78A140094 for ; Thu, 5 Jun 2014 19:17:54 +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=RamnqCzF4IxmCe/V7utWQGCQLmphayThvfaubEyGdrrv3OXLaW 11cZKxZfQghGtcOU2r1BU3c212glUxJ97qk/z5q/8Iv06Qlon+ECH4ZJufDGr9K6 jRAJUC4ImcIKO5h8FjOzAA1R1v6eiws8olz0YcTgvPlDCJNGxWc+4HJc8= 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=m8WHoa8evC/7FaqyU7cRUTz4HTc=; b=GPwm6DoPQWh2OSQm1Bdb 0EcOj1BZ6IQKHX9bbcDyZNYhfiiTbckbeWtW/4UHIvZycDH410vjkNtmMVX0WDxF r/dHSVfLPhJUr8hB4TWS10Vu5M9fQFicbZ80QMWJ4/KUK5B0hDSdczOWc/usrCd3 /vRCF19Ueyrz5RcCN7G1DXM= Received: (qmail 17778 invoked by alias); 5 Jun 2014 09:17:46 -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 17764 invoked by uid 89); 5 Jun 2014 09:17:46 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.0 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; Thu, 05 Jun 2014 09:17:44 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s559Hfcm012990 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 5 Jun 2014 05:17:42 -0400 Received: from redhat.com (ovpn-116-106.ams2.redhat.com [10.36.116.106]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s559HcG2012424 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=NO); Thu, 5 Jun 2014 05:17:40 -0400 Date: Thu, 5 Jun 2014 11:17:37 +0200 From: Marek Polacek To: GCC Patches Cc: "Joseph S. Myers" Subject: [C PATCH] More locus tweaks (PR c/56724) Message-ID: <20140605091737.GA24532@redhat.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) My previous patch for 56724 didn't handle all cases of this. So let's fix this now by using expr_loc for ic_argpass. Tested x86_64-unknown-linux-gnu, applying to trunk. 2014-06-05 Marek Polacek PR c/56724 * c-typeck.c (convert_for_assignment): Use expr_loc for ic_argpass. * gcc.dg/pr56724-3.c: New test. Marek diff --git gcc/c/c-typeck.c gcc/c/c-typeck.c index e0d3fde..f09f39e 100644 --- gcc/c/c-typeck.c +++ gcc/c/c-typeck.c @@ -6025,8 +6025,9 @@ convert_for_assignment (location_t location, location_t expr_loc, tree type, where NULL is typically defined in C to be '(void *) 0'. */ if (VOID_TYPE_P (ttr) && rhs != null_pointer_node && !VOID_TYPE_P (ttl)) - warning_at (location, OPT_Wc___compat, - "request for implicit conversion " + warning_at (errtype == ic_argpass ? expr_loc : location, + OPT_Wc___compat, + "request for implicit conversion " "from %qT to %qT not permitted in C++", rhstype, type); /* See if the pointers point to incompatible address spaces. */ @@ -6038,7 +6039,7 @@ convert_for_assignment (location_t location, location_t expr_loc, tree type, switch (errtype) { case ic_argpass: - error_at (location, "passing argument %d of %qE from pointer to " + error_at (expr_loc, "passing argument %d of %qE from pointer to " "non-enclosed address space", parmnum, rname); break; case ic_assign: @@ -6067,7 +6068,7 @@ convert_for_assignment (location_t location, location_t expr_loc, tree type, switch (errtype) { case ic_argpass: - warning_at (location, OPT_Wsuggest_attribute_format, + warning_at (expr_loc, OPT_Wsuggest_attribute_format, "argument %d of %qE might be " "a candidate for a format attribute", parmnum, rname); @@ -6246,9 +6247,10 @@ convert_for_assignment (location_t location, location_t expr_loc, tree type, switch (errtype) { case ic_argpass: - error_at (location, "incompatible type for argument %d of %qE", parmnum, rname); + error_at (expr_loc, "incompatible type for argument %d of %qE", parmnum, + rname); inform ((fundecl && !DECL_IS_BUILTIN (fundecl)) - ? DECL_SOURCE_LOCATION (fundecl) : input_location, + ? DECL_SOURCE_LOCATION (fundecl) : expr_loc, "expected %qT but argument is of type %qT", type, rhstype); break; case ic_assign: @@ -6257,12 +6259,12 @@ convert_for_assignment (location_t location, location_t expr_loc, tree type, break; case ic_init: error_at (location, - "incompatible types when initializing type %qT using type %qT", + "incompatible types when initializing type %qT using type %qT", type, rhstype); break; case ic_return: error_at (location, - "incompatible types when returning type %qT but %qT was " + "incompatible types when returning type %qT but %qT was " "expected", rhstype, type); break; default: diff --git gcc/testsuite/gcc.dg/pr56724-3.c gcc/testsuite/gcc.dg/pr56724-3.c index e69de29..192d719 100644 --- gcc/testsuite/gcc.dg/pr56724-3.c +++ gcc/testsuite/gcc.dg/pr56724-3.c @@ -0,0 +1,14 @@ +/* PR c/56724 */ +/* { dg-do compile } */ +/* { dg-options "-Wc++-compat" } */ + +extern void xfer (int, int, unsigned char *); +struct T { int a; } t; + +void +call (int x, int y, void *arg) +{ + unsigned char *uc = arg; /* { dg-warning "23:request for implicit conversion" } */ + xfer (x, y, arg); /* { dg-warning "15:request for implicit conversion" } */ + xfer (x, y, t); /* { dg-error "15:incompatible type for" } */ +}