Commit 062ab459 by Paolo Carlini Committed by Paolo Carlini

decl.c (cp_finish_decl): Improve error location.

/cp
2019-01-12  Paolo Carlini  <paolo.carlini@oracle.com>

	* decl.c (cp_finish_decl): Improve error location.
	* decl2.c (grokfield): Likewise, improve two locations.

/testsuite
2019-01-12  Paolo Carlini  <paolo.carlini@oracle.com>

	* g++.dg/cpp0x/pr62101.C: Test locations too.
	* g++.dg/inherit/pure1.C: Likewise.

From-SVN: r267887
parent 8d5d3edd
2019-01-12 Paolo Carlini <paolo.carlini@oracle.com>
* decl.c (cp_finish_decl): Improve error location.
* decl2.c (grokfield): Likewise, improve two locations.
2019-01-11 Marek Polacek <polacek@redhat.com> 2019-01-11 Marek Polacek <polacek@redhat.com>
PR c++/88692, c++/87882 - -Wredundant-move false positive with *this. PR c++/88692, c++/87882 - -Wredundant-move false positive with *this.
......
...@@ -7293,7 +7293,10 @@ cp_finish_decl (tree decl, tree init, bool init_const_expr_p, ...@@ -7293,7 +7293,10 @@ cp_finish_decl (tree decl, tree init, bool init_const_expr_p,
synthesize_method (decl); synthesize_method (decl);
} }
else else
error ("function %q#D is initialized like a variable", decl); error_at (cp_expr_loc_or_loc (init,
DECL_SOURCE_LOCATION (decl)),
"function %q#D is initialized like a variable",
decl);
} }
/* else no initialization required. */ /* else no initialization required. */
} }
......
...@@ -924,12 +924,14 @@ grokfield (const cp_declarator *declarator, ...@@ -924,12 +924,14 @@ grokfield (const cp_declarator *declarator,
else else
{ {
gcc_assert (TREE_CODE (TREE_TYPE (value)) == FUNCTION_TYPE); gcc_assert (TREE_CODE (TREE_TYPE (value)) == FUNCTION_TYPE);
location_t iloc
= cp_expr_loc_or_loc (init, DECL_SOURCE_LOCATION (value));
if (friendp) if (friendp)
error ("initializer specified for friend function %qD", error_at (iloc, "initializer specified for friend "
value); "function %qD", value);
else else
error ("initializer specified for static member function %qD", error_at (iloc, "initializer specified for static "
value); "member function %qD", value);
} }
} }
else if (TREE_CODE (value) == FIELD_DECL) else if (TREE_CODE (value) == FIELD_DECL)
......
2019-01-12 Paolo Carlini <paolo.carlini@oracle.com>
* g++.dg/cpp0x/pr62101.C: Test locations too.
* g++.dg/inherit/pure1.C: Likewise.
2019-01-12 Paul Thomas <pault@gcc.gnu.org> 2019-01-12 Paul Thomas <pault@gcc.gnu.org>
* gfortran.dg/ISO_Fortran_binding_2.f90 : Remove because of * gfortran.dg/ISO_Fortran_binding_2.f90 : Remove because of
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
struct X struct X
{ {
friend void g(X, int) = 0; // { dg-error "initializer specified for friend function" } friend void g(X, int) = 0; // { dg-error "15:initializer specified for friend function" }
friend void g(X, int) = default; // { dg-error "cannot be defaulted" } friend void g(X, int) = default; // { dg-error "cannot be defaulted" }
// { dg-prune-output "note" } // { dg-prune-output "note" }
friend void f(X, int) = delete; friend void f(X, int) = delete;
......
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