From patchwork Mon Dec 10 10:23:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 1010359 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-491986-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="jS0phYlO"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=oracle.com header.i=@oracle.com header.b="wZH4kCIa"; dkim-atps=neutral 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 43Czj9327Kz9s0t for ; Mon, 10 Dec 2018 21:25:00 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to:cc :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=d8YonjuPH0Nzj1FSbPlkKAAFSjNNgmtGp4qL+vvFHQotlIxwrR RADSuX+vjQsFekJ0Q59xWwgYxwPJuogQg53dnMHNlMNZGhjVndr2Jvut7pTp/KzN Zz/wWuxXc2kExgGDRVXRbN4s+zqbZQGHQ3tcS23910SBPWljgkyg5eoyU= 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:to:cc :from:subject:message-id:date:mime-version:content-type; s= default; bh=RE6Ln3u6EMOaU5RRMFQzESGl1Iw=; b=jS0phYlOfBRkp+zAZEiG zP1CehA02iXPyLRVB/6F6CdmZs9lMIBlrGg79MVxOhwWJhI9EJ6CyG6JzyRPjIJm gqwIdxVJeApKXfVfYExIU4jZjesCuH9dSNJimMvwddkCvweqswVgB2aTPa8IPODw k8tOtQY2+ayWDP/SaQaHqAI= Received: (qmail 125163 invoked by alias); 10 Dec 2018 10:24:50 -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 124789 invoked by uid 89); 10 Dec 2018 10:24:28 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.9 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_PASS, SPF_PASS, TIME_LIMIT_EXCEEDED autolearn=unavailable version=3.3.2 spammy=H*Ad:D*oracle.com, nonstatic, sk:record_, non-static X-HELO: userp2130.oracle.com Received: from userp2130.oracle.com (HELO userp2130.oracle.com) (156.151.31.86) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 10 Dec 2018 10:24:05 +0000 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id wBAANxs5104314; Mon, 10 Dec 2018 10:24:03 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=to : cc : from : subject : message-id : date : mime-version : content-type; s=corp-2018-07-02; bh=5NMy8I3XLLoIcU/XEplL+tAD4O/730w1SeTbtWkODJY=; b=wZH4kCIaEVhZDBlc1Em4/IGHIurD7dZZ6ZcdZROyFItJMeXYrOvJMeC2vhoPIskhF+eb CiJPIjum8TH6dy0a7nwI5G6Qz7rst8xHojHbepfqfJcBN4dBVGA809icQ/lzeRMlyfdU +DOKIGCF3h8/52P86JtPZ+PwrtQuZEDhzCxslMtRitVSZknCBgGp5e/fSQJi0gq8TxWb kboqHVNKMa3JstGwe/b38UaGraiCooqrk+9HaW7bKInXPWjFc/O0EjWvbw/SXtlW7c2m b/O3CgbRcmFhYbVFLgpEWFJYn6NcMQPFgAC9PMdzh3ohbwtAuQzuIIkXXHGW6s/AxGB8 OA== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp2130.oracle.com with ESMTP id 2p85ctw372-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 10 Dec 2018 10:24:03 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id wBAANvcM029374 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 10 Dec 2018 10:23:58 GMT Received: from abhmp0013.oracle.com (abhmp0013.oracle.com [141.146.116.19]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id wBAANv77011167; Mon, 10 Dec 2018 10:23:57 GMT Received: from [192.168.1.4] (/80.181.224.14) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 10 Dec 2018 02:23:56 -0800 To: "gcc-patches@gcc.gnu.org" Cc: Jason Merrill From: Paolo Carlini Subject: [C++ Patch] Add location_t parameter to grokvardecl Message-ID: <9208064d-b9a0-66bf-416d-b89f975febb4@oracle.com> Date: Mon, 10 Dec 2018 11:23:53 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.0 MIME-Version: 1.0 X-IsSubscribed: yes Hi, the other day I noticed that we weren't getting right the first location of pr53037-4.C, for a variable, whereas the next one, for a function, was Ok. Indeed, we were passing a location only to grokfndecl. In other terms, I found a good empirical reason to move the declaration of the local loc = declarator ? declarator->id_loc : input_location further up ;) Tested x86_64-linux. Thanks, Paolo. ////////////////////// /cp 2018-12-10 Paolo Carlini * decl2.c (grokvardecl): Add location_t parameter and use it in build_lang_decl_loc and build_decl calls. (grokdeclarator): Move up loc declaration and use it in the grokvardecl call too. /testsuite 2018-12-10 Paolo Carlini * g++.dg/pr53037-4.C: Test the first two locations too. Index: cp/decl.c =================================================================== --- cp/decl.c (revision 266943) +++ cp/decl.c (working copy) @@ -68,7 +68,7 @@ static int decl_jump_unsafe (tree); static void require_complete_types_for_parms (tree); static tree grok_reference_init (tree, tree, tree, int); static tree grokvardecl (tree, tree, tree, const cp_decl_specifier_seq *, - int, int, int, bool, int, tree); + int, int, int, bool, int, tree, location_t); static void check_static_variable_definition (tree, tree); static void record_unknown_type (tree, const char *); static tree builtin_function_1 (tree, tree, bool); @@ -9282,7 +9282,8 @@ grokvardecl (tree type, int inlinep, bool conceptp, int template_count, - tree scope) + tree scope, + location_t location) { tree decl; tree explicit_scope; @@ -9318,9 +9319,9 @@ grokvardecl (tree type, /* Similarly for explicit specializations. */ || (orig_declarator && TREE_CODE (orig_declarator) == TEMPLATE_ID_EXPR))) - decl = build_lang_decl (VAR_DECL, name, type); + decl = build_lang_decl_loc (location, VAR_DECL, name, type); else - decl = build_decl (input_location, VAR_DECL, name, type); + decl = build_decl (location, VAR_DECL, name, type); if (explicit_scope && TREE_CODE (explicit_scope) == NAMESPACE_DECL) set_decl_namespace (decl, explicit_scope, 0); @@ -12200,6 +12201,7 @@ grokdeclarator (const cp_declarator *declarator, { tree decl = NULL_TREE; + location_t loc = declarator ? declarator->id_loc : input_location; if (decl_context == PARM) { @@ -12216,13 +12218,13 @@ grokdeclarator (const cp_declarator *declarator, if (!staticp && !friendp && TREE_CODE (type) != METHOD_TYPE) if (tree auto_node = type_uses_auto (type)) { - location_t loc = declspecs->locations[ds_type_spec]; + location_t tloc = declspecs->locations[ds_type_spec]; if (CLASS_PLACEHOLDER_TEMPLATE (auto_node)) - error_at (loc, "invalid use of template-name %qE without an " + error_at (tloc, "invalid use of template-name %qE without an " "argument list", CLASS_PLACEHOLDER_TEMPLATE (auto_node)); else - error_at (loc, "non-static data member declared with " + error_at (tloc, "non-static data member declared with " "placeholder %qT", auto_node); type = error_mark_node; } @@ -12487,7 +12489,6 @@ grokdeclarator (const cp_declarator *declarator, if (decl == NULL_TREE) { - location_t loc = declarator ? declarator->id_loc : input_location; if (staticp) { /* C++ allows static class members. All other work @@ -12704,7 +12705,8 @@ grokdeclarator (const cp_declarator *declarator, inlinep, concept_p, template_count, - ctype ? ctype : in_namespace); + ctype ? ctype : in_namespace, + loc); if (decl == NULL_TREE) return error_mark_node; Index: testsuite/g++.dg/pr53037-4.C =================================================================== --- testsuite/g++.dg/pr53037-4.C (revision 266943) +++ testsuite/g++.dg/pr53037-4.C (working copy) @@ -2,11 +2,11 @@ /* { dg-do compile } */ /* { dg-options "-O0" } */ -int foo1 __attribute__((warn_if_not_aligned(8))); /* { dg-error "'warn_if_not_aligned' may not be specified for 'foo1'" } */ +int foo1 __attribute__((warn_if_not_aligned(8))); /* { dg-error "5:'warn_if_not_aligned' may not be specified for 'foo1'" } */ __attribute__((warn_if_not_aligned(8))) void -foo2 (void) /* { dg-error "'warn_if_not_aligned' may not be specified for 'void foo2\\(\\)'" } */ +foo2 (void) /* { dg-error "1:'warn_if_not_aligned' may not be specified for 'void foo2\\(\\)'" } */ { }