Commit 918f238e by Dodji Seketeli Committed by Jason Merrill

re PR c++/47705 (internal compiler error: in convert_nontype_argument, at cp/pt.c:5006)

	PR c++/47705
	* pt.c (convert_nontype_argument): Only call decay_conversion on
	arrays.

From-SVN: r170791
parent ef78aed6
2011-03-08 Dodji Seketeli <dodji@redhat.com>
PR c++/47705
* pt.c (convert_nontype_argument): Only call decay_conversion on
arrays.
2011-03-08 Jason Merrill <jason@redhat.com> 2011-03-08 Jason Merrill <jason@redhat.com>
PR c++/47488 PR c++/47488
......
...@@ -5314,7 +5314,8 @@ convert_nontype_argument (tree type, tree expr, tsubst_flags_t complain) ...@@ -5314,7 +5314,8 @@ convert_nontype_argument (tree type, tree expr, tsubst_flags_t complain)
/* Add the ADDR_EXPR now for the benefit of /* Add the ADDR_EXPR now for the benefit of
value_dependent_expression_p. */ value_dependent_expression_p. */
if (TYPE_PTROBV_P (type)) if (TYPE_PTROBV_P (type)
&& TREE_CODE (TREE_TYPE (expr)) == ARRAY_TYPE)
expr = decay_conversion (expr); expr = decay_conversion (expr);
/* If we are in a template, EXPR may be non-dependent, but still /* If we are in a template, EXPR may be non-dependent, but still
...@@ -5369,22 +5370,17 @@ convert_nontype_argument (tree type, tree expr, tsubst_flags_t complain) ...@@ -5369,22 +5370,17 @@ convert_nontype_argument (tree type, tree expr, tsubst_flags_t complain)
qualification conversion. Let's strip everything. */ qualification conversion. Let's strip everything. */
else if (TYPE_PTROBV_P (type)) else if (TYPE_PTROBV_P (type))
{ {
tree sub = expr; STRIP_NOPS (expr);
STRIP_NOPS (sub); gcc_assert (TREE_CODE (expr) == ADDR_EXPR);
if (TREE_CODE (sub) == ADDR_EXPR) gcc_assert (TREE_CODE (TREE_TYPE (expr)) == POINTER_TYPE);
{
gcc_assert (TREE_CODE (TREE_TYPE (sub)) == POINTER_TYPE);
/* Skip the ADDR_EXPR only if it is part of the decay for /* Skip the ADDR_EXPR only if it is part of the decay for
an array. Otherwise, it is part of the original argument an array. Otherwise, it is part of the original argument
in the source code. */ in the source code. */
if (TREE_CODE (TREE_TYPE (TREE_OPERAND (sub, 0))) == ARRAY_TYPE) if (TREE_CODE (TREE_TYPE (TREE_OPERAND (expr, 0))) == ARRAY_TYPE)
expr = TREE_OPERAND (sub, 0); expr = TREE_OPERAND (expr, 0);
else
expr = sub;
expr_type = TREE_TYPE (expr); expr_type = TREE_TYPE (expr);
} }
} }
}
/* [temp.arg.nontype]/5, bullet 1 /* [temp.arg.nontype]/5, bullet 1
......
...@@ -4,4 +4,4 @@ template<char const * const x> class Something { }; ...@@ -4,4 +4,4 @@ template<char const * const x> class Something { };
extern char const xyz; extern char const xyz;
class SomethingElse:public Something<xyz> { }; // { dg-error "const char *" } class SomethingElse:public Something<xyz> { }; // { dg-error "xyz. is a variable" }
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