[analyzer] Add a test for PR13927 "offsetof replacement flagged as null deref"
authorJordan Rose <jordan_rose@apple.com>
Mon, 1 Oct 2012 19:07:19 +0000 (19:07 +0000)
committerJordan Rose <jordan_rose@apple.com>
Mon, 1 Oct 2012 19:07:19 +0000 (19:07 +0000)
This seems to be legal according to C11 6.5.3.2.

No functionality change.

llvm-svn: 164959

clang/test/Analysis/array-struct.c

index 223069f..c22f979 100644 (file)
@@ -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
+}
+