From 35dddc5327d6d188da70a786105a796ffe201665 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Thu, 22 Dec 2016 12:48:39 +0100 Subject: [PATCH] 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 --- gcc/testsuite/ChangeLog | 6 ++++++ gcc/testsuite/c-c++-common/ubsan/pr78858.c | 10 ++++++++++ gcc/testsuite/gcc.dg/nonnull-5.c | 11 +++++++++++ 3 files changed, 27 insertions(+) create mode 100644 gcc/testsuite/c-c++-common/ubsan/pr78858.c create mode 100644 gcc/testsuite/gcc.dg/nonnull-5.c 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" } */ +} -- 2.30.2