From patchwork Fri Jun 14 00:12:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 1115680 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-502942-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="it+5sSlj"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=oracle.com header.i=@oracle.com header.b="gIfZtG0f"; 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 45Q1K34p3vz9s6w for ; Fri, 14 Jun 2019 10:12:49 +1000 (AEST) 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=cqblvQASzfUPADW34NBeQw20UoJk5HTWPZ/vEoRckpxIJj6Tzc Rs9PdkGOLafXT/DGNGmoKV8zKANeB65fHrvJIbYJ8MvIBENFFPtj7EKMImXYOuiP hvAMGQrwaiOHmn1VZh6NCYjilllASRGiEO7X09Ek+2/3aus7CmHntxXvo= 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=/NVuO5SVhHCVGCC6Sa9v+NfZyfk=; b=it+5sSljjtXHJsQ+BbNt hi5eCbpP1X24JnsHY39ZbnLZCbBUlNXxj982DWUX450o/c6AHhWB6zT2MiEaWiX6 bmn2mV3B+XAMp4vgk20kh9/t9yfoClZ2hDJJAOafEWetVcL01vcBVUrlP0CnITBK jG+hB/zWLE4WCIJi8gQCc7o= Received: (qmail 45217 invoked by alias); 14 Jun 2019 00:12:41 -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 45202 invoked by uid 89); 14 Jun 2019 00:12:40 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-9.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, SPF_HELO_PASS autolearn=ham version=3.3.1 spammy=spent, __asm, pedwarn X-HELO: aserp2120.oracle.com Received: from aserp2120.oracle.com (HELO aserp2120.oracle.com) (141.146.126.78) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 14 Jun 2019 00:12:38 +0000 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x5E09SdP165640; Fri, 14 Jun 2019 00:12:35 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=v0aD78aLv5TNbJ8AYwLxgUTxMyeHXTzCMHf9blVNWU0=; b=gIfZtG0fWCjY3cAbS1P1SRLYac4pTWzwp+dxjEPhJ6fb64rDKH/VA31VsQ/g2Xt9bu26 mqzjhAhlTi0pi2mKMstHD+nBZEcKdKTjrFIEM8EzQ3z29/L7TZhC7r1KSAlIuMHunoMn FYBmQtsE33/FQk6qfcWBQbzPD+vfuHXhsVFV/K70yhF1oQFqtrt5NUnU6GRj05592/U0 8XjbR46gZ0dn/qsZYL5G+nMIyGit1HwH49Fcwauw/Dc2T6X7XwDjoupiS2I3VfWMuru8 ySr8Mqma+xH+bsAcB6MErvA5hHR8aG2QB8gInaFU+dA8IdTTrkwoAn+aDTPAy5EHmaKD CQ== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2120.oracle.com with ESMTP id 2t04ynvg4p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Jun 2019 00:12:34 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x5E0CY7D099574; Fri, 14 Jun 2019 00:12:34 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3030.oracle.com with ESMTP id 2t04j0rwu8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Jun 2019 00:12:34 +0000 Received: from abhmp0004.oracle.com (abhmp0004.oracle.com [141.146.116.10]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x5E0CSOT021535; Fri, 14 Jun 2019 00:12:28 GMT Received: from [192.168.1.4] (/79.42.221.26) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 13 Jun 2019 17:12:27 -0700 To: "gcc-patches@gcc.gnu.org" Cc: Jason Merrill From: Paolo Carlini Subject: [C++ Patch] More grokdeclarator locations Message-ID: <1a9da66c-76a4-1bc1-6f18-5052736b3711@oracle.com> Date: Fri, 14 Jun 2019 02:12:16 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 X-IsSubscribed: yes Hi, should all be rather straightforward but I spent quite a bit of time on the testsuite changes... Tested x86_64-linux, as usual. Thanks, Paolo. PS: at some point we should start talking about all the error, error_at, etc, which are *never* exercised by our testsuite. I'm coming to the conclusion that some should really go. Any general procedural suggestions? /////////////////// /cp 2019-06-14 Paolo Carlini * decl.c (grokdeclarator): Use id_loc, typespec_loc, and locations[ds_storage_class] in a few additional places. /testsuite 2019-06-14 Paolo Carlini * g++.dg/diagnostic/auto-storage-1.C: New. * g++.dg/diagnostic/no-type-1.C: Likewise. * g++.dg/diagnostic/no-type-2.C: Likewise. * g++.dg/diagnostic/top-level-auto-1.C: Likewise. * g++.dg/cpp0x/auto9.C: Test some locations too. * g++.dg/cpp1z/register1.C: Likewise. * g++.dg/cpp1z/register2.C: Likewise. * g++.dg/cpp1z/register3.C: Likewise. * g++.dg/other/error34.C: Likewise. Index: cp/decl.c =================================================================== --- cp/decl.c (revision 272259) +++ cp/decl.c (working copy) @@ -10797,13 +10797,14 @@ grokdeclarator (const cp_declarator *declarator, else if (in_system_header_at (input_location) || flag_ms_extensions) /* Allow it, sigh. */; else if (! is_main) - permerror (input_location, "ISO C++ forbids declaration of %qs with no type", name); + permerror (id_loc, "ISO C++ forbids declaration of %qs with no type", + name); else if (pedantic) - pedwarn (input_location, OPT_Wpedantic, + pedwarn (id_loc, OPT_Wpedantic, "ISO C++ forbids declaration of %qs with no type", name); else - warning (OPT_Wreturn_type, - "ISO C++ forbids declaration of %qs with no type", name); + warning_at (id_loc, OPT_Wreturn_type, + "ISO C++ forbids declaration of %qs with no type", name); if (type_was_error_mark_node && template_parm_flag) /* FIXME we should be able to propagate the error_mark_node as is @@ -11232,7 +11233,8 @@ grokdeclarator (const cp_declarator *declarator, else if (toplevel_bindings_p ()) { if (storage_class == sc_auto) - error ("top-level declaration of %qs specifies %", name); + error_at (declspecs->locations[ds_storage_class], + "top-level declaration of %qs specifies %", name); } else if (thread_p && storage_class != sc_extern @@ -12323,9 +12325,10 @@ grokdeclarator (const cp_declarator *declarator, && !(cxx_dialect >= cxx17 && template_parm_flag)) { if (cxx_dialect >= cxx14) - error ("% parameter not permitted in this context"); + error_at (typespec_loc, + "% parameter not permitted in this context"); else - error ("parameter declared %"); + error_at (typespec_loc, "parameter declared %"); type = error_mark_node; } @@ -12746,9 +12749,12 @@ grokdeclarator (const cp_declarator *declarator, // FIXME:gcc_assert (original_name == dname); if (storage_class == sc_auto) - error ("storage class % invalid for function %qs", name); + error_at (declspecs->locations[ds_storage_class], + "storage class % invalid for function %qs", name); else if (storage_class == sc_register) - error ("storage class % invalid for function %qs", name); + error_at (declspecs->locations[ds_storage_class], + "storage class % invalid for function %qs", + name); else if (thread_p) { if (declspecs->gnu_thread_keyword_p) Index: testsuite/g++.dg/cpp0x/auto9.C =================================================================== --- testsuite/g++.dg/cpp0x/auto9.C (revision 272259) +++ testsuite/g++.dg/cpp0x/auto9.C (working copy) @@ -78,10 +78,10 @@ enum struct D : auto * { FF = 0 }; // { dg-error void bar () { - try { } catch (auto i) { } // { dg-error "parameter" } - try { } catch (auto) { } // { dg-error "parameter" } - try { } catch (auto *i) { } // { dg-error "parameter" } - try { } catch (auto *) { } // { dg-error "parameter" } + try { } catch (auto i) { } // { dg-error "18:parameter" } + try { } catch (auto) { } // { dg-error "18:parameter" } + try { } catch (auto *i) { } // { dg-error "18:parameter" } + try { } catch (auto *) { } // { dg-error "18:parameter" } } void @@ -111,7 +111,7 @@ badthrow2 () throw (auto &) // { dg-error "inval { // { dg-error "dynamic exception specification" "" { target c++17 } .-1 } } // { dg-warning "deprecated" "" { target { ! c++17 } } .-2 } -template struct G {}; // { dg-error "auto" "" { target { ! c++17 } } } +template struct G {}; // { dg-error "11:parameter" "" { target { ! c++17 } } } template struct H { H (); ~H (); }; H h; // { dg-error "invalid|initializer" } Index: testsuite/g++.dg/cpp1z/register1.C =================================================================== --- testsuite/g++.dg/cpp1z/register1.C (revision 272259) +++ testsuite/g++.dg/cpp1z/register1.C (working copy) @@ -10,7 +10,7 @@ register int a __asm (REG1); // { dg-bogus "ISO C\\+\\+17 does not allow 'register' storage class specifier" "" { target c++17 } } #endif register int b; // { dg-error "ISO C\\+\\+17 does not allow 'register' storage class specifier" "" { target c++17 } } -register int c (); // { dg-error "storage class 'register' invalid for function" } +register int c (); // { dg-error "1:storage class 'register' invalid for function" } int foo (register int d) // { dg-error "ISO C\\+\\+17 does not allow 'register' storage class specifier" "" { target c++17 } } { return d; Index: testsuite/g++.dg/cpp1z/register2.C =================================================================== --- testsuite/g++.dg/cpp1z/register2.C (revision 272259) +++ testsuite/g++.dg/cpp1z/register2.C (working copy) @@ -11,7 +11,7 @@ register int a __asm (REG1); // { dg-bogus "ISO C\\+\\+17 does not allow 'register' storage class specifier" "" { target c++17 } } #endif register int b; // { dg-bogus "ISO C\\+\\+17 does not allow 'register' storage class specifier" "" { target c++17 } } -register int c (); // { dg-error "storage class 'register' invalid for function" } +register int c (); // { dg-error "1:storage class 'register' invalid for function" } int foo (register int d) // { dg-bogus "ISO C\\+\\+17 does not allow 'register' storage class specifier" "" { target c++17 } } { return d; Index: testsuite/g++.dg/cpp1z/register3.C =================================================================== --- testsuite/g++.dg/cpp1z/register3.C (revision 272259) +++ testsuite/g++.dg/cpp1z/register3.C (working copy) @@ -11,7 +11,7 @@ register int a __asm (REG1); // { dg-bogus "'register' storage class specifier used" } #endif register int b; // { dg-warning "'register' storage class specifier used" } -register int c (); // { dg-error "storage class 'register' invalid for function" } +register int c (); // { dg-error "1:storage class 'register' invalid for function" } int foo (register int d) // { dg-warning "'register' storage class specifier used" } { return d; Index: testsuite/g++.dg/diagnostic/auto-storage-1.C =================================================================== --- testsuite/g++.dg/diagnostic/auto-storage-1.C (nonexistent) +++ testsuite/g++.dg/diagnostic/auto-storage-1.C (working copy) @@ -0,0 +1,6 @@ +// { dg-do compile { target c++98_only } } + +void foo() +{ + auto void bar(); // { dg-error "3:storage class .auto. invalid for function" } +} Index: testsuite/g++.dg/diagnostic/no-type-1.C =================================================================== --- testsuite/g++.dg/diagnostic/no-type-1.C (nonexistent) +++ testsuite/g++.dg/diagnostic/no-type-1.C (working copy) @@ -0,0 +1 @@ +main() {} // { dg-error "1:ISO C\\+\\+ forbids declaration" } Index: testsuite/g++.dg/diagnostic/no-type-2.C =================================================================== --- testsuite/g++.dg/diagnostic/no-type-2.C (nonexistent) +++ testsuite/g++.dg/diagnostic/no-type-2.C (working copy) @@ -0,0 +1,3 @@ +// { dg-options "-w" } + +foo() {} // { dg-error "1:ISO C\\+\\+ forbids declaration" } Index: testsuite/g++.dg/diagnostic/top-level-auto-1.C =================================================================== --- testsuite/g++.dg/diagnostic/top-level-auto-1.C (nonexistent) +++ testsuite/g++.dg/diagnostic/top-level-auto-1.C (working copy) @@ -0,0 +1,3 @@ +// { dg-do compile { target c++98_only } } + +auto int i; // { dg-error "1:top-level declaration of .i. specifies .auto." } Index: testsuite/g++.dg/other/error34.C =================================================================== --- testsuite/g++.dg/other/error34.C (revision 272259) +++ testsuite/g++.dg/other/error34.C (working copy) @@ -2,5 +2,5 @@ // { dg-do compile } // { dg-options "" } -S () : str(__PRETTY_FUNCTION__) { return S(); } // { dg-error "forbids declaration" "decl" } +S () : str(__PRETTY_FUNCTION__) { return S(); } // { dg-error "1:ISO C\\+\\+ forbids declaration" "decl" } // { dg-error "only constructors" "constructor" { target *-*-* } .-1 }