aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/pt.c
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2013-03-16 22:35:50 -0400
committerJason Merrill <jason@gcc.gnu.org>2013-03-16 22:35:50 -0400
commitcb3c050e515c697b2b69991ce9c7a770e301ac92 (patch)
treebedb10e1b691f963066dbf55eb220bb3a023c5c7 /gcc/cp/pt.c
parente9f3968bbe670a0b54516a29ca9ffb7c79c6cb20 (diff)
downloadgcc-cb3c050e515c697b2b69991ce9c7a770e301ac92.zip
gcc-cb3c050e515c697b2b69991ce9c7a770e301ac92.tar.gz
gcc-cb3c050e515c697b2b69991ce9c7a770e301ac92.tar.bz2
re PR c++/54946 (ICE on template parameter from cast char-pointer in C++11 constexpr struct)
PR c++/54946 * pt.c (convert_nontype_argument): Handle invalid pointer. From-SVN: r196731
Diffstat (limited to 'gcc/cp/pt.c')
-rw-r--r--gcc/cp/pt.c29
1 files changed, 20 insertions, 9 deletions
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 126e110..c07ed32 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -5553,15 +5553,19 @@ convert_nontype_argument (tree type, tree expr, tsubst_flags_t complain)
qualification conversion. Let's strip everything. */
else if (TREE_CODE (expr) == NOP_EXPR && TYPE_PTROBV_P (type))
{
- 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);
+ tree probe = expr;
+ STRIP_NOPS (probe);
+ if (TREE_CODE (probe) == ADDR_EXPR
+ && TREE_CODE (TREE_TYPE (probe)) == 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 (probe, 0))) == ARRAY_TYPE)
+ probe = TREE_OPERAND (probe, 0);
+ expr = probe;
+ expr_type = TREE_TYPE (expr);
+ }
}
/* [temp.arg.nontype]/5, bullet 1
@@ -5640,6 +5644,13 @@ convert_nontype_argument (tree type, tree expr, tsubst_flags_t complain)
expr, expr);
return NULL_TREE;
}
+ if (POINTER_TYPE_P (expr_type))
+ {
+ error ("%qE is not a valid template argument for %qT"
+ "because it is not the address of a variable",
+ expr, type);
+ return NULL_TREE;
+ }
/* Other values, like integer constants, might be valid
non-type arguments of some other type. */
return error_mark_node;