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
+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
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
--- /dev/null
+/* 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;
+}