Commit a663ce5a by Jason Merrill Committed by Jason Merrill

re PR c++/63658 (Using class reference as template parameter causes compilation to fail)

	PR c++/63658
	* pt.c (convert_nontype_argument): Call convert_from_reference.
	(check_instantiated_arg): Don't be confused by reference refs.
	(unify): Look through reference refs on the arg, too.
	* mangle.c (write_template_arg): Look through reference refs.

From-SVN: r217900
parent e4c4792d
2014-11-20 Jason Merrill <jason@redhat.com> 2014-11-20 Jason Merrill <jason@redhat.com>
PR c++/63658
* pt.c (convert_nontype_argument): Call convert_from_reference.
(check_instantiated_arg): Don't be confused by reference refs.
(unify): Look through reference refs on the arg, too.
* mangle.c (write_template_arg): Look through reference refs.
* error.c (dump_expr): Avoid printing (*&i) for references. * error.c (dump_expr): Avoid printing (*&i) for references.
2014-11-20 Ville Voutilainen <ville.voutilainen@gmail.com> 2014-11-20 Ville Voutilainen <ville.voutilainen@gmail.com>
......
...@@ -3086,6 +3086,8 @@ write_template_arg (tree node) ...@@ -3086,6 +3086,8 @@ write_template_arg (tree node)
} }
} }
if (REFERENCE_REF_P (node))
node = TREE_OPERAND (node, 0);
if (TREE_CODE (node) == NOP_EXPR if (TREE_CODE (node) == NOP_EXPR
&& TREE_CODE (TREE_TYPE (node)) == REFERENCE_TYPE) && TREE_CODE (TREE_TYPE (node)) == REFERENCE_TYPE)
{ {
......
...@@ -6174,7 +6174,7 @@ convert_nontype_argument (tree type, tree expr, tsubst_flags_t complain) ...@@ -6174,7 +6174,7 @@ convert_nontype_argument (tree type, tree expr, tsubst_flags_t complain)
right type? */ right type? */
gcc_assert (same_type_ignoring_top_level_qualifiers_p gcc_assert (same_type_ignoring_top_level_qualifiers_p
(type, TREE_TYPE (expr))); (type, TREE_TYPE (expr)));
return expr; return convert_from_reference (expr);
} }
/* Subroutine of coerce_template_template_parms, which returns 1 if /* Subroutine of coerce_template_template_parms, which returns 1 if
...@@ -15740,6 +15740,7 @@ check_instantiated_arg (tree tmpl, tree t, tsubst_flags_t complain) ...@@ -15740,6 +15740,7 @@ check_instantiated_arg (tree tmpl, tree t, tsubst_flags_t complain)
constant. */ constant. */
else if (TREE_TYPE (t) else if (TREE_TYPE (t)
&& INTEGRAL_OR_ENUMERATION_TYPE_P (TREE_TYPE (t)) && INTEGRAL_OR_ENUMERATION_TYPE_P (TREE_TYPE (t))
&& !REFERENCE_REF_P (t)
&& !TREE_CONSTANT (t)) && !TREE_CONSTANT (t))
{ {
if (complain & tf_error) if (complain & tf_error)
...@@ -18473,8 +18474,12 @@ unify (tree tparms, tree targs, tree parm, tree arg, int strict, ...@@ -18473,8 +18474,12 @@ unify (tree tparms, tree targs, tree parm, tree arg, int strict,
case INDIRECT_REF: case INDIRECT_REF:
if (REFERENCE_REF_P (parm)) if (REFERENCE_REF_P (parm))
return unify (tparms, targs, TREE_OPERAND (parm, 0), arg, {
strict, explain_p); if (REFERENCE_REF_P (arg))
arg = TREE_OPERAND (arg, 0);
return unify (tparms, targs, TREE_OPERAND (parm, 0), arg,
strict, explain_p);
}
/* FALLTHRU */ /* FALLTHRU */
default: default:
......
// PR c++/63658
struct Descriptor {};
template <Descriptor & D>
struct foo
{
void size ();
};
Descriptor g_descriptor = {};
template<> void foo<g_descriptor>::size()
{
}
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