Add a reproducer in the test of a current issue for Baozeng to look into.
This happens probably because we don't iterate over the redecl chains and thus we don't pickup the attribute.
This commit is contained in:
parent
d6b9cd9b0c
commit
452e98bf46
@ -1,8 +1,30 @@
|
||||
// RUN: cat %s | %cling -Xclang -verify
|
||||
// RUN: cat %s | %cling -Xclang -verify | FileCheck %s
|
||||
//This file checks a call instruction. The called function has arguments with nonnull attribute.
|
||||
// XFAIL: *
|
||||
#include <string.h>
|
||||
char *p;
|
||||
strcmp("a", p); // expected-warning {{you are about to dereference null ptr, which probably will lead to seg violation. Do you want to proceed?[y/n]}}
|
||||
char *p = 0;
|
||||
//strcmp("a", p); // expected-warning {{you are about to dereference null ptr, which probably will lead to seg violation. Do you want to proceed?[y/n]}}
|
||||
|
||||
//strcmp(p, "a"); // expected-warning {{you are about to dereference null ptr, which probably will lead to seg violation. Do you want to proceed?[y/n]}}
|
||||
|
||||
extern "C" int printf(const char* fmt, ...);
|
||||
.rawInput 1
|
||||
extern "C" int cannotCallWithNull(int* p = 0);
|
||||
extern "C" int cannotCallWithNull(int* p) __attribute__((nonnull(1)));
|
||||
extern "C" int cannotCallWithNull(int* p);
|
||||
extern "C" int cannotCallWithNull(int* p);
|
||||
.rawInput 0
|
||||
|
||||
extern "C" int cannotCallWithNull(int* p) {
|
||||
if (!p)
|
||||
printf("Must not be called with p=0.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
cannotCallWithNull() // warning-expected {{null passed to a callee which requires a non-null argument}}
|
||||
//CHECK-NOT: Must not be called with p=0.
|
||||
//CHECK: (int) 1
|
||||
|
||||
|
||||
|
||||
strcmp(p, "a"); // expected-warning {{you are about to dereference null ptr, which probably will lead to seg violation. Do you want to proceed?[y/n]}}
|
||||
.q
|
||||
|
Loading…
x
Reference in New Issue
Block a user