From patchwork Mon Sep 2 14:28:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 1156651 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-508172-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="XsqpKdWE"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=oracle.com header.i=@oracle.com header.b="qEiwH0vm"; 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 46MXWV2RHrz9sDB for ; Tue, 3 Sep 2019 00:28:38 +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=L5agi/BLaqQSZEzaURCQmSGGz+hm5FK0gv7iBNGOVLov+Xcf2A aQJ3GghFsHzOk2For/b3x3Z8WZ2RQlo97/myrDvK7Wx7hV5udZmIFtq2k2tL5fCK +AqOAM7G71kDUgvzqQEAD0VmyHSISD4V5OxohqNs54ytUVRiwPSQ7E0Qg= 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=Be+RDhw0+UubxPtkKAEUQL15F10=; b=XsqpKdWEE5PE3GORR6b+ ZtVpbaGlom8Tx8mydTS1IgFTfYXo5hkuwjguuGI+N01laDayE7lBVKWyBsXxcGct PmycwmOGOOPbtolKF/pfstK1klnEKAEffzQ4rmAi5kCIA5ikPR6RJFxW+5Scumcr 3FTmw294yLle0Oo4J4aZN+I= Received: (qmail 22990 invoked by alias); 2 Sep 2019 14:28:30 -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 22981 invoked by uid 89); 2 Sep 2019 14:28:30 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-9.5 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=paolo, Paolo, ctype, grokdeclarator 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; Mon, 02 Sep 2019 14:28:27 +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 x82EOU94155486; Mon, 2 Sep 2019 14:28:25 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-2019-08-05; bh=BMDKGcBfIhvp8zH4MKJ9MDFUxlla1etoR1lkWhNB0v0=; b=qEiwH0vm3OOd5XP9eVUxrq0Ali2HME9rynM/8siuU4uNypSe7NETHuFy70rSs4fmDStW WMI/tIkjDjFe3pg5zXLFwJHmQQ1lxVdiBsHzULHNDajdwjiDB4IkslGtqVa/4EBp+wz8 +M3apV5OSNejz7XH+1kwvhuSKykS5iRpBJDvPAE79LhBvEXWbDa5jOYZcluionnYvJm2 367F1ANiaf8caeTt0Mhd9KDAmwQK+AHnVk7bufipZ9tnDcv65+TZvZ/k+WIaWos8bIH+ awo2/O2F+Qm5zoQsye9hLSc1AyR1yYMEgj96l+f20R4E3fwGsAwgGxGKrKk+VJntiug0 aw== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2120.oracle.com with ESMTP id 2us4r3r16g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 02 Sep 2019 14:28:25 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x82ESD6R115021; Mon, 2 Sep 2019 14:28:24 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3020.oracle.com with ESMTP id 2uqg837uqq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 02 Sep 2019 14:28:23 +0000 Received: from abhmp0007.oracle.com (abhmp0007.oracle.com [141.146.116.13]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x82ESIU3007114; Mon, 2 Sep 2019 14:28:18 GMT Received: from [192.168.1.4] (/79.19.31.88) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 02 Sep 2019 07:28:17 -0700 To: "gcc-patches@gcc.gnu.org" Cc: Jason Merrill From: Paolo Carlini Subject: Bunch of location improvements Message-ID: <8f2d7681-ce1f-15e9-02cf-b8fc83c6f284@oracle.com> Date: Mon, 2 Sep 2019 16:28:14 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 X-IsSubscribed: yes Hi, all should be more or less straightforward. I also propose to use an additional range for that error message about constinit && constexpr mentioned to Marek a few days ago. Tested x86_64-linux. Thanks, Paolo. ///////////////////////// /cp 2019-09-02 Paolo Carlini * decl.c (has_designator_problem): Use cp_expr_loc_or_input_loc in error_at. (build_enumerator): Likewise. (cp_finish_decl): Use DECL_SOURCE_LOCATION. (grokdeclarator): Use id_loc in two error_at; change errror message about constinit together constexpr to use two ranges. /testsuite 2019-09-02 Paolo Carlini * g++.dg/cpp0x/enum29.C: Test location(s) too. * g++.dg/cpp0x/lambda/lambda-ice10.C: Likewise. * g++.dg/cpp2a/constinit3.C: Likewise. * g++.dg/ext/desig4.C: Likewise. * g++.dg/ext/label10.C: Likewise. * g++.old-deja/g++.other/dtor3.C: Likewise. Index: cp/decl.c =================================================================== --- cp/decl.c (revision 275318) +++ cp/decl.c (working copy) @@ -6108,8 +6108,9 @@ has_designator_problem (reshape_iter *d, tsubst_fl if (d->cur->index) { if (complain & tf_error) - error ("C99 designator %qE outside aggregate initializer", - d->cur->index); + error_at (cp_expr_loc_or_input_loc (d->cur->index), + "C99 designator %qE outside aggregate initializer", + d->cur->index); else return true; } @@ -7282,8 +7283,9 @@ cp_finish_decl (tree decl, tree init, bool init_co if ((flags & LOOKUP_CONSTINIT) && !(dk == dk_thread || dk == dk_static)) { - error ("% can only be applied to a variable with static " - "or thread storage duration"); + error_at (DECL_SOURCE_LOCATION (decl), + "% can only be applied to a variable with " + "static or thread storage duration"); return; } @@ -10622,8 +10624,9 @@ grokdeclarator (const cp_declarator *declarator, && !uniquely_derived_from_p (ctype, current_class_type)) { - error ("invalid use of qualified-name %<%T::%D%>", - qualifying_scope, decl); + error_at (id_declarator->id_loc, + "invalid use of qualified-name %<%T::%D%>", + qualifying_scope, decl); return error_mark_node; } } @@ -10810,8 +10813,9 @@ grokdeclarator (const cp_declarator *declarator, keywords shall appear in a decl-specifier-seq." */ if (constinit_p && constexpr_p) { - error_at (min_location (declspecs->locations[ds_constinit], - declspecs->locations[ds_constexpr]), + gcc_rich_location richloc (declspecs->locations[ds_constinit]); + richloc.add_range (declspecs->locations[ds_constexpr]); + error_at (&richloc, "can use at most one of the % and % " "specifiers"); return error_mark_node; @@ -11815,7 +11819,8 @@ grokdeclarator (const cp_declarator *declarator, && inner_declarator->u.id.sfk == sfk_destructor && arg_types != void_list_node) { - error ("destructors may not have parameters"); + error_at (declarator->id_loc, + "destructors may not have parameters"); arg_types = void_list_node; parms = NULL_TREE; } @@ -15155,8 +15160,9 @@ build_enumerator (tree name, tree value, tree enum if (! INTEGRAL_OR_UNSCOPED_ENUMERATION_TYPE_P (TREE_TYPE (value))) { - error ("enumerator value for %qD must have integral or " - "unscoped enumeration type", name); + error_at (cp_expr_loc_or_input_loc (value), + "enumerator value for %qD must have integral or " + "unscoped enumeration type", name); value = NULL_TREE; } else Index: testsuite/g++.dg/cpp0x/enum29.C =================================================================== --- testsuite/g++.dg/cpp0x/enum29.C (revision 275318) +++ testsuite/g++.dg/cpp0x/enum29.C (working copy) @@ -38,7 +38,7 @@ enum E0 { e0 = X0() }; enum E1 { e1 = X1() }; enum E2 { e2 = X2() }; enum E3 { e3 = X3() }; -enum E4 { e4 = X4() }; // { dg-error "integral" } +enum E4 { e4 = X4() }; // { dg-error "16:enumerator value for .e4. must have integral" } enum E5 { e5 = X5() }; // { dg-error "ambiguous" } enum F0 : int { f0 = X0() }; Index: testsuite/g++.dg/cpp0x/lambda/lambda-ice10.C =================================================================== --- testsuite/g++.dg/cpp0x/lambda/lambda-ice10.C (revision 275318) +++ testsuite/g++.dg/cpp0x/lambda/lambda-ice10.C (working copy) @@ -4,5 +4,5 @@ template struct A { static const int i; - template const int A::i = []{ return 0; }(); // { dg-error "invalid use" } + template const int A::i = []{ return 0; }(); // { dg-error "29:invalid use" } }; Index: testsuite/g++.dg/cpp2a/constinit3.C =================================================================== --- testsuite/g++.dg/cpp2a/constinit3.C (revision 275318) +++ testsuite/g++.dg/cpp2a/constinit3.C (working copy) @@ -31,8 +31,8 @@ int fn1 () { // Not static storage - constinit int a1 = 42; // { dg-error ".constinit. can only be applied to a variable with static or thread storage" } - constinit int a2 = 42; // { dg-error ".constinit. can only be applied to a variable with static or thread storage" } + constinit int a1 = 42; // { dg-error "17:.constinit. can only be applied to a variable with static or thread storage" } + constinit int a2 = 42; // { dg-error "17:.constinit. can only be applied to a variable with static or thread storage" } extern constinit int e1; return 0; @@ -46,7 +46,7 @@ fn3 () void fn2 (int i, constinit int p) // { dg-error "a parameter cannot be declared .constinit." } { - constinit auto l = [i](){ return i; }; // { dg-error ".constinit. can only be applied to a variable with static or thread storage" } + constinit auto l = [i](){ return i; }; // { dg-error "18:.constinit. can only be applied to a variable with static or thread storage" } } struct B { int d; }; Index: testsuite/g++.dg/ext/desig4.C =================================================================== --- testsuite/g++.dg/ext/desig4.C (revision 275318) +++ testsuite/g++.dg/ext/desig4.C (working copy) @@ -1,18 +1,18 @@ // PR c++/51458 // { dg-options "" } -char g[] = { [7] = "abcd" }; // { dg-error "designator" } +char g[] = { [7] = "abcd" }; // { dg-error "15:designator .7." } int a = { .foo = 6 }; // { dg-error "designator" } -int b = { [0] = 1 }; // { dg-error "designator" } +int b = { [0] = 1 }; // { dg-error "12:designator .0." } _Complex float c = { .foo = 0, 1 }; // { dg-error "designator" } // { dg-error "either all initializer clauses should be designated or none of them should be" "" { target c++2a } .-1 } // { dg-error "cannot convert" "" { target *-*-* } .-2 } -_Complex float d = { [0] = 0, 1 }; // { dg-error "designator" } +_Complex float d = { [0] = 0, 1 }; // { dg-error "23:designator .0." } // { dg-error "either all initializer clauses should be designated or none of them should be" "" { target c++2a } .-1 } // { dg-error "cannot convert" "" { target *-*-* } .-2 } _Complex float e = { 0, .foo = 1 }; // { dg-error "designator" } // { dg-error "either all initializer clauses should be designated or none of them should be" "" { target c++2a } .-1 } // { dg-error "cannot convert" "" { target *-*-* } .-2 } -_Complex float f = { 0, [0] = 1 }; // { dg-error "designator" } +_Complex float f = { 0, [0] = 1 }; // { dg-error "26:designator .0." } // { dg-error "either all initializer clauses should be designated or none of them should be" "" { target c++2a } .-1 } // { dg-error "cannot convert" "" { target *-*-* } .-2 } Index: testsuite/g++.dg/ext/label10.C =================================================================== --- testsuite/g++.dg/ext/label10.C (revision 275318) +++ testsuite/g++.dg/ext/label10.C (working copy) @@ -12,6 +12,6 @@ A<0> a; void foo () { __label__ P; - enum { O = && P }; // { dg-error "cannot appear in|integral" } + enum { O = && P }; // { dg-error "14:enumerator value for .O. must have integral|cannot appear in" } P:; } Index: testsuite/g++.old-deja/g++.other/dtor3.C =================================================================== --- testsuite/g++.old-deja/g++.other/dtor3.C (revision 275318) +++ testsuite/g++.old-deja/g++.other/dtor3.C (working copy) @@ -2,7 +2,7 @@ struct S1 { - ~S1(int); // { dg-error "" } destructors may not have parameters + ~S1(int); // { dg-error "3:destructors may not have parameters" } }; @@ -9,13 +9,13 @@ struct S1 template struct S2 { - ~S2(int); // { dg-error "" } destructors may not have parameters + ~S2(int); // { dg-error "3:destructors may not have parameters" } }; struct S3 { - ~S3(double) {} // { dg-error "" } destructors may not have parameters + ~S3(double) {} // { dg-error "3:destructors may not have parameters" } }; @@ -22,7 +22,7 @@ struct S3 template struct S4 { - ~S4(double) {} // { dg-error "" } destructors may not have parameters + ~S4(double) {} // { dg-error "3:destructors may not have parameters" } };