xref: /minix3/external/bsd/llvm/dist/clang/test/SemaObjC/argument-checking.m (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc// RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s
2*f4a2713aSLionel Sambuc
3*f4a2713aSLionel Sambucstruct S { int a; };
4*f4a2713aSLionel Sambuc
5*f4a2713aSLionel Sambucextern int charStarFunc(char *); // expected-note{{passing argument to parameter here}}
6*f4a2713aSLionel Sambucextern int charFunc(char); // expected-note{{passing argument to parameter here}}
7*f4a2713aSLionel Sambuc
8*f4a2713aSLionel Sambuc@interface Test
9*f4a2713aSLionel Sambuc+alloc;
10*f4a2713aSLionel Sambuc-(int)charStarMeth:(char *)s; // expected-note{{passing argument to parameter 's' here}}
11*f4a2713aSLionel Sambuc-structMeth:(struct S)s; // expected-note{{passing argument to parameter 's' here}}
12*f4a2713aSLionel Sambuc-structMeth:(struct S)s
13*f4a2713aSLionel Sambuc   :(struct S)s2; // expected-note{{passing argument to parameter 's2' here}}
14*f4a2713aSLionel Sambuc@end
15*f4a2713aSLionel Sambuc
16*f4a2713aSLionel Sambucvoid test() {
17*f4a2713aSLionel Sambuc  id obj = [Test alloc];
18*f4a2713aSLionel Sambuc  struct S sInst;
19*f4a2713aSLionel Sambuc
20*f4a2713aSLionel Sambuc  charStarFunc(1); // expected-warning {{incompatible integer to pointer conversion passing 'int' to parameter of type 'char *'}}
21*f4a2713aSLionel Sambuc  charFunc("abc"); // expected-warning {{incompatible pointer to integer conversion passing 'char [4]' to parameter of type 'char'}}
22*f4a2713aSLionel Sambuc
23*f4a2713aSLionel Sambuc  [obj charStarMeth:1]; // expected-warning {{incompatible integer to pointer conversion sending 'int'}}
24*f4a2713aSLionel Sambuc  [obj structMeth:1]; // expected-error {{sending 'int'}}
25*f4a2713aSLionel Sambuc  [obj structMeth:sInst :1]; // expected-error {{sending 'int'}}
26*f4a2713aSLionel Sambuc}
27