From: Paolo Carlini Date: Tue, 4 Jun 2019 23:10:56 +0000 (+0000) Subject: decl.c (grokdeclarator): Use declarator->id_loc in two additional places. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ad441c263d5aeedc9c152642cba54dcba7799b2b;p=gcc.git decl.c (grokdeclarator): Use declarator->id_loc in two additional places. /cp 2019-06-04 Paolo Carlini * decl.c (grokdeclarator): Use declarator->id_loc in two additional places. /testsuite 2019-06-04 Paolo Carlini * g++.dg/concepts/pr60573.C: Test locations too. * g++.dg/cpp0x/deleted13.C: Likewise. * g++.dg/parse/error29.C: Likewise. * g++.dg/parse/qualified4.C: Likewise. * g++.dg/template/crash96.C Likewise. * g++.old-deja/g++.brendan/crash22.C Likewise. * g++.old-deja/g++.brendan/crash23.C Likewise. * g++.old-deja/g++.law/visibility10.C Likewise. * g++.old-deja/g++.other/decl5.C: Likewise. From-SVN: r271928 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index c28faf90144..ddd5581a111 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2019-06-04 Paolo Carlini + + * decl.c (grokdeclarator): Use declarator->id_loc in two + additional places. + 2019-06-04 Nathan Sidwell * name-lookup.c (lookup_type_scope_1): Reimplement, handle local diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index bdf397e5ecb..23b2a4c2831 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -11873,6 +11873,8 @@ grokdeclarator (const cp_declarator *declarator, unqualified_id = dname; } + location_t loc = declarator ? declarator->id_loc : input_location; + /* If TYPE is a FUNCTION_TYPE, but the function name was explicitly qualified with a class-name, turn it into a METHOD_TYPE, unless we know that the function is static. We take advantage of this @@ -11898,8 +11900,7 @@ grokdeclarator (const cp_declarator *declarator, friendp = 0; } else - permerror (declarator->id_loc, - "extra qualification %<%T::%> on member %qs", + permerror (loc, "extra qualification %<%T::%> on member %qs", ctype, name); } else if (/* If the qualifying type is already complete, then we @@ -11928,19 +11929,19 @@ grokdeclarator (const cp_declarator *declarator, if (current_class_type && (!friendp || funcdef_flag || initialized)) { - error (funcdef_flag || initialized - ? G_("cannot define member function %<%T::%s%> " - "within %qT") - : G_("cannot declare member function %<%T::%s%> " - "within %qT"), - ctype, name, current_class_type); + error_at (loc, funcdef_flag || initialized + ? G_("cannot define member function %<%T::%s%> " + "within %qT") + : G_("cannot declare member function %<%T::%s%> " + "within %qT"), + ctype, name, current_class_type); return error_mark_node; } } else if (typedef_p && current_class_type) { - error ("cannot declare member %<%T::%s%> within %qT", - ctype, name, current_class_type); + error_at (loc, "cannot declare member %<%T::%s%> within %qT", + ctype, name, current_class_type); return error_mark_node; } } @@ -12053,8 +12054,6 @@ grokdeclarator (const cp_declarator *declarator, } } - location_t loc = declarator ? declarator->id_loc : input_location; - /* If this is declaring a typedef name, return a TYPE_DECL. */ if (typedef_p && decl_context != TYPENAME) { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 7bcc461327d..03fbc0be021 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,15 @@ +2019-06-04 Paolo Carlini + + * g++.dg/concepts/pr60573.C: Test locations too. + * g++.dg/cpp0x/deleted13.C: Likewise. + * g++.dg/parse/error29.C: Likewise. + * g++.dg/parse/qualified4.C: Likewise. + * g++.dg/template/crash96.C Likewise. + * g++.old-deja/g++.brendan/crash22.C Likewise. + * g++.old-deja/g++.brendan/crash23.C Likewise. + * g++.old-deja/g++.law/visibility10.C Likewise. + * g++.old-deja/g++.other/decl5.C: Likewise. + 2019-06-04 Bill Schmidt PR target/78263 diff --git a/gcc/testsuite/g++.dg/concepts/pr60573.C b/gcc/testsuite/g++.dg/concepts/pr60573.C index 568849175c6..42cda21ef74 100644 --- a/gcc/testsuite/g++.dg/concepts/pr60573.C +++ b/gcc/testsuite/g++.dg/concepts/pr60573.C @@ -9,7 +9,7 @@ struct A void foo(auto); }; - void B::foo(auto) {} // { dg-error "cannot define" } + void B::foo(auto) {} // { dg-error "8:cannot define" } struct X { @@ -21,8 +21,8 @@ struct A }; }; - void Y::Z::foo(auto) {} // { dg-error "cannot define" } + void Y::Z::foo(auto) {} // { dg-error "10:cannot define" } }; - void X::Y::Z::foo(auto) {} // { dg-error "cannot define" } + void X::Y::Z::foo(auto) {} // { dg-error "8:cannot define" } }; diff --git a/gcc/testsuite/g++.dg/cpp0x/deleted13.C b/gcc/testsuite/g++.dg/cpp0x/deleted13.C index f10551f9666..ce915a840e9 100644 --- a/gcc/testsuite/g++.dg/cpp0x/deleted13.C +++ b/gcc/testsuite/g++.dg/cpp0x/deleted13.C @@ -8,5 +8,5 @@ struct A struct B { - template friend void A::foo() = delete; // { dg-error "" } + template friend void A::foo() = delete; // { dg-error "34:cannot define" } }; diff --git a/gcc/testsuite/g++.dg/parse/error29.C b/gcc/testsuite/g++.dg/parse/error29.C index 2c3a3a7f288..20cc82004f2 100644 --- a/gcc/testsuite/g++.dg/parse/error29.C +++ b/gcc/testsuite/g++.dg/parse/error29.C @@ -7,7 +7,7 @@ struct A { void operator delete(void *); }; struct B { - friend void A::foo() {} // { dg-error "22:cannot define member function 'A::foo' within 'B'" } - friend void A::operator delete(void*) {} // { dg-error "39:cannot define member function 'A::operator delete' within 'B'" } - friend A::A() {} // { dg-error "15:cannot define member function 'A::A' within 'B'" } + friend void A::foo() {} // { dg-error "15:cannot define member function 'A::foo' within 'B'" } + friend void A::operator delete(void*) {} // { dg-error "15:cannot define member function 'A::operator delete' within 'B'" } + friend A::A() {} // { dg-error "10:cannot define member function 'A::A' within 'B'" } }; diff --git a/gcc/testsuite/g++.dg/parse/qualified4.C b/gcc/testsuite/g++.dg/parse/qualified4.C index c827fcfe7c1..71b01afd3bd 100644 --- a/gcc/testsuite/g++.dg/parse/qualified4.C +++ b/gcc/testsuite/g++.dg/parse/qualified4.C @@ -2,5 +2,5 @@ // { dg-options "" } struct X { - void X::bar() {} // { dg-error "" } + void X::bar() {} // { dg-error "8:extra qualification" } }; diff --git a/gcc/testsuite/g++.dg/template/crash96.C b/gcc/testsuite/g++.dg/template/crash96.C index 5c2aa9954b1..d1ce2db78b5 100644 --- a/gcc/testsuite/g++.dg/template/crash96.C +++ b/gcc/testsuite/g++.dg/template/crash96.C @@ -2,5 +2,5 @@ template struct A { - template template void A::foo() {} // { dg-error "extra qualification" } + template template void A::foo() {} // { dg-error "36:extra qualification" } }; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash22.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash22.C index 73831a053d1..7e56892c7e9 100644 --- a/gcc/testsuite/g++.old-deja/g++.brendan/crash22.C +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash22.C @@ -6,6 +6,6 @@ struct A { }; struct B { - void A::a1(); // this used to die in chainon(), now grokdeclarator should// { dg-error "" } cannot declare.* - void A::a2(); // should be fixed by the 930629 change.// { dg-error "" } cannot declare.* + void A::a1(); // this used to die in chainon(), now grokdeclarator should// { dg-error "10:cannot declare" } cannot declare.* + void A::a2(); // should be fixed by the 930629 change.// { dg-error "10:cannot declare" } cannot declare.* }; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash23.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash23.C index 2506869792f..f09609dc744 100644 --- a/gcc/testsuite/g++.old-deja/g++.brendan/crash23.C +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash23.C @@ -10,6 +10,6 @@ public: void f (); void g (int); }; - void B::f () {}// { dg-error "" } .* - void B::g (int val) {}// { dg-error "" } .* + void B::f () {}// { dg-error "8:cannot define" } .* + void B::g (int val) {}// { dg-error "8:cannot define" } .* }; diff --git a/gcc/testsuite/g++.old-deja/g++.law/visibility10.C b/gcc/testsuite/g++.old-deja/g++.law/visibility10.C index 23505f63095..7abb4a85d7c 100644 --- a/gcc/testsuite/g++.old-deja/g++.law/visibility10.C +++ b/gcc/testsuite/g++.old-deja/g++.law/visibility10.C @@ -10,7 +10,7 @@ public: }; class deriv : public base { - void base :: f1();// { dg-error "" } .* + void base :: f1();// { dg-error "8:cannot declare" } .* }; int main () diff --git a/gcc/testsuite/g++.old-deja/g++.other/decl5.C b/gcc/testsuite/g++.old-deja/g++.other/decl5.C index 3ac91379e76..6d229325187 100644 --- a/gcc/testsuite/g++.old-deja/g++.other/decl5.C +++ b/gcc/testsuite/g++.old-deja/g++.other/decl5.C @@ -35,7 +35,7 @@ struct B { struct ::Q { // { dg-error "global qual" } ::Q not a member of B int m; }; - int A::fn() { // { dg-error "cannot define member" } A::fn not a member of B + int A::fn() { // { dg-error "7:cannot define member" } A::fn not a member of B return 0; } void fn(struct ::Q &);