Commit 817f9ef2 by James E Wilson Committed by Jim Wilson

Fix spurious warning for strstr (s, "").

* builtins.c (fold_builtin_strstr): Pass s1 through fold_convert before
returning it.
* gcc.dg/builtin-strstr.c: New.

From-SVN: r107206
parent 7b767e31
2005-11-18 James E Wilson <wilson@specifix.com>
* builtins.c (fold_builtin_strstr): Pass s1 through fold_convert before
returning it.
2005-11-18 Mike Stump <mrs@apple.com> 2005-11-18 Mike Stump <mrs@apple.com>
* c-common.c (handle_cleanup_attribute): Use a lang hook for lookup_name. * c-common.c (handle_cleanup_attribute): Use a lang hook for lookup_name.
......
...@@ -9199,8 +9199,10 @@ fold_builtin_strstr (tree arglist, tree type) ...@@ -9199,8 +9199,10 @@ fold_builtin_strstr (tree arglist, tree type)
return fold_convert (type, tem); return fold_convert (type, tem);
} }
/* The argument is const char *, and the result is char *, so we need
a type conversion here to avoid a warning. */
if (p2[0] == '\0') if (p2[0] == '\0')
return s1; return fold_convert (type, s1);
if (p2[1] != '\0') if (p2[1] != '\0')
return 0; return 0;
......
2005-11-18 James E Wilson <wilson@specifix.com>
* gcc.dg/builtin-strstr.c: New.
2005-11-18 Richard Henderson <rth@redhat.com> 2005-11-18 Richard Henderson <rth@redhat.com>
* gcc.target/ia64/20010423-1.c, gcc.target/ia64/20020313-1.c, * gcc.target/ia64/20010423-1.c, gcc.target/ia64/20020313-1.c,
/* The strstr call is expanded to just "s", which should not result in a
warning about discarding qualifiers in an assignment. */
/* { dg-do compile } */
extern char * strstr (const char *s1, const char * s2);
void foo(const char *s){
char * cp;
cp = strstr(s, "");
}
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