From: Jakub Jelinek Date: Thu, 22 Dec 2016 11:48:39 +0000 (+0100) Subject: re PR middle-end/78858 (Bogus -Wnonnull warning involving strcmp with -fsanitize... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=35dddc5327d6d188da70a786105a796ffe201665;p=gcc.git re PR middle-end/78858 (Bogus -Wnonnull warning involving strcmp with -fsanitize=undefined) PR middle-end/78858 * c-c++-common/ubsan/pr78858.c: New test. * gcc.dg/nonnull-5.c: New test. From-SVN: r243884 --- diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3a704c58537..33908d5e803 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2016-12-22 Jakub Jelinek + + PR middle-end/78858 + * c-c++-common/ubsan/pr78858.c: New test. + * gcc.dg/nonnull-5.c: New test. + 2016-12-21 Jakub Jelinek PR c++/72707 diff --git a/gcc/testsuite/c-c++-common/ubsan/pr78858.c b/gcc/testsuite/c-c++-common/ubsan/pr78858.c new file mode 100644 index 00000000000..ad0af42caca --- /dev/null +++ b/gcc/testsuite/c-c++-common/ubsan/pr78858.c @@ -0,0 +1,10 @@ +/* PR middle-end/78858 */ +/* { dg-do compile } */ +/* { dg-options "-fsanitize=undefined -Wnonnull" } */ + +void +foo (char **x, const char *y) +{ + *x = (char *) __builtin_malloc (__builtin_strlen (y) + 1); /* { dg-bogus "argument 1 null where non-null expected" } */ + __builtin_strcpy (*x, y); +} diff --git a/gcc/testsuite/gcc.dg/nonnull-5.c b/gcc/testsuite/gcc.dg/nonnull-5.c new file mode 100644 index 00000000000..ba52fe3dbce --- /dev/null +++ b/gcc/testsuite/gcc.dg/nonnull-5.c @@ -0,0 +1,11 @@ +/* Reduced from https://sourceware.org/bugzilla/show_bug.cgi?id=20978 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wnonnull" } */ + +int +foo (const char *name) +{ + if (name) + return 6; + return __builtin_strlen (name); /* { dg-warning "argument 1 null where non-null expected" } */ +}