===================================================================
@@ -10579,7 +10579,8 @@ grokdeclarator (const cp_declarator *declarator,
ctype = qualifying_scope;
if (!MAYBE_CLASS_TYPE_P (ctype))
{
- error ("%q#T is not a class or a namespace", ctype);
+ error_at (id_declarator->id_loc,
+ "%q#T is not a class or namespace", ctype);
ctype = NULL_TREE;
}
else if (innermost_code != cdk_function
@@ -10601,13 +10602,15 @@ grokdeclarator (const cp_declarator *declarator,
{
if (innermost_code != cdk_function)
{
- error ("declaration of %qD as non-function", decl);
+ error_at (EXPR_LOCATION (decl),
+ "declaration of %qE as non-function", decl);
return error_mark_node;
}
else if (!qualifying_scope
&& !(current_class_type && at_class_scope_p ()))
{
- error ("declaration of %qD as non-member", decl);
+ error_at (EXPR_LOCATION (decl),
+ "declaration of %qE as non-member", decl);
return error_mark_node;
}
@@ -12510,7 +12513,7 @@ grokdeclarator (const cp_declarator *declarator,
else if (in_namespace && !friendp)
{
/* Something like struct S { int N::j; }; */
- error ("invalid use of %<::%>");
+ error_at (id_loc, "invalid use of %<::%>");
return error_mark_node;
}
else if (FUNC_OR_METHOD_TYPE_P (type) && unqualified_id)
@@ -12565,15 +12568,15 @@ grokdeclarator (const cp_declarator *declarator,
if (!ctype)
{
gcc_assert (friendp);
- error ("expected qualified name in friend declaration "
- "for destructor %qD", uqname);
+ error_at (id_loc, "expected qualified name in friend "
+ "declaration for destructor %qD", uqname);
return error_mark_node;
}
if (!check_dtor_name (ctype, TREE_OPERAND (uqname, 0)))
{
- error ("declaration of %qD as member of %qT",
- uqname, ctype);
+ error_at (id_loc, "declaration of %qD as member of %qT",
+ uqname, ctype);
return error_mark_node;
}
if (concept_p)
===================================================================
@@ -2,4 +2,4 @@
// { dg-do compile { target c++11 } }
enum A { };
-void A::f() { } // { dg-error "not a class" }
+void A::f() { } // { dg-error "6:.enum A. is not a class" }
===================================================================
@@ -4,10 +4,10 @@
struct A
{
- friend ~A(); // { dg-error "qualified name" }
+ friend ~A(); // { dg-error "10:expected qualified name" }
};
struct B
{
- friend ~A(); // { dg-error "qualified name" }
+ friend ~A(); // { dg-error "10:expected qualified name" }
};
===================================================================
@@ -1,12 +1,12 @@
// PR c++/19732
struct A;
-typedef int ~A; // { dg-error "non-function" }
+typedef int ~A; // { dg-error "13:declaration of .~ A. as non-function" }
struct B {
- ~A(); // { dg-error "" }
- typedef int ~A; // { dg-error "non-function" }
+ ~A(); // { dg-error "3:declaration of .~A. as member of .B." }
+ typedef int ~A; // { dg-error "15:declaration of .~ A. as non-function" }
void f() {
- extern ~B(); // { dg-error "non-member" }
+ extern ~B(); // { dg-error "12:declaration of .~ B. as non-member" }
}
};
-void ~A(); // { dg-error "non-member" }
+void ~A(); // { dg-error "6:declaration of .~ A. as non-member" }
===================================================================
@@ -19,7 +19,8 @@ struct B
struct C
{
friend int C ();
- friend int ~C (); // { dg-error "return type|in friend decl" }
+ friend int ~C (); // { dg-error "10:return type" }
+ // { dg-error "14:expected qualified name in friend decl" "" { target *-*-* } .-1 }
friend int C (const C &);
};
@@ -26,7 +27,8 @@ struct C
struct D
{
friend int D () {}
- friend int ~D () {} // { dg-error "return type|in friend decl" }
+ friend int ~D () {} // { dg-error "10:return type" }
+ // { dg-error "14:expected qualified name in friend decl" "" { target *-*-* } .-1 }
friend int D (const D &) {}
};
===================================================================
@@ -3,7 +3,7 @@
struct A
{
template<void (A::*)()> struct B {};
- void ::foo(); // { dg-error "invalid use" }
+ void ::foo(); // { dg-error "10:invalid use" }
B<&A::foo> b; // { dg-error "incomplete type|template argument" }
};
===================================================================
@@ -1,4 +1,4 @@
// { dg-do assemble }
// GROUPS passed error-messages
class foo {};
-~foo () {}// { dg-error "" } destructors must be member functions.*
+~foo () {}// { dg-error "1:declaration of .~ foo. as non-member" } destructors must be member functions.*