From: Jordan Rose Date: Mon, 1 Oct 2012 19:07:19 +0000 (+0000) Subject: [analyzer] Add a test for PR13927 "offsetof replacement flagged as null deref" X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=75c5e6df52e055537cf92687cf80fe644233381f;p=clang [analyzer] Add a test for PR13927 "offsetof replacement flagged as null deref" This seems to be legal according to C11 6.5.3.2. No functionality change. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164959 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/test/Analysis/array-struct.c b/test/Analysis/array-struct.c index 223069f925..c22f9796e5 100644 --- a/test/Analysis/array-struct.c +++ b/test/Analysis/array-struct.c @@ -175,3 +175,11 @@ void f18() { if (*q) { // no-warning } } + + +// [PR13927] offsetof replacement macro flagged as "dereference of a null pointer" +int offset_of_data_array(void) +{ + return ((char *)&(((struct s*)0)->data_array)) - ((char *)0); // no-warning +} +