xref: /aosp_15_r20/external/clang/test/FixIt/dereference-addressof.c (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li // RUN: %clang_cc1 -fsyntax-only -verify %s
2*67e74705SXin Li // RUN: cp %s %t
3*67e74705SXin Li // RUN: not %clang_cc1 -fsyntax-only -fixit -x c %t
4*67e74705SXin Li // RUN: %clang_cc1 -fsyntax-only -pedantic -x c %t
5*67e74705SXin Li 
ip(int * aPtr)6*67e74705SXin Li void ip(int *aPtr) {}   // expected-note{{passing argument to parameter 'aPtr' here}}
i(int a)7*67e74705SXin Li void i(int a) {}        // expected-note{{passing argument to parameter 'a' here}}
ii(int a)8*67e74705SXin Li void ii(int a) {}       // expected-note{{passing argument to parameter 'a' here}}
fp(float * aPtr)9*67e74705SXin Li void fp(float *aPtr) {} // expected-note{{passing argument to parameter 'aPtr' here}}
f(float a)10*67e74705SXin Li void f(float a) {}      // expected-note{{passing argument to parameter 'a' here}}
11*67e74705SXin Li 
f2(int * aPtr,int a,float * bPtr,char c)12*67e74705SXin Li void f2(int *aPtr, int a, float *bPtr, char c) {
13*67e74705SXin Li   float fl = 0;
14*67e74705SXin Li   ip(a);     // expected-warning{{incompatible integer to pointer conversion passing 'int' to parameter of type 'int *'; take the address with &}}
15*67e74705SXin Li   i(aPtr);   // expected-warning{{incompatible pointer to integer conversion passing 'int *' to parameter of type 'int'; dereference with *}}
16*67e74705SXin Li   ii(&a);     // expected-warning{{incompatible pointer to integer conversion passing 'int *' to parameter of type 'int'; remove &}}
17*67e74705SXin Li   fp(*bPtr); // expected-error{{passing 'float' to parameter of incompatible type 'float *'; remove *}}
18*67e74705SXin Li   f(bPtr);   // expected-error{{passing 'float *' to parameter of incompatible type 'float'; dereference with *}}
19*67e74705SXin Li   a = aPtr;  // expected-warning{{incompatible pointer to integer conversion assigning to 'int' from 'int *'; dereference with *}}
20*67e74705SXin Li   fl = bPtr + a;  // expected-error{{assigning to 'float' from incompatible type 'float *'; dereference with *}}
21*67e74705SXin Li   bPtr = bPtr[a]; // expected-error{{assigning to 'float *' from incompatible type 'float'; take the address with &}}
22*67e74705SXin Li }
23