PR tree-optimization/99489 - ICE calling strncat after strcat
gcc/ChangeLog: PR tree-optimization/99489 * builtins.c (gimple_call_alloc_size): Fail gracefully when argument is not a call statement. gcc/testsuite/ChangeLog: PR tree-optimization/99489 * gcc.dg/Wstringop-truncation-9.c: New test.
This commit is contained in:
parent
7987beec67
commit
77643ac4bb
2 changed files with 42 additions and 1 deletions
|
@ -4924,7 +4924,7 @@ tree
|
|||
gimple_call_alloc_size (gimple *stmt, wide_int rng1[2] /* = NULL */,
|
||||
range_query * /* = NULL */)
|
||||
{
|
||||
if (!stmt)
|
||||
if (!stmt || !is_gimple_call (stmt))
|
||||
return NULL_TREE;
|
||||
|
||||
tree allocfntype;
|
||||
|
|
41
gcc/testsuite/gcc.dg/Wstringop-truncation-9.c
Normal file
41
gcc/testsuite/gcc.dg/Wstringop-truncation-9.c
Normal file
|
@ -0,0 +1,41 @@
|
|||
/* PR tree-optimization/99489 - ICE calling strncat after strncat
|
||||
{ dg-do compile }
|
||||
{ dg-options "-O2 -Wall" } */
|
||||
|
||||
// Important -- see pr82429.
|
||||
char *stpcpy (char *, const char *);
|
||||
|
||||
void fchar (char *d, char c, char *s)
|
||||
{
|
||||
__builtin_strcat (d, s);
|
||||
__builtin_strncat (d, &c, 1);
|
||||
}
|
||||
|
||||
void fcstchar (char *d, char *s)
|
||||
{
|
||||
__builtin_strcat (d, s);
|
||||
|
||||
const char c = 'x';
|
||||
__builtin_strncat (d, &c, 1); // { dg-warning "-Wstringop-truncation" }
|
||||
}
|
||||
|
||||
void fstr (char *d, char *s)
|
||||
{
|
||||
__builtin_strcat (d, s);
|
||||
__builtin_strncat (d, s, 1);
|
||||
}
|
||||
|
||||
void farr (char *d, char *s)
|
||||
{
|
||||
__builtin_strcat (d, s);
|
||||
|
||||
char a[] = "x";
|
||||
__builtin_strncat (d, a, 1); // { dg-warning "-Wstringop-truncation" }
|
||||
}
|
||||
|
||||
void flit (char *d, char *s)
|
||||
{
|
||||
__builtin_strcat (d, s);
|
||||
__builtin_strncat (d, "x", 1); // { dg-warning "-Wstringop-truncation" "pr?????" { xfail *-*-*} }
|
||||
// { dg-warning "-Wstringop-overflow" "actual" { target *-*-*} .-1 }
|
||||
}
|
Loading…
Add table
Reference in a new issue