From patchwork Thu Sep 12 14:41:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 1161652 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-508965-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="uI6/uwOl"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=oracle.com header.i=@oracle.com header.b="qTEWPhvA"; 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 46ThLf3vhnz9sCJ for ; Fri, 13 Sep 2019 00:42:16 +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=BssAPHp9PtrNBw2/DGkIskmfIZ2tAv2ZD0OOTpkU5ZJyGl56K+ IsKM2ev5JEaNQekzFKCaSkF6DcmxgS22yNDnjpYkfQ0fU6VYJ0oOsq7fGsttZPQL Ap/LLCdE0EIW2GU6/ryXk4LlWaUmcTpsRSaWLubcb7Nx8ejlCHFp8suQM= 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=q3RwaRa3iaR7QyfiDw+Utbhos18=; b=uI6/uwOlAOA7fc2d9vUM CoG8DVe/8WFVwArcZlZPAgiB0KJrTOj1YE4fnXXgKK7VH6SNrNiSObcTpZsMwiTW onIEiDSP1POuvl6HASbw4t13CfVwg9Q5xPTMVhS9Z/iph7rI/OQWxWgSEQT3OOQv btULGKMYX+7sCVc/h10MKrE= Received: (qmail 78322 invoked by alias); 12 Sep 2019 14:42:08 -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 78314 invoked by uid 89); 12 Sep 2019 14:42:08 -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=dim, 2, 5, *t2, *T2 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; Thu, 12 Sep 2019 14:42:06 +0000 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x8CEIpvd013050; Thu, 12 Sep 2019 14:42:04 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=8fbNr8bI58kJS/Y/xT5hAFMJbHExiTr1XvOkfITv8c4=; b=qTEWPhvAIMW0JxdyOdPkATD6Lc8SPoZ9VHm85dn5mDSzIHh3JF1EZ5+1TizAkUfmEfQK rB9ziobjcL8UJsPXcdQlHZL6OpWvxmlIDWbHAVH3jVG7DU7QbjKRBoD///c9mWkockRZ Lm5RJ3DzWEDYD44rOewuJVZch7W0XV1/5duMVgOu0kK/PL+g462XHnymuzpkZvsAzT23 TYejG+McwdRtOg33diJvEhnc5hNq8k9a4D0N+1gTobxaLDLKahNRfJmcRA5CklNvkZA+ pngHiu+s/vlIMqE7Y7pqxLlc7TXKvfB/qUGuhbZ7FG612sYLZBgNTIeWq/+1KjPquroI pg== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2130.oracle.com with ESMTP id 2uw1m990fb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 12 Sep 2019 14:42:04 +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 x8CENtZW023366; Thu, 12 Sep 2019 14:42:03 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3020.oracle.com with ESMTP id 2uy33cd500-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 12 Sep 2019 14:42:03 +0000 Received: from abhmp0005.oracle.com (abhmp0005.oracle.com [141.146.116.11]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x8CEg2pn020942; Thu, 12 Sep 2019 14:42:03 GMT Received: from [192.168.1.4] (/79.19.31.88) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 12 Sep 2019 07:42:01 -0700 To: "gcc-patches@gcc.gnu.org" Cc: Jason Merrill From: Paolo Carlini Subject: [C++ Patch] Another bunch of location fixes Message-ID: Date: Thu, 12 Sep 2019 16:41:59 +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, nothing special here, various bits I missed so far or in the past meant to test more thoroughly. Thanks, Paolo. ////////////////////////// /cp 2019-09-12 Paolo Carlini * decl.c (grokdeclarator): Use declspecs->locations and declarator->id_loc in a few error messages. * pt.c (finish_member_template_decl): Use DECL_SOURCE_LOCATION. (push_template_decl_real): Likewise. /testsuite 2019-09-12 Paolo Carlini * g++.dg/ext/int128-6.C: New. * c-c++-common/pr68107.c: Test location(s). * g++.dg/other/large-size-array.C: Likewise. * g++.dg/template/dtor2.C: Likewise. * g++.dg/template/error9.C: Likewise. * g++.dg/tls/diag-2.C: Likewise. * g++.dg/tls/diag-4.C: Likewise. * g++.dg/tls/diag-5.C: Likewise. * g++.old-deja/g++.pt/memtemp71.C: Likewise. Index: cp/decl.c =================================================================== --- cp/decl.c (revision 275681) +++ cp/decl.c (working copy) @@ -10948,14 +10948,15 @@ grokdeclarator (const cp_declarator *declarator, { if (! int_n_enabled_p[declspecs->int_n_idx]) { - error ("%<__int%d%> is not supported by this target", - int_n_data[declspecs->int_n_idx].bitsize); + error_at (declspecs->locations[ds_type_spec], + "%<__int%d%> is not supported by this target", + int_n_data[declspecs->int_n_idx].bitsize); explicit_intN = false; } /* Don't pedwarn if the alternate "__intN__" form has been used instead of "__intN". */ else if (!int_n_alt && pedantic && ! in_system_header_at (input_location)) - pedwarn (input_location, OPT_Wpedantic, + pedwarn (declspecs->locations[ds_type_spec], OPT_Wpedantic, "ISO C++ does not support %<__int%d%> for %qs", int_n_data[declspecs->int_n_idx].bitsize, name); } @@ -11330,7 +11331,10 @@ grokdeclarator (const cp_declarator *declarator, && storage_class != sc_static) || typedef_p)) { - error ("multiple storage classes in declaration of %qs", name); + location_t loc + = min_location (declspecs->locations[ds_thread], + declspecs->locations[ds_storage_class]); + error_at (loc, "multiple storage classes in declaration of %qs", name); thread_p = false; } if (decl_context != NORMAL @@ -11489,7 +11493,9 @@ grokdeclarator (const cp_declarator *declarator, type = create_array_type_for_decl (dname, type, declarator->u.array.bounds, declarator->id_loc); - if (!valid_array_size_p (input_location, type, dname)) + if (!valid_array_size_p (dname + ? declarator->id_loc : input_location, + type, dname)) type = error_mark_node; if (declarator->std_attributes) Index: cp/pt.c =================================================================== --- cp/pt.c (revision 275681) +++ cp/pt.c (working copy) @@ -298,7 +298,8 @@ finish_member_template_decl (tree decl) return NULL_TREE; } else if (TREE_CODE (decl) == FIELD_DECL) - error ("data member %qD cannot be a member template", decl); + error_at (DECL_SOURCE_LOCATION (decl), + "data member %qD cannot be a member template", decl); else if (DECL_TEMPLATE_INFO (decl)) { if (!DECL_TEMPLATE_SPECIALIZATION (decl)) @@ -310,7 +311,8 @@ finish_member_template_decl (tree decl) return decl; } else - error ("invalid member template declaration %qD", decl); + error_at (DECL_SOURCE_LOCATION (decl), + "invalid member template declaration %qD", decl); return error_mark_node; } @@ -5515,7 +5517,8 @@ push_template_decl_real (tree decl, bool is_friend /* [temp.mem] A destructor shall not be a member template. */ - error ("destructor %qD declared as member template", decl); + error_at (DECL_SOURCE_LOCATION (decl), + "destructor %qD declared as member template", decl); return error_mark_node; } if (IDENTIFIER_NEWDEL_OP_P (DECL_NAME (decl)) Index: testsuite/c-c++-common/pr68107.c =================================================================== --- testsuite/c-c++-common/pr68107.c (revision 275681) +++ testsuite/c-c++-common/pr68107.c (working copy) @@ -3,34 +3,34 @@ #define N ((__SIZE_MAX__ / sizeof (int)) / 2 + 1) -typedef int (*T1)[N]; /* { dg-error "exceeds maximum object size" } */ +typedef int (*T1)[N]; /* { dg-error "15:exceeds maximum object size" } */ typedef int (*T2)[N - 1]; -typedef int (*T3)[N][N]; /* { dg-error "exceeds maximum object size" } */ -typedef int (*T4)[N - 1][N - 1]; /* { dg-error "exceeds maximum object size" } */ -typedef int (**T5)[N]; /* { dg-error "exceeds maximum object size" } */ +typedef int (*T3)[N][N]; /* { dg-error "15:exceeds maximum object size" } */ +typedef int (*T4)[N - 1][N - 1]; /* { dg-error "15:exceeds maximum object size" } */ +typedef int (**T5)[N]; /* { dg-error "16:exceeds maximum object size" } */ struct S { - int (*q1)[N]; /* { dg-error "exceeds maximum object size" } */ + int (*q1)[N]; /* { dg-error "9:exceeds maximum object size" } */ int (*q2)[N - 1]; - int (*q3)[N][N]; /* { dg-error "exceeds maximum object size" } */ - int (*q4)[N - 1][N - 1]; /* { dg-error "exceeds maximum object size" } */ - int (**q5)[N]; /* { dg-error "exceeds maximum object size" } */ + int (*q3)[N][N]; /* { dg-error "9:exceeds maximum object size" } */ + int (*q4)[N - 1][N - 1]; /* { dg-error "9:exceeds maximum object size" } */ + int (**q5)[N]; /* { dg-error "10:exceeds maximum object size" } */ }; -void fn1 (int (*p1)[N]); /* { dg-error "exceeds maximum object size" } */ +void fn1 (int (*p1)[N]); /* { dg-error "17:exceeds maximum object size" } */ void fn2 (int (*p1)[N - 1]); -void fn3 (int (*p3)[N][N]); /* { dg-error "exceeds maximum object size" } */ -void fn4 (int (*p4)[N - 1][N - 1]); /* { dg-error "exceeds maximum object size" } */ -void fn5 (int (**p5)[N]); /* { dg-error "exceeds maximum object size" } */ +void fn3 (int (*p3)[N][N]); /* { dg-error "17:exceeds maximum object size" } */ +void fn4 (int (*p4)[N - 1][N - 1]); /* { dg-error "17:exceeds maximum object size" } */ +void fn5 (int (**p5)[N]); /* { dg-error "18:exceeds maximum object size" } */ void fn (void) { - int (*n1)[N]; /* { dg-error "exceeds maximum object size" } */ + int (*n1)[N]; /* { dg-error "9:exceeds maximum object size" } */ int (*n2)[N - 1]; - int (*n3)[N][N]; /* { dg-error "exceeds maximum object size" } */ - int (*n4)[N - 1][N - 1]; /* { dg-error "exceeds maximum object size" } */ - int (**n5)[N]; /* { dg-error "exceeds maximum object size" } */ + int (*n3)[N][N]; /* { dg-error "9:exceeds maximum object size" } */ + int (*n4)[N - 1][N - 1]; /* { dg-error "9:exceeds maximum object size" } */ + int (**n5)[N]; /* { dg-error "10:exceeds maximum object size" } */ sizeof (int (*)[N]); /* { dg-error "exceeds maximum object size" } */ sizeof (int [N]); /* { dg-error "exceeds maximum object size" } */ Index: testsuite/g++.dg/ext/int128-6.C =================================================================== --- testsuite/g++.dg/ext/int128-6.C (nonexistent) +++ testsuite/g++.dg/ext/int128-6.C (working copy) @@ -0,0 +1,5 @@ +// { dg-do compile { target int128 } } + +__int128 i __attribute__((unused)); // { dg-error "1:ISO C\\+\\+ does not support" } + +unsigned __int128 ui __attribute__((unused)); // { dg-error "10:ISO C\\+\\+ does not support" } Index: testsuite/g++.dg/other/large-size-array.C =================================================================== --- testsuite/g++.dg/other/large-size-array.C (revision 275681) +++ testsuite/g++.dg/other/large-size-array.C (working copy) @@ -20,7 +20,7 @@ sub (int *a) int main (void) { - int a[DIM][DIM]; /* { dg-error "exceeds maximum object size" } */ + int a[DIM][DIM]; /* { dg-error "7:exceeds maximum object size" } */ return sub (&a[0][0]); /* { dg-error "declared" } */ } Index: testsuite/g++.dg/template/dtor2.C =================================================================== --- testsuite/g++.dg/template/dtor2.C (revision 275681) +++ testsuite/g++.dg/template/dtor2.C (working copy) @@ -1,7 +1,7 @@ struct Foo { template - ~Foo() {} // { dg-error "" } + ~Foo() {} // { dg-error "5:destructor .Foo::~Foo\\\(\\\)." } }; int main() Index: testsuite/g++.dg/template/error9.C =================================================================== --- testsuite/g++.dg/template/error9.C (revision 275681) +++ testsuite/g++.dg/template/error9.C (working copy) @@ -3,5 +3,5 @@ struct Foo { template - ~Foo(); // { dg-error "" } + ~Foo(); // { dg-error "5:destructor .Foo::~Foo\\\(\\\)." } }; Index: testsuite/g++.dg/tls/diag-2.C =================================================================== --- testsuite/g++.dg/tls/diag-2.C (revision 275681) +++ testsuite/g++.dg/tls/diag-2.C (working copy) @@ -4,14 +4,14 @@ __thread extern int g1; /* { dg-error "'__thread' before 'extern'" } */ __thread static int g2; /* { dg-error "'__thread' before 'static'" } */ __thread __thread int g3; /* { dg-error "duplicate '__thread'" } */ -typedef __thread int g4; /* { dg-error "multiple storage classes" } */ +typedef __thread int g4; /* { dg-error "9:multiple storage classes" } */ void foo() { __thread int l1; /* { dg-error "3:function-scope .l1. implicitly auto and declared '__thread'" } */ - auto __thread int l2; /* { dg-error "multiple storage classes|data types" } */ + auto __thread int l2; /* { dg-error "3:multiple storage classes|data types" } */ __thread extern int l3; /* { dg-error "'__thread' before 'extern'" } */ - register __thread int l4; /* { dg-error "multiple storage classes" } */ + register __thread int l4; /* { dg-error "3:multiple storage classes" } */ } /* { dg-error "ISO C\\+\\+17 does not allow 'register' storage class specifier" "" { target c++17 } .-1 } */ __thread void f1 (); /* { dg-error "1:storage class .__thread. invalid for function" } */ Index: testsuite/g++.dg/tls/diag-4.C =================================================================== --- testsuite/g++.dg/tls/diag-4.C (revision 275681) +++ testsuite/g++.dg/tls/diag-4.C (working copy) @@ -1,10 +1,10 @@ /* Invalid __thread specifiers. */ /* { dg-require-effective-target tls } */ -__thread typedef int g4; /* { dg-error "multiple storage classes" } */ +__thread typedef int g4; /* { dg-error "1:multiple storage classes" } */ void foo() { - __thread auto int l2; /* { dg-error "multiple storage classes|data types" } */ - __thread register int l4; /* { dg-error "multiple storage classes" } */ + __thread auto int l2; /* { dg-error "3:multiple storage classes|data types" } */ + __thread register int l4; /* { dg-error "3:multiple storage classes" } */ } /* { dg-error "ISO C\\+\\+17 does not allow 'register' storage class specifier" "" { target c++17 } .-1 } */ Index: testsuite/g++.dg/tls/diag-5.C =================================================================== --- testsuite/g++.dg/tls/diag-5.C (revision 275681) +++ testsuite/g++.dg/tls/diag-5.C (working copy) @@ -2,4 +2,4 @@ // Invalid __thread specifiers. // { dg-require-effective-target tls } -struct A { __thread register int i; }; // { dg-error "multiple storage classes|storage class specified" } +struct A { __thread register int i; }; // { dg-error "12:multiple storage classes|storage class specified" } Index: testsuite/g++.old-deja/g++.pt/memtemp71.C =================================================================== --- testsuite/g++.old-deja/g++.pt/memtemp71.C (revision 275681) +++ testsuite/g++.old-deja/g++.pt/memtemp71.C (working copy) @@ -2,5 +2,5 @@ class A { - templateT epsilon; // { dg-error "" } invalid member template + templateT epsilon; // { dg-error "22:data member .epsilon. cannot be a member template" } };