/* This case handles bogus declarations like template <>
template <class T> void f<int>(); */
- error ("template-id %qD in declaration of primary template",
- declarator);
+ error_at (cp_expr_loc_or_input_loc (declarator),
+ "template-id %qE in declaration of primary template",
+ declarator);
return decl;
}
}
template <class T> void f<int>(); */
if (!uses_template_parms (TREE_OPERAND (declarator, 1)))
- error ("template-id %qD in declaration of primary template",
- declarator);
+ error_at (cp_expr_loc_or_input_loc (declarator),
+ "template-id %qE in declaration of primary template",
+ declarator);
else if (variable_template_p (TREE_OPERAND (declarator, 0)))
{
/* Partial specialization of variable template. */
goto ok;
}
else if (cxx_dialect < cxx14)
- error ("non-type partial specialization %qD "
- "is not allowed", declarator);
+ error_at (cp_expr_loc_or_input_loc (declarator),
+ "non-type partial specialization %qE "
+ "is not allowed", declarator);
else
- error ("non-class, non-variable partial specialization %qD "
- "is not allowed", declarator);
+ error_at (cp_expr_loc_or_input_loc (declarator),
+ "non-class, non-variable partial specialization %qE "
+ "is not allowed", declarator);
return decl;
ok:;
}
{
if ((!packed_args && tpd.arg_uses_template_parms[i])
|| (packed_args && uses_template_parms (arg)))
- error ("template argument %qE involves template parameter(s)",
- arg);
+ error_at (cp_expr_loc_or_input_loc (arg),
+ "template argument %qE involves template "
+ "parameter(s)", arg);
else
{
/* Look at the corresponding template parameter,
{
if (complain & tf_error)
{
- error ("%qE is not a valid template argument for type %qT",
- expr, type);
+ location_t loc = cp_expr_loc_or_input_loc (expr);
+ error_at (loc, "%qE is not a valid template argument for type %qT",
+ expr, type);
if (TYPE_PTR_P (type))
- inform (input_location, "it must be the address of a function "
+ inform (loc, "it must be the address of a function "
"with external linkage");
else
- inform (input_location, "it must be the name of a function with "
+ inform (loc, "it must be the name of a function with "
"external linkage");
}
return NULL_TREE;
{
if (complain & tf_error)
{
+ location_t loc = cp_expr_loc_or_input_loc (expr);
if (cxx_dialect >= cxx11)
- error ("%qE is not a valid template argument for type %qT "
- "because %qD has no linkage",
- expr, type, fn_no_ptr);
+ error_at (loc, "%qE is not a valid template argument for type "
+ "%qT because %qD has no linkage",
+ expr, type, fn_no_ptr);
else
- error ("%qE is not a valid template argument for type %qT "
- "because %qD does not have external linkage",
- expr, type, fn_no_ptr);
+ error_at (loc, "%qE is not a valid template argument for type "
+ "%qT because %qD does not have external linkage",
+ expr, type, fn_no_ptr);
}
return NULL_TREE;
}
check_valid_ptrmem_cst_expr (tree type, tree expr,
tsubst_flags_t complain)
{
- location_t loc = cp_expr_loc_or_input_loc (expr);
tree orig_expr = expr;
STRIP_NOPS (expr);
if (null_ptr_cst_p (expr))
return true;
if (complain & tf_error)
{
+ location_t loc = cp_expr_loc_or_input_loc (orig_expr);
error_at (loc, "%qE is not a valid template argument for type %qT",
orig_expr, type);
if (TREE_CODE (expr) != PTRMEM_CST)
if (!VAR_P (decl))
{
if (complain & tf_error)
- error ("%qE is not a valid template argument of type %qT "
- "because %qE is not a variable", expr, type, decl);
+ error_at (cp_expr_loc_or_input_loc (expr),
+ "%qE is not a valid template argument of type %qT "
+ "because %qE is not a variable", expr, type, decl);
return true;
}
else if (cxx_dialect < cxx11 && !DECL_EXTERNAL_LINKAGE_P (decl))
{
if (complain & tf_error)
- error ("%qE is not a valid template argument of type %qT "
- "in C++98 because %qD does not have external linkage",
- expr, type, decl);
+ error_at (cp_expr_loc_or_input_loc (expr),
+ "%qE is not a valid template argument of type %qT "
+ "in C++98 because %qD does not have external linkage",
+ expr, type, decl);
return true;
}
else if ((cxx_dialect >= cxx11 && cxx_dialect < cxx17)
&& decl_linkage (decl) == lk_none)
{
if (complain & tf_error)
- error ("%qE is not a valid template argument of type %qT "
- "because %qD has no linkage", expr, type, decl);
+ error_at (cp_expr_loc_or_input_loc (expr),
+ "%qE is not a valid template argument of type %qT "
+ "because %qD has no linkage", expr, type, decl);
return true;
}
/* C++17: For a non-type template-parameter of reference or pointer
if (val == NULL_TREE)
val = error_mark_node;
else if (val == error_mark_node && (complain & tf_error))
- error ("could not convert template argument %qE from %qT to %qT",
- orig_arg, TREE_TYPE (orig_arg), t);
+ error_at (cp_expr_loc_or_input_loc (orig_arg),
+ "could not convert template argument %qE from %qT to %qT",
+ orig_arg, TREE_TYPE (orig_arg), t);
if (INDIRECT_REF_P (val))
{