1 // RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=region -analyzer-experimental-checks -fblocks -verify %s
6 free(a
); // expected-warning {{Argument to free() is the address of the local variable 'a', which is not memory allocated by malloc()}}
11 free(&a
); // expected-warning {{Argument to free() is the address of the local variable 'a', which is not memory allocated by malloc()}}
15 static int a
[] = { 1 };
16 free(a
); // expected-warning {{Argument to free() is the address of the static variable 'a', which is not memory allocated by malloc()}}
20 free(x
); // no-warning
25 free(ptr()); // no-warning
29 free((void*)1000); // expected-warning {{Argument to free() is a constant address (1000), which is not memory allocated by malloc()}}
33 free(*x
); // no-warning
38 free((*x
)+8); // no-warning
43 free(&&label
); // expected-warning {{Argument to free() is the address of the label 'label', which is not memory allocated by malloc()}}
47 free((void*)&t10
); // expected-warning {{Argument to free() is the address of the function 't10', which is not memory allocated by malloc()}}
51 char *p
= (char*)__builtin_alloca(2);
52 free(p
); // expected-warning {{Argument to free() was allocated by alloca(), not malloc()}}
56 free(^{return;}); // expected-warning {{Argument to free() is a block, which is not memory allocated by malloc()}}
60 free(&a
); // expected-warning {{Argument to free() is the address of the parameter 'a', which is not memory allocated by malloc()}}
63 static int someGlobal
[2];
65 free(someGlobal
); // expected-warning {{Argument to free() is the address of the global variable 'someGlobal', which is not memory allocated by malloc()}}
68 void t15 (char **x
, int offset
) {
70 free(x
[offset
]); // no-warning