1 // RUN: %clangxx -fsanitize=returns-nonnull-attribute -w %s -O3 -o %t
2 // RUN: %run %t foo 2>&1 | FileCheck %s --check-prefix=NOERROR --allow-empty --implicit-check-not='runtime error'
3 // RUN: %run %t 2>&1 | FileCheck %s
4 // RUN: %clangxx -fsanitize=returns-nonnull-attribute -fno-sanitize-recover=returns-nonnull-attribute -w %s -O3 -o %t.abort
5 // RUN: not %run %t.abort &> /dev/null
7 __attribute__((returns_nonnull
)) char *foo(char *a
);
10 // CHECK: nonnull.cpp:[[@LINE+2]]:3: runtime error: null pointer returned from function declared to never return null
11 // CHECK-NEXT: nonnull.cpp:[[@LINE-4]]:16: note: returns_nonnull attribute specified here
15 __attribute__((returns_nonnull
)) char *bar(int x
, char *a
) {
17 // CHECK: nonnull.cpp:[[@LINE+2]]:5: runtime error: null pointer returned from function declared to never return null
18 // CHECK-NEXT: nonnull.cpp:[[@LINE-3]]:16: note: returns_nonnull attribute specified here
21 // CHECK: nonnull.cpp:[[@LINE+2]]:5: runtime error: null pointer returned from function declared to never return null
22 // CHECK-NEXT: nonnull.cpp:[[@LINE-7]]:16: note: returns_nonnull attribute specified here
27 int main(int argc
, char **argv
) {
34 // We expect to see a runtime error the first time we cover the "else"...
37 // ... but not a second time.
38 // CHECK-NOT: runtime error
44 // NOERROR-NOT: runtime error