diff options
author | Martin Sebor <msebor@redhat.com> | 2019-04-04 22:38:10 +0000 |
---|---|---|
committer | Martin Sebor <msebor@gcc.gnu.org> | 2019-04-04 16:38:10 -0600 |
commit | 1a9b15a7d76ee3ee2cd960698a84e34ec10c2bf0 (patch) | |
tree | b55605cb740d88748c0349945fe87a7b06634d12 /gcc/testsuite/gcc.dg/Wstringop-overflow-13.c | |
parent | 9a0cbb60d28042893135cee60ad28a48a7e2235d (diff) | |
download | gcc-1a9b15a7d76ee3ee2cd960698a84e34ec10c2bf0.zip gcc-1a9b15a7d76ee3ee2cd960698a84e34ec10c2bf0.tar.gz gcc-1a9b15a7d76ee3ee2cd960698a84e34ec10c2bf0.tar.bz2 |
PR middle-end/89957 - ICE calling strnlen with an int128_t bound in a known range
PR middle-end/89957 - ICE calling strnlen with an int128_t bound in a known range
PR middle-end/89911 - [9 Regression] ICE in get_attr_nonstring_decl
gcc/ChangeLog:
PR middle-end/89957
PR middle-end/89911
* builtins.c (expand_builtin_strnlen): Make sure wi::ltu_p operands
have the same precision since the function crashes otherwise.
* calls.c (maybe_warn_nonstring_arg): Avoid assuming strnlen() call
has non-zero arguments.
gcc/testsuite/ChangeLog:
PR middle-end/89957
PR middle-end/89911
* gcc.dg/Wstringop-overflow-13.c: New test.
From-SVN: r270154
Diffstat (limited to 'gcc/testsuite/gcc.dg/Wstringop-overflow-13.c')
-rw-r--r-- | gcc/testsuite/gcc.dg/Wstringop-overflow-13.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/Wstringop-overflow-13.c b/gcc/testsuite/gcc.dg/Wstringop-overflow-13.c new file mode 100644 index 0000000..bd51315 --- /dev/null +++ b/gcc/testsuite/gcc.dg/Wstringop-overflow-13.c @@ -0,0 +1,40 @@ +/* PR middle-end/89957 - ICE calling strnlen with an int128_t bound + in a known range + PR middle-end/89911 - ICE on a call with no arguments to strnlen + declared with no prototype + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +typedef __SIZE_TYPE__ size_t; + +extern size_t strnlen (); + +size_t f0 (void) +{ + return strnlen (); /* { dg-warning "too few arguments to built-in function 'strnlen'" } */ +} + +size_t f1 (const char *s) +{ + return strnlen (s); /* { dg-warning "too few arguments to built-in function 'strnlen'" } */ +} + +size_t f2 (const char *s) +{ + return strnlen (s, s); /* { dg-warning "\\\[-Wint-conversion]" } */ +} + +#if __SIZEOF_INT128__ == 16 + +size_t fi128 (const char *s, __int128_t n) +{ + if (n < 0) + n = 0; + + /* PR middle-end/89957 */ + return strnlen (s, n); /* { dg-warning "\\\[-Wbuiltin-declaration-mismatch]" "int128" { target int128 } } */ +} + +#endif + +/* { dg-prune-output "\\\[-Wint-conversion]" } */ |