From: Paolo Carlini Date: Mon, 16 Sep 2019 23:04:10 +0000 (+0000) Subject: decl.c (grokdeclarator): Use declspecs->locations and declarator->id_loc in a few... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=61b204bf24adfe62d58400e60732bc569bc2164a;p=gcc.git decl.c (grokdeclarator): Use declspecs->locations and declarator->id_loc in a few error messages. /cp 2019-09-16 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-16 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. From-SVN: r275759 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 7bf28f81fae..efa1686b2a0 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2019-09-16 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. + 2019-09-15 Jason Merrill PR c++/30277 - int-width bit-field promotion. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index e0d67328121..b753796609a 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -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) diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 9de1b8fec97..4b3993cdeda 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -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)) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 7b9d0d05089..f705dc46351 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,15 @@ +2019-09-16 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. + 2019-09-16 Li Jia He Qi Feng diff --git a/gcc/testsuite/c-c++-common/pr68107.c b/gcc/testsuite/c-c++-common/pr68107.c index 6cf19cb0da9..b9f9afec92a 100644 --- a/gcc/testsuite/c-c++-common/pr68107.c +++ b/gcc/testsuite/c-c++-common/pr68107.c @@ -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" } */ diff --git a/gcc/testsuite/g++.dg/ext/int128-6.C b/gcc/testsuite/g++.dg/ext/int128-6.C new file mode 100644 index 00000000000..a475b01ddc6 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/int128-6.C @@ -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" } diff --git a/gcc/testsuite/g++.dg/other/large-size-array.C b/gcc/testsuite/g++.dg/other/large-size-array.C index 631e3a895f8..15a33f902f4 100644 --- a/gcc/testsuite/g++.dg/other/large-size-array.C +++ b/gcc/testsuite/g++.dg/other/large-size-array.C @@ -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" } */ } diff --git a/gcc/testsuite/g++.dg/template/dtor2.C b/gcc/testsuite/g++.dg/template/dtor2.C index 04bea9cb640..d8b6b4f5cb1 100644 --- a/gcc/testsuite/g++.dg/template/dtor2.C +++ b/gcc/testsuite/g++.dg/template/dtor2.C @@ -1,7 +1,7 @@ struct Foo { template - ~Foo() {} // { dg-error "" } + ~Foo() {} // { dg-error "5:destructor .Foo::~Foo\\\(\\\)." } }; int main() diff --git a/gcc/testsuite/g++.dg/template/error9.C b/gcc/testsuite/g++.dg/template/error9.C index 60f550a7ca6..65e3d91aef4 100644 --- a/gcc/testsuite/g++.dg/template/error9.C +++ b/gcc/testsuite/g++.dg/template/error9.C @@ -3,5 +3,5 @@ struct Foo { template - ~Foo(); // { dg-error "" } + ~Foo(); // { dg-error "5:destructor .Foo::~Foo\\\(\\\)." } }; diff --git a/gcc/testsuite/g++.dg/tls/diag-2.C b/gcc/testsuite/g++.dg/tls/diag-2.C index c247a9787a2..3e8f422b41d 100644 --- a/gcc/testsuite/g++.dg/tls/diag-2.C +++ b/gcc/testsuite/g++.dg/tls/diag-2.C @@ -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" } */ diff --git a/gcc/testsuite/g++.dg/tls/diag-4.C b/gcc/testsuite/g++.dg/tls/diag-4.C index 56f185e312c..24e28c9575c 100644 --- a/gcc/testsuite/g++.dg/tls/diag-4.C +++ b/gcc/testsuite/g++.dg/tls/diag-4.C @@ -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 } */ diff --git a/gcc/testsuite/g++.dg/tls/diag-5.C b/gcc/testsuite/g++.dg/tls/diag-5.C index ca92b307428..f94e68c6d7e 100644 --- a/gcc/testsuite/g++.dg/tls/diag-5.C +++ b/gcc/testsuite/g++.dg/tls/diag-5.C @@ -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" } diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp71.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp71.C index 74149a005c3..91cfac0032c 100644 --- a/gcc/testsuite/g++.old-deja/g++.pt/memtemp71.C +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp71.C @@ -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" } };