Home | History | Annotate | Download | only in Misc
      1 // RUN: %clangxx -fsanitize=returns-nonnull-attribute %s -O3 -o %t
      2 // RUN: %run %t foo
      3 // RUN: %run %t 2>&1 | FileCheck %s
      4 
      5 __attribute__((returns_nonnull)) char *foo(char *a);
      6 
      7 char *foo(char *a) {
      8   return a;
      9   // CHECK: nonnull.cpp:[[@LINE+2]]:1: runtime error: null pointer returned from function declared to never return null
     10   // CHECK-NEXT: nonnull.cpp:[[@LINE-5]]:16: note: returns_nonnull attribute specified here
     11 }
     12 
     13 int main(int argc, char **argv) {
     14   return foo(argv[1]) == 0;
     15 }
     16