From: Dodji Seketeli Date: Tue, 8 Mar 2011 22:02:59 +0000 (+0000) Subject: re PR c++/47705 (internal compiler error: in convert_nontype_argument, at cp/pt.c... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=918f238e7f736ee291d76e77fcefdaee761bf167;p=gcc.git 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 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index ab0d3b4b565..68f04e15eac 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2011-03-08 Dodji Seketeli + + PR c++/47705 + * pt.c (convert_nontype_argument): Only call decay_conversion on + arrays. + 2011-03-08 Jason Merrill PR c++/47488 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index cda9df8d1be..2ca2cd0c0c2 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -5314,7 +5314,8 @@ convert_nontype_argument (tree type, tree expr, tsubst_flags_t complain) /* Add the ADDR_EXPR now for the benefit of 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); /* If we are in a template, EXPR may be non-dependent, but still @@ -5369,20 +5370,15 @@ convert_nontype_argument (tree type, tree expr, tsubst_flags_t complain) qualification conversion. Let's strip everything. */ else if (TYPE_PTROBV_P (type)) { - tree sub = expr; - STRIP_NOPS (sub); - if (TREE_CODE (sub) == ADDR_EXPR) - { - gcc_assert (TREE_CODE (TREE_TYPE (sub)) == POINTER_TYPE); - /* Skip the ADDR_EXPR only if it is part of the decay for - an array. Otherwise, it is part of the original argument - in the source code. */ - if (TREE_CODE (TREE_TYPE (TREE_OPERAND (sub, 0))) == ARRAY_TYPE) - expr = TREE_OPERAND (sub, 0); - else - expr = sub; - expr_type = TREE_TYPE (expr); - } + STRIP_NOPS (expr); + gcc_assert (TREE_CODE (expr) == ADDR_EXPR); + gcc_assert (TREE_CODE (TREE_TYPE (expr)) == POINTER_TYPE); + /* Skip the ADDR_EXPR only if it is part of the decay for + an array. Otherwise, it is part of the original argument + in the source code. */ + if (TREE_CODE (TREE_TYPE (TREE_OPERAND (expr, 0))) == ARRAY_TYPE) + expr = TREE_OPERAND (expr, 0); + expr_type = TREE_TYPE (expr); } } diff --git a/gcc/testsuite/g++.dg/template/nontype21.C b/gcc/testsuite/g++.dg/template/nontype21.C index c0f53199b1b..69cab54f412 100644 --- a/gcc/testsuite/g++.dg/template/nontype21.C +++ b/gcc/testsuite/g++.dg/template/nontype21.C @@ -4,4 +4,4 @@ template class Something { }; extern char const xyz; -class SomethingElse:public Something { }; // { dg-error "const char *" } +class SomethingElse:public Something { }; // { dg-error "xyz. is a variable" }