[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / Sema / warn-free-nonheap-object.c
bloba62e8ace7142ae922b51b5149ec3d2d31329784a
1 // RUN: %clang_cc1 -Wfree-nonheap-object -fsyntax-only -verify %s
3 typedef __SIZE_TYPE__ size_t;
4 void *malloc(size_t);
5 void free(void *);
7 struct S {
8 int I;
9 char *P;
12 int GI;
13 void test(void) {
15 free(&GI); // expected-warning {{attempt to call free on non-heap object 'GI'}}
18 static int SI = 0;
19 free(&SI); // expected-warning {{attempt to call free on non-heap object 'SI'}}
22 int I = 0;
23 free(&I); // expected-warning {{attempt to call free on non-heap object 'I'}}
26 int I = 0;
27 int *P = &I;
28 free(P); // FIXME diagnosing this would require control flow analysis.
31 void *P = malloc(8);
32 free(P);
35 int A[] = {0, 1, 2, 3};
36 free(A); // expected-warning {{attempt to call free on non-heap object 'A'}}
37 free(&A); // expected-warning {{attempt to call free on non-heap object 'A'}}
40 struct S s;
41 free(&s.I); // expected-warning {{attempt to call free on non-heap object 'I'}}
42 free(s.P);