Commit ad441c26 by Paolo Carlini Committed by Paolo Carlini

decl.c (grokdeclarator): Use declarator->id_loc in two additional places.

/cp
2019-06-04  Paolo Carlini  <paolo.carlini@oracle.com>

	* decl.c (grokdeclarator): Use declarator->id_loc in two
	additional places.

/testsuite
2019-06-04  Paolo Carlini  <paolo.carlini@oracle.com>

	* 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
parent e756e900
2019-06-04 Paolo Carlini <paolo.carlini@oracle.com>
* decl.c (grokdeclarator): Use declarator->id_loc in two
additional places.
2019-06-04 Nathan Sidwell <nathan@acm.org> 2019-06-04 Nathan Sidwell <nathan@acm.org>
* name-lookup.c (lookup_type_scope_1): Reimplement, handle local * name-lookup.c (lookup_type_scope_1): Reimplement, handle local
......
...@@ -11873,6 +11873,8 @@ grokdeclarator (const cp_declarator *declarator, ...@@ -11873,6 +11873,8 @@ grokdeclarator (const cp_declarator *declarator,
unqualified_id = dname; unqualified_id = dname;
} }
location_t loc = declarator ? declarator->id_loc : input_location;
/* If TYPE is a FUNCTION_TYPE, but the function name was explicitly /* If TYPE is a FUNCTION_TYPE, but the function name was explicitly
qualified with a class-name, turn it into a METHOD_TYPE, unless qualified with a class-name, turn it into a METHOD_TYPE, unless
we know that the function is static. We take advantage of this we know that the function is static. We take advantage of this
...@@ -11898,8 +11900,7 @@ grokdeclarator (const cp_declarator *declarator, ...@@ -11898,8 +11900,7 @@ grokdeclarator (const cp_declarator *declarator,
friendp = 0; friendp = 0;
} }
else else
permerror (declarator->id_loc, permerror (loc, "extra qualification %<%T::%> on member %qs",
"extra qualification %<%T::%> on member %qs",
ctype, name); ctype, name);
} }
else if (/* If the qualifying type is already complete, then we else if (/* If the qualifying type is already complete, then we
...@@ -11928,19 +11929,19 @@ grokdeclarator (const cp_declarator *declarator, ...@@ -11928,19 +11929,19 @@ grokdeclarator (const cp_declarator *declarator,
if (current_class_type if (current_class_type
&& (!friendp || funcdef_flag || initialized)) && (!friendp || funcdef_flag || initialized))
{ {
error (funcdef_flag || initialized error_at (loc, funcdef_flag || initialized
? G_("cannot define member function %<%T::%s%> " ? G_("cannot define member function %<%T::%s%> "
"within %qT") "within %qT")
: G_("cannot declare member function %<%T::%s%> " : G_("cannot declare member function %<%T::%s%> "
"within %qT"), "within %qT"),
ctype, name, current_class_type); ctype, name, current_class_type);
return error_mark_node; return error_mark_node;
} }
} }
else if (typedef_p && current_class_type) else if (typedef_p && current_class_type)
{ {
error ("cannot declare member %<%T::%s%> within %qT", error_at (loc, "cannot declare member %<%T::%s%> within %qT",
ctype, name, current_class_type); ctype, name, current_class_type);
return error_mark_node; return error_mark_node;
} }
} }
...@@ -12053,8 +12054,6 @@ grokdeclarator (const cp_declarator *declarator, ...@@ -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 this is declaring a typedef name, return a TYPE_DECL. */
if (typedef_p && decl_context != TYPENAME) if (typedef_p && decl_context != TYPENAME)
{ {
......
2019-06-04 Paolo Carlini <paolo.carlini@oracle.com>
* 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 <wschmidt@linux.ibm.com> 2019-06-04 Bill Schmidt <wschmidt@linux.ibm.com>
PR target/78263 PR target/78263
......
...@@ -9,7 +9,7 @@ struct A ...@@ -9,7 +9,7 @@ struct A
void foo(auto); void foo(auto);
}; };
void B::foo(auto) {} // { dg-error "cannot define" } void B::foo(auto) {} // { dg-error "8:cannot define" }
struct X struct X
{ {
...@@ -21,8 +21,8 @@ struct A ...@@ -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" }
}; };
...@@ -8,5 +8,5 @@ struct A ...@@ -8,5 +8,5 @@ struct A
struct B struct B
{ {
template<typename> friend void A::foo() = delete; // { dg-error "" } template<typename> friend void A::foo() = delete; // { dg-error "34:cannot define" }
}; };
...@@ -7,7 +7,7 @@ struct A { ...@@ -7,7 +7,7 @@ struct A {
void operator delete(void *); void operator delete(void *);
}; };
struct B { struct B {
friend void A::foo() {} // { dg-error "22:cannot define member function 'A::foo' 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 "39:cannot define member function 'A::operator delete' 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 "15:cannot define member function 'A::A' within 'B'" } friend A::A() {} // { dg-error "10:cannot define member function 'A::A' within 'B'" }
}; };
...@@ -2,5 +2,5 @@ ...@@ -2,5 +2,5 @@
// { dg-options "" } // { dg-options "" }
struct X { struct X {
void X::bar() {} // { dg-error "" } void X::bar() {} // { dg-error "8:extra qualification" }
}; };
...@@ -2,5 +2,5 @@ ...@@ -2,5 +2,5 @@
template<int> struct A template<int> struct A
{ {
template<int> template<int> void A::foo() {} // { dg-error "extra qualification" } template<int> template<int> void A::foo() {} // { dg-error "36:extra qualification" }
}; };
...@@ -6,6 +6,6 @@ struct A { ...@@ -6,6 +6,6 @@ struct A {
}; };
struct B { struct B {
void A::a1(); // this used to die in chainon(), now grokdeclarator should// { 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 "" } cannot declare.* void A::a2(); // should be fixed by the 930629 change.// { dg-error "10:cannot declare" } cannot declare.*
}; };
...@@ -10,6 +10,6 @@ public: ...@@ -10,6 +10,6 @@ public:
void f (); void f ();
void g (int); void g (int);
}; };
void B::f () {}// { dg-error "" } .* void B::f () {}// { dg-error "8:cannot define" } .*
void B::g (int val) {}// { dg-error "" } .* void B::g (int val) {}// { dg-error "8:cannot define" } .*
}; };
...@@ -10,7 +10,7 @@ public: ...@@ -10,7 +10,7 @@ public:
}; };
class deriv : public base { class deriv : public base {
void base :: f1();// { dg-error "" } .* void base :: f1();// { dg-error "8:cannot declare" } .*
}; };
int main () int main ()
......
...@@ -35,7 +35,7 @@ struct B { ...@@ -35,7 +35,7 @@ struct B {
struct ::Q { // { dg-error "global qual" } ::Q not a member of B struct ::Q { // { dg-error "global qual" } ::Q not a member of B
int m; 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; return 0;
} }
void fn(struct ::Q &); void fn(struct ::Q &);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment