teak-llvm/clang/test/SemaObjC/argument-checking.m
Douglas Gregor 4f4946aaaa Whenever we complain about a failed initialization of a function or
method parameter, provide a note pointing at the parameter itself so
the user does not have to manually look for the function/method being
called and match up parameters to arguments. For example, we now get:

t.c:4:5: warning: incompatible pointer types passing 'long *' to
parameter of
      type 'int *' [-pedantic]
  f(long_ptr);
    ^~~~~~~~
t.c:1:13: note: passing argument to parameter 'x' here
void f(int *x);
            ^

llvm-svn: 102038
2010-04-22 00:20:18 +00:00

27 lines
1.1 KiB
Objective-C

// RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s
struct S { int a; };
extern int charStarFunc(char *); // expected-note{{passing argument to parameter here}}
extern int charFunc(char); // expected-note{{passing argument to parameter here}}
@interface Test
+alloc;
-(int)charStarMeth:(char *)s; // expected-note{{passing argument to parameter 's' here}}
-structMeth:(struct S)s; // expected-note{{passing argument to parameter 's' here}}
-structMeth:(struct S)s
:(struct S)s2; // expected-note{{passing argument to parameter 's2' here}}
@end
void test() {
id obj = [Test alloc];
struct S sInst;
charStarFunc(1); // expected-warning {{incompatible integer to pointer conversion passing 'int' to parameter of type 'char *'}}
charFunc("abc"); // expected-warning {{incompatible pointer to integer conversion passing 'char [4]' to parameter of type 'char'}}
[obj charStarMeth:1]; // expected-warning {{incompatible integer to pointer conversion sending 'int'}}
[obj structMeth:1]; // expected-error {{sending 'int'}}
[obj structMeth:sInst :1]; // expected-error {{sending 'int'}}
}