Commit a8ed1cbd by Jakub Jelinek Committed by Jakub Jelinek

re PR c/84953 (misleading warning from strpbrk(x,""))

	PR c/84953
	* builtins.c (fold_builtin_strpbrk): For strpbrk(x, "") use type
	instead of TREE_TYPE (s1) for the return value.

	* gcc.dg/pr84953.c: New test.

From-SVN: r258671
parent d2a1b11e
2018-03-20 Jakub Jelinek <jakub@redhat.com>
PR c/84953
* builtins.c (fold_builtin_strpbrk): For strpbrk(x, "") use type
instead of TREE_TYPE (s1) for the return value.
2018-03-19 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/84946
......
......@@ -9573,7 +9573,7 @@ fold_builtin_strpbrk (location_t loc, tree s1, tree s2, tree type)
if (p2[0] == '\0')
/* strpbrk(x, "") == NULL.
Evaluate and ignore s1 in case it had side-effects. */
return omit_one_operand_loc (loc, TREE_TYPE (s1), integer_zero_node, s1);
return omit_one_operand_loc (loc, type, integer_zero_node, s1);
if (p2[1] != '\0')
return NULL_TREE; /* Really call strpbrk. */
......
2018-03-20 Jakub Jelinek <jakub@redhat.com>
PR c/84953
* gcc.dg/pr84953.c: New test.
2018-03-19 Marek Polacek <polacek@redhat.com>
PR c++/84925
......
/* PR c/84953 */
/* { dg-do compile } */
char *strpbrk (const char *, const char *);
char *
test (char *p)
{
p = strpbrk (p, ""); /* { dg-bogus "assignment discards 'const' qualifier from pointer target type" } */
return p;
}
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