diff options
Diffstat (limited to 'compiler-rt/test/ubsan/TestCases/Misc/nonnull.cpp')
| -rw-r--r-- | compiler-rt/test/ubsan/TestCases/Misc/nonnull.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/compiler-rt/test/ubsan/TestCases/Misc/nonnull.cpp b/compiler-rt/test/ubsan/TestCases/Misc/nonnull.cpp new file mode 100644 index 00000000000..8b5fcaf43bf --- /dev/null +++ b/compiler-rt/test/ubsan/TestCases/Misc/nonnull.cpp @@ -0,0 +1,13 @@ +// RUN: %clangxx -fsanitize=returns-nonnull-attribute %s -O3 -o %t +// RUN: %run %t foo +// RUN: %run %t 2>&1 | FileCheck %s + +__attribute__((returns_nonnull)) +char *foo(char *a) { + return a; + // CHECK: nonnull.cpp:[[@LINE+1]]:1: runtime error: null pointer returned from function declared to never return null +} + +int main(int argc, char **argv) { + return foo(argv[1]) == 0; +} |

