Commit ad31c32a by Paolo Carlini Committed by Paolo Carlini

pt.c (convert_nontype_argument_function): Add tsubst_flags_t parameter.

2014-05-09  Paolo Carlini  <paolo.carlini@oracle.com>

	* pt.c (convert_nontype_argument_function): Add tsubst_flags_t
	parameter.
	(convert_nontype_argument): Adjust calls.
	(coerce_template_parameter_pack): Add missing complain & tf_error
	check.

From-SVN: r210289
parent e7eee636
2014-05-09 Paolo Carlini <paolo.carlini@oracle.com>
* pt.c (convert_nontype_argument_function): Add tsubst_flags_t
parameter.
(convert_nontype_argument): Adjust calls.
(coerce_template_parameter_pack): Add missing complain & tf_error
check.
2014-05-09 Jason Merrill <jason@redhat.com> 2014-05-09 Jason Merrill <jason@redhat.com>
DR 587 DR 587
......
...@@ -142,7 +142,7 @@ static int type_unification_real (tree, tree, tree, const tree *, ...@@ -142,7 +142,7 @@ static int type_unification_real (tree, tree, tree, const tree *,
vec<deferred_access_check, va_gc> **, vec<deferred_access_check, va_gc> **,
bool); bool);
static void note_template_header (int); static void note_template_header (int);
static tree convert_nontype_argument_function (tree, tree); static tree convert_nontype_argument_function (tree, tree, tsubst_flags_t);
static tree convert_nontype_argument (tree, tree, tsubst_flags_t); static tree convert_nontype_argument (tree, tree, tsubst_flags_t);
static tree convert_template_argument (tree, tree, tree, static tree convert_template_argument (tree, tree, tree,
tsubst_flags_t, int, tree); tsubst_flags_t, int, tree);
...@@ -5272,7 +5272,8 @@ get_underlying_template (tree tmpl) ...@@ -5272,7 +5272,8 @@ get_underlying_template (tree tmpl)
and check that the resulting function has external linkage. */ and check that the resulting function has external linkage. */
static tree static tree
convert_nontype_argument_function (tree type, tree expr) convert_nontype_argument_function (tree type, tree expr,
tsubst_flags_t complain)
{ {
tree fns = expr; tree fns = expr;
tree fn, fn_no_ptr; tree fn, fn_no_ptr;
...@@ -5298,25 +5299,34 @@ convert_nontype_argument_function (tree type, tree expr) ...@@ -5298,25 +5299,34 @@ convert_nontype_argument_function (tree type, tree expr)
if (TREE_CODE (fn_no_ptr) != FUNCTION_DECL) if (TREE_CODE (fn_no_ptr) != FUNCTION_DECL)
{ {
error ("%qE is not a valid template argument for type %qT", expr, type); if (complain & tf_error)
if (TYPE_PTR_P (type)) {
error ("it must be the address of a function with external linkage"); error ("%qE is not a valid template argument for type %qT",
else expr, type);
error ("it must be the name of a function with external linkage"); if (TYPE_PTR_P (type))
error ("it must be the address of a function with "
"external linkage");
else
error ("it must be the name of a function with "
"external linkage");
}
return NULL_TREE; return NULL_TREE;
} }
linkage = decl_linkage (fn_no_ptr); linkage = decl_linkage (fn_no_ptr);
if (cxx_dialect >= cxx11 ? linkage == lk_none : linkage != lk_external) if (cxx_dialect >= cxx11 ? linkage == lk_none : linkage != lk_external)
{ {
if (cxx_dialect >= cxx11) if (complain & tf_error)
error ("%qE is not a valid template argument for type %qT " {
"because %qD has no linkage", if (cxx_dialect >= cxx11)
expr, type, fn_no_ptr); error ("%qE is not a valid template argument for type %qT "
else "because %qD has no linkage",
error ("%qE is not a valid template argument for type %qT " expr, type, fn_no_ptr);
"because %qD does not have external linkage", else
expr, type, fn_no_ptr); error ("%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; return NULL_TREE;
} }
...@@ -5959,7 +5969,7 @@ convert_nontype_argument (tree type, tree expr, tsubst_flags_t complain) ...@@ -5959,7 +5969,7 @@ convert_nontype_argument (tree type, tree expr, tsubst_flags_t complain)
/* Null pointer values are OK in C++11. */ /* Null pointer values are OK in C++11. */
return perform_qualification_conversions (type, expr); return perform_qualification_conversions (type, expr);
expr = convert_nontype_argument_function (type, expr); expr = convert_nontype_argument_function (type, expr, complain);
if (!expr || expr == error_mark_node) if (!expr || expr == error_mark_node)
return expr; return expr;
} }
...@@ -5983,7 +5993,7 @@ convert_nontype_argument (tree type, tree expr, tsubst_flags_t complain) ...@@ -5983,7 +5993,7 @@ convert_nontype_argument (tree type, tree expr, tsubst_flags_t complain)
return NULL_TREE; return NULL_TREE;
} }
expr = convert_nontype_argument_function (type, expr); expr = convert_nontype_argument_function (type, expr, complain);
if (!expr || expr == error_mark_node) if (!expr || expr == error_mark_node)
return expr; return expr;
...@@ -6696,8 +6706,9 @@ coerce_template_parameter_pack (tree parms, ...@@ -6696,8 +6706,9 @@ coerce_template_parameter_pack (tree parms,
if (arg_idx - parm_idx < TREE_VEC_LENGTH (packed_args) if (arg_idx - parm_idx < TREE_VEC_LENGTH (packed_args)
&& TREE_VEC_LENGTH (packed_args) > 0) && TREE_VEC_LENGTH (packed_args) > 0)
{ {
error ("wrong number of template arguments (%d, should be %d)", if (complain & tf_error)
arg_idx - parm_idx, TREE_VEC_LENGTH (packed_args)); error ("wrong number of template arguments (%d, should be %d)",
arg_idx - parm_idx, TREE_VEC_LENGTH (packed_args));
return error_mark_node; return error_mark_node;
} }
......
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