From patchwork Wed Apr 25 14:04:11 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dodji Seketeli X-Patchwork-Id: 154932 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]) by ozlabs.org (Postfix) with SMTP id 230FFB6EE7 for ; Thu, 26 Apr 2012 00:04:36 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1335967477; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:From:To:Cc:Subject:References:Date:In-Reply-To: Message-ID:User-Agent:MIME-Version:Content-Type:Mailing-List: Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:Sender:Delivered-To; bh=/1+d6F9WiVD7stWEx6DcIAWp9Mg=; b=do5OuEBqe+q2U+zLrVTn2ZEdwkldteSdO9dMTEraLuKziB+IzB4N/vEvEZT+o1 khse+gQlXr9X3JNProsPcJcMQvlIihXKNai1OTxPvA5KXmEtmnhnkEgVQYh8JV2d AuN2bB5ExB+YujPfm+BMO1eB7axpeu+QS7YssrmTRb/QU= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Received:From:To:Cc:Subject:References:X-URL:Date:In-Reply-To:Message-ID:User-Agent:MIME-Version:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=ySmmbEaTm71ABXyGdd4CXAniXmfoeViD8xW/YzUrGiV93mfmTO7tWlaCCW7TTN 3Q6er5xupBs+yYrSH3xcNd+txTf2oAJAXzdHVN6FzZfUjAvdIJ9/6CXHNEnGOmG9 T5Cn1HiN7con2e3HNmCemnJfTL9niUTRmuU11JjOeKtdA=; Received: (qmail 11371 invoked by alias); 25 Apr 2012 14:04:34 -0000 Received: (qmail 11362 invoked by uid 22791); 25 Apr 2012 14:04:32 -0000 X-SWARE-Spam-Status: No, hits=-5.9 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_W, SPF_HELO_PASS, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 25 Apr 2012 14:04:13 +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 q3PE4DF6024808 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 25 Apr 2012 10:04:13 -0400 Received: from localhost (ovpn-116-18.ams2.redhat.com [10.36.116.18]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q3PE4CMv011658 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 25 Apr 2012 10:04:13 -0400 Received: by localhost (Postfix, from userid 500) id 7BABD29C046; Wed, 25 Apr 2012 16:04:11 +0200 (CEST) From: Dodji Seketeli To: GCC Patches Cc: Tom Tromey , Jason Merrill , Gabriel Dos Reis Subject: [PATCH 11/13] Fix va_start related location References: X-URL: http://www.redhat.com Date: Wed, 25 Apr 2012 16:04:11 +0200 In-Reply-To: (Dodji Seketeli's message of "Tue, 10 Apr 2012 16:53:12 +0200") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) MIME-Version: 1.0 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 In gcc/testsuite/gcc.dg/pr30457.c, the first warning was not being emitted because the relevant location was inside the var_start macro defined in a system header. It can even point to a token for a builtin macro there. This patch unwinds to the first token in real source code in that case. Tested on x86_64-unknown-linux-gnu against trunk. * builtins.c (fold_builtin_next_arg): Unwinds to the first location in real source code. --- gcc/builtins.c | 16 ++++++++++++++-- 1 files changed, 14 insertions(+), 2 deletions(-) diff --git a/gcc/builtins.c b/gcc/builtins.c index b47f218..ef90b25 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -12164,8 +12164,20 @@ fold_builtin_next_arg (tree exp, bool va_start_p) the default argument promotions, the behavior is undefined." */ else if (DECL_REGISTER (arg)) - warning (0, "undefined behaviour when second parameter of " - "% is declared with % storage"); + { + /* There is good chance the current input_location points + inside the definition of the va_start macro (perhaps on + the token for builtin) in a system header, so the warning + will not be emitted. Use the location in real source + code. */ + source_location current_location = + linemap_unwind_to_first_non_reserved_loc (line_table, input_location, + NULL); + warning_at (current_location, + 0, + "undefined behaviour when second parameter of " + "% is declared with % storage"); + } /* We want to verify the second parameter just once before the tree optimizers are run and then avoid keeping it in the tree,