return error_mark_node;
argtype = lvalue_type (arg);
+ location_t loc = cp_expr_loc_or_input_loc (arg);
gcc_assert (!(identifier_p (arg) && IDENTIFIER_ANY_OP_P (arg)));
else if (current_class_type
&& TREE_OPERAND (arg, 0) == current_class_ref)
/* An expression like &memfn. */
- permerror (input_location, "ISO C++ forbids taking the address of an unqualified"
+ permerror (loc,
+ "ISO C++ forbids taking the address of an unqualified"
" or parenthesized non-static member function to form"
" a pointer to member function. Say %<&%T::%D%>",
base, name);
else
- permerror (input_location, "ISO C++ forbids taking the address of a bound member"
+ permerror (loc,
+ "ISO C++ forbids taking the address of a bound member"
" function to form a pointer to member function."
" Say %<&%T::%D%>",
base, name);
if (kind == clk_none)
{
if (complain & tf_error)
- lvalue_error (cp_expr_loc_or_input_loc (arg), lv_addressof);
+ lvalue_error (loc, lv_addressof);
return error_mark_node;
}
if (strict_lvalue && (kind & (clk_rvalueref|clk_class)))
if (!(complain & tf_error))
return error_mark_node;
/* Make this a permerror because we used to accept it. */
- permerror (cp_expr_loc_or_input_loc (arg),
- "taking address of rvalue");
+ permerror (loc, "taking address of rvalue");
}
}
arg = build1 (CONVERT_EXPR, type, arg);
return arg;
}
- else if (pedantic && DECL_MAIN_P (arg))
+ else if (pedantic && DECL_MAIN_P (tree_strip_any_location_wrapper (arg)))
{
/* ARM $3.4 */
/* Apparently a lot of autoconf scripts for C++ packages do this,
so only complain if -Wpedantic. */
if (complain & (flag_pedantic_errors ? tf_error : tf_warning))
- pedwarn (input_location, OPT_Wpedantic,
+ pedwarn (loc, OPT_Wpedantic,
"ISO C++ forbids taking address of function %<::main%>");
else if (flag_pedantic_errors)
return error_mark_node;
if (TYPE_REF_P (TREE_TYPE (t)))
{
if (complain & tf_error)
- error ("cannot create pointer to reference member %qD", t);
+ error_at (loc,
+ "cannot create pointer to reference member %qD", t);
return error_mark_node;
}
if (bitfield_p (arg))
{
if (complain & tf_error)
- error_at (cp_expr_loc_or_input_loc (arg),
- "attempt to take address of bit-field");
+ error_at (loc, "attempt to take address of bit-field");
return error_mark_node;
}
|| !DECL_IMMEDIATE_FUNCTION_P (current_function_decl)))
{
if (complain & tf_error)
- error ("taking address of an immediate function %qD",
- stripped_arg);
+ error_at (loc, "taking address of an immediate function %qD",
+ stripped_arg);
return error_mark_node;
}
if (TREE_CODE (stripped_arg) == FUNCTION_DECL
the declared type is incomplete. */
tree functype;
int fn_returns_value_p;
+ location_t loc = cp_expr_loc_or_input_loc (retval);
*no_warning = false;
if (DECL_DESTRUCTOR_P (current_function_decl))
{
if (retval)
- error ("returning a value from a destructor");
+ error_at (loc, "returning a value from a destructor");
return NULL_TREE;
}
else if (DECL_CONSTRUCTOR_P (current_function_decl))
error ("cannot return from a handler of a function-try-block of a constructor");
else if (retval)
/* You can't return a value from a constructor. */
- error ("returning a value from a constructor");
+ error_at (loc, "returning a value from a constructor");
return NULL_TREE;
}
else if (!same_type_p (type, functype))
{
if (LAMBDA_FUNCTION_P (current_function_decl))
- error ("inconsistent types %qT and %qT deduced for "
- "lambda return type", functype, type);
+ error_at (loc, "inconsistent types %qT and %qT deduced for "
+ "lambda return type", functype, type);
else
- error ("inconsistent deduction for auto return type: "
- "%qT and then %qT", functype, type);
+ error_at (loc, "inconsistent deduction for auto return type: "
+ "%qT and then %qT", functype, type);
}
functype = type;
}
its side-effects. */
finish_expr_stmt (retval);
else if (retval != error_mark_node)
- permerror (input_location,
- "return-statement with a value, in function "
+ permerror (loc, "return-statement with a value, in function "
"returning %qT", valtype);
current_function_returns_null = 1;
}
if (warn)
- warning (OPT_Weffc__, "%<operator=%> should return a reference to %<*this%>");
+ warning_at (loc, OPT_Weffc__,
+ "%<operator=%> should return a reference to %<*this%>");
}
if (dependent_type_p (functype)