Commit 35e519c4 by Richard Sandiford Committed by Richard Sandiford

re PR c++/58708 (string literal operator templates broken)

gcc/cp/
	PR c++/58708
	* parser.c (make_string_pack): Use double_int::from_buffer.

From-SVN: r207320
parent bf53d4b8
2014-01-30 Richard Sandiford <rdsandiford@googlemail.com>
PR c++/58708
* parser.c (make_string_pack): Use double_int::from_buffer.
2014-01-30 Marek Polacek <polacek@redhat.com>
PR c/59940
......
......@@ -3808,7 +3808,8 @@ make_string_pack (tree value)
{
tree charvec;
tree argpack = make_node (NONTYPE_ARGUMENT_PACK);
const char *str = TREE_STRING_POINTER (value);
const unsigned char *str
= (const unsigned char *) TREE_STRING_POINTER (value);
int sz = TREE_INT_CST_LOW (TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (value))));
int len = TREE_STRING_LENGTH (value) / sz - 1;
tree argvec = make_tree_vec (2);
......@@ -3821,23 +3822,10 @@ make_string_pack (tree value)
/* Fill in CHARVEC with all of the parameters. */
charvec = make_tree_vec (len);
if (sz == 1)
{
for (int i = 0; i < len; ++i)
TREE_VEC_ELT (charvec, i) = build_int_cst (str_char_type_node, str[i]);
}
else if (sz == 2)
{
const uint16_t *num = (const uint16_t *)str;
for (int i = 0; i < len; ++i)
TREE_VEC_ELT (charvec, i) = build_int_cst (str_char_type_node, num[i]);
}
else if (sz == 4)
{
const uint32_t *num = (const uint32_t *)str;
for (int i = 0; i < len; ++i)
TREE_VEC_ELT (charvec, i) = build_int_cst (str_char_type_node, num[i]);
}
for (int i = 0; i < len; ++i)
TREE_VEC_ELT (charvec, i)
= double_int_to_tree (str_char_type_node,
double_int::from_buffer (str + i * sz, sz));
/* Build the argument packs. */
SET_ARGUMENT_PACK_ARGS (argpack, charvec);
......
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