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
This commit is contained in:
Richard Sandiford 2014-01-30 19:44:06 +00:00 committed by Richard Sandiford
parent bf53d4b89e
commit 35e519c484
2 changed files with 11 additions and 18 deletions

View File

@ -1,3 +1,8 @@
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

View File

@ -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);