aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-04-22 00:20:18 +0000
committerDouglas Gregor <dgregor@apple.com>2010-04-22 00:20:18 +0000
commita41a8c5972c2632247ae7913cf6ce65d45f7e702 (patch)
tree227fcd37c3bb59135e62dd3457712b93bb225cd4
parent128317e6a0b020966f7392aa850b24cfe43bc163 (diff)
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); ^ git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102038 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/Basic/DiagnosticSemaKinds.td5
-rw-r--r--lib/Sema/Sema.h3
-rw-r--r--lib/Sema/SemaExpr.cpp8
-rw-r--r--lib/Sema/SemaInit.cpp24
-rw-r--r--lib/Sema/SemaInit.h6
-rw-r--r--test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p2.cpp2
-rw-r--r--test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p1.cpp3
-rw-r--r--test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p5.cpp3
-rw-r--r--test/PCH/functions.c2
-rw-r--r--test/PCH/functions.h5
-rw-r--r--test/Sema/array-constraint.c2
-rw-r--r--test/Sema/attr-format.c2
-rw-r--r--test/Sema/block-misc.c2
-rw-r--r--test/Sema/format-strings.c4
-rw-r--r--test/Sema/incompatible-sign.c2
-rw-r--r--test/Sema/predefined-function.c3
-rw-r--r--test/Sema/transparent-union.c2
-rw-r--r--test/Sema/vector-assign.c2
-rw-r--r--test/Sema/vector-cast.c2
-rw-r--r--test/SemaCXX/default1.cpp9
-rw-r--r--test/SemaCXX/default2.cpp3
-rw-r--r--test/SemaCXX/elaborated-type-specifier.cpp2
-rw-r--r--test/SemaCXX/member-location.cpp5
-rw-r--r--test/SemaCXX/overload-call.cpp2
-rw-r--r--test/SemaCXX/ref-init-ambiguous.cpp2
-rw-r--r--test/SemaObjC/argument-checking.m11
-rw-r--r--test/SemaObjC/block-type-safety.m6
-rw-r--r--test/SemaObjC/blocks.m2
-rw-r--r--test/SemaObjC/class-method-self.m2
-rw-r--r--test/SemaObjC/compatible-protocol-qualified-types.m2
-rw-r--r--test/SemaObjC/comptypes-legal.m2
-rw-r--r--test/SemaObjC/incompatible-protocol-qualified-types.m2
-rw-r--r--test/SemaObjC/method-arg-qualifier-warning.m2
-rw-r--r--test/SemaObjC/protocol-id-test-3.m2
-rw-r--r--test/SemaObjC/protocol-typecheck.m2
-rw-r--r--test/SemaObjC/warn-incompatible-builtin-types.m2
-rw-r--r--test/SemaObjC/warn-superclass-method-mismatch.m2
-rw-r--r--test/SemaObjCXX/message.mm4
-rw-r--r--test/SemaObjCXX/objc-pointer-conv.mm2
-rw-r--r--test/SemaTemplate/default-expr-arguments.cpp12
-rw-r--r--test/SemaTemplate/instantiate-member-template.cpp2
41 files changed, 109 insertions, 53 deletions
diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td
index eb53d6ca38..aad880a7dd 100644
--- a/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/include/clang/Basic/DiagnosticSemaKinds.td
@@ -2077,7 +2077,10 @@ def warn_setter_getter_impl_required_in_category : Warning<
"use @dynamic or provide a method implementation in category">;
def note_property_impl_required : Note<
"implementation is here">;
-
+def note_parameter_named_here : Note<
+ "passing argument to parameter %0 here">;
+def note_parameter_here : Note<
+ "passing argument to parameter here">;
// C++ casts
// These messages adhere to the TryCast pattern: %0 is an int specifying the
diff --git a/lib/Sema/Sema.h b/lib/Sema/Sema.h
index a284803ed6..5333684522 100644
--- a/lib/Sema/Sema.h
+++ b/lib/Sema/Sema.h
@@ -4076,7 +4076,8 @@ public:
bool DiagnoseAssignmentResult(AssignConvertType ConvTy,
SourceLocation Loc,
QualType DstType, QualType SrcType,
- Expr *SrcExpr, AssignmentAction Action);
+ Expr *SrcExpr, AssignmentAction Action,
+ bool *Complained = 0);
/// CheckAssignmentConstraints - Perform type checking for assignment,
/// argument passing, variable initialization, and function return values.
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index 265f44c999..3621f70ffc 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -7036,7 +7036,11 @@ static void MakeObjCStringLiteralFixItHint(Sema& SemaRef, QualType DstType,
bool Sema::DiagnoseAssignmentResult(AssignConvertType ConvTy,
SourceLocation Loc,
QualType DstType, QualType SrcType,
- Expr *SrcExpr, AssignmentAction Action) {
+ Expr *SrcExpr, AssignmentAction Action,
+ bool *Complained) {
+ if (Complained)
+ *Complained = false;
+
// Decode the result (notice that AST's are still created for extensions).
bool isInvalid = false;
unsigned DiagKind;
@@ -7121,6 +7125,8 @@ bool Sema::DiagnoseAssignmentResult(AssignConvertType ConvTy,
Diag(Loc, DiagKind) << FirstType << SecondType << Action
<< SrcExpr->getSourceRange() << Hint;
+ if (Complained)
+ *Complained = true;
return isInvalid;
}
diff --git a/lib/Sema/SemaInit.cpp b/lib/Sema/SemaInit.cpp
index 6a9efbddbd..eae5f63efa 100644
--- a/lib/Sema/SemaInit.cpp
+++ b/lib/Sema/SemaInit.cpp
@@ -3308,6 +3308,20 @@ static Sema::OwningExprResult CopyObject(Sema &S,
move_arg(ConstructorArgs));
}
+void InitializationSequence::PrintInitLocationNote(Sema &S,
+ const InitializedEntity &Entity) {
+ if (Entity.getKind() == InitializedEntity::EK_Parameter && Entity.getDecl()) {
+ if (Entity.getDecl()->getLocation().isInvalid())
+ return;
+
+ if (Entity.getDecl()->getDeclName())
+ S.Diag(Entity.getDecl()->getLocation(), diag::note_parameter_named_here)
+ << Entity.getDecl()->getDeclName();
+ else
+ S.Diag(Entity.getDecl()->getLocation(), diag::note_parameter_here);
+ }
+}
+
Action::OwningExprResult
InitializationSequence::Perform(Sema &S,
const InitializedEntity &Entity,
@@ -3474,6 +3488,7 @@ InitializationSequence::Perform(Sema &S,
S.Diag(Kind.getLocation(), diag::err_reference_bind_to_vector_element)
<< Entity.getType().isVolatileQualified()
<< CurInitExpr->getSourceRange();
+ PrintInitLocationNote(S, Entity);
return S.ExprError();
}
@@ -3695,10 +3710,16 @@ InitializationSequence::Perform(Sema &S,
== Sema::Compatible)
ConvTy = Sema::Compatible;
+ bool Complained;
if (S.DiagnoseAssignmentResult(ConvTy, Kind.getLocation(),
Step->Type, SourceType,
- CurInitExpr, getAssignmentAction(Entity)))
+ CurInitExpr,
+ getAssignmentAction(Entity),
+ &Complained)) {
+ PrintInitLocationNote(S, Entity);
return S.ExprError();
+ } else if (Complained)
+ PrintInitLocationNote(S, Entity);
CurInit.release();
CurInit = S.Owned(CurInitExpr);
@@ -3972,6 +3993,7 @@ bool InitializationSequence::Diagnose(Sema &S,
break;
}
+ PrintInitLocationNote(S, Entity);
return true;
}
diff --git a/lib/Sema/SemaInit.h b/lib/Sema/SemaInit.h
index ba11470d24..5f2592fb77 100644
--- a/lib/Sema/SemaInit.h
+++ b/lib/Sema/SemaInit.h
@@ -542,7 +542,11 @@ private:
/// \brief The candidate set created when initialization failed.
OverloadCandidateSet FailedCandidateSet;
-
+
+ /// \brief Prints a follow-up note that highlights the location of
+ /// the initialized entity, if it's remote.
+ void PrintInitLocationNote(Sema &S, const InitializedEntity &Entity);
+
public:
/// \brief Try to perform initialization of the given entity, creating a
/// record of the steps required to perform the initialization.
diff --git a/test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p2.cpp b/test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p2.cpp
index f9bac40c9d..30393961b3 100644
--- a/test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p2.cpp
+++ b/test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p2.cpp
@@ -36,7 +36,7 @@ namespace Numbers {
double d;
};
Number zero(0.0f);
- void g(Number);
+ void g(Number); // expected-note 2{{passing argument to parameter here}}
}
void test2() {
diff --git a/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p1.cpp b/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p1.cpp
index 3581f79b0a..c51c2cacc3 100644
--- a/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p1.cpp
+++ b/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p1.cpp
@@ -12,7 +12,8 @@ namespace Test0 {
test<1> foo(class foo);
namespace A {
- test<2> foo(class ::foo); // expected-note {{candidate}}
+ test<2> foo(class ::foo); // expected-note {{candidate}} \
+ // expected-note{{passing argument to parameter here}}
void test0() {
using ::foo;
diff --git a/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p5.cpp b/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p5.cpp
index 7ee052c5f9..3100e56a08 100644
--- a/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p5.cpp
+++ b/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p5.cpp
@@ -2,7 +2,8 @@
float global_f;
-void f0(int *ip = &global_f); // expected-error{{cannot initialize}}
+void f0(int *ip = &global_f); // expected-error{{cannot initialize}} \
+// expected-note{{passing argument to parameter 'ip' here}}
// Example from C++03 standard
int a = 1;
diff --git a/test/PCH/functions.c b/test/PCH/functions.c
index 5d7849e129..23becb60e8 100644
--- a/test/PCH/functions.c
+++ b/test/PCH/functions.c
@@ -6,7 +6,7 @@
// RUN: %clang_cc1 -include-pch %t -fsyntax-only -verify %s
int f0(int x0, int y0, ...) { return x0 + y0; }
-
+// expected-note{{passing argument to parameter here}}
float *test_f1(int val, double x, double y) {
if (val > 5)
return f1(x, y);
diff --git a/test/PCH/functions.h b/test/PCH/functions.h
index 3972430081..f57400fc84 100644
--- a/test/PCH/functions.h
+++ b/test/PCH/functions.h
@@ -1,6 +1,9 @@
/* For use with the functions.c test */
-int f0(int x, int y, ...);
+
+
+
+int f0(int x, int y, ...);
float *f1(float x, float y);
void g0(int *);
diff --git a/test/Sema/array-constraint.c b/test/Sema/array-constraint.c
index 8b577fa5d7..9fcac25abe 100644
--- a/test/Sema/array-constraint.c
+++ b/test/Sema/array-constraint.c
@@ -43,7 +43,7 @@ void check_size() {
static int I;
typedef int TA[I]; // expected-error {{variable length array declaration not allowed at file scope}}
-void strFunc(char *);
+void strFunc(char *); // expected-note{{passing argument to parameter here}}
const char staticAry[] = "test";
void checkStaticAry() {
strFunc(staticAry); // expected-warning{{passing 'char const [5]' to parameter of type 'char *' discards qualifiers}}
diff --git a/test/Sema/attr-format.c b/test/Sema/attr-format.c
index 0fadf98f97..a223e08f5a 100644
--- a/test/Sema/attr-format.c
+++ b/test/Sema/attr-format.c
@@ -45,7 +45,7 @@ void e2(char *str, int c, ...) __attribute__((format(printf0, 2,3))); // expecte
// FreeBSD usage
#define __printf0like(fmt,va) __attribute__((__format__(__printf0__,fmt,va)))
void null(int i, const char *a, ...) __printf0like(2,0); // no-error
-void null(int i, const char *a, ...) {
+void null(int i, const char *a, ...) { // expected-note{{passing argument to parameter 'a' here}}
if (a)
(void)0/* vprintf(...) would go here */;
}
diff --git a/test/Sema/block-misc.c b/test/Sema/block-misc.c
index e31cdb5bcd..accd4bac14 100644
--- a/test/Sema/block-misc.c
+++ b/test/Sema/block-misc.c
@@ -139,7 +139,7 @@ void test14() {
enum { LESS };
-void foo(long (^comp)()) {
+void foo(long (^comp)()) { // expected-note{{passing argument to parameter 'comp' here}}
}
void (^test15f)(void);
diff --git a/test/Sema/format-strings.c b/test/Sema/format-strings.c
index dcc4c35d01..bdc2bb0c9a 100644
--- a/test/Sema/format-strings.c
+++ b/test/Sema/format-strings.c
@@ -4,7 +4,7 @@
typedef __typeof(sizeof(int)) size_t;
typedef struct _FILE FILE;
int fprintf(FILE *, const char *restrict, ...);
-int printf(const char *restrict, ...);
+int printf(const char *restrict, ...); // expected-note{{passing argument to parameter here}}
int snprintf(char *restrict, size_t, const char *restrict, ...);
int sprintf(char *restrict, const char *restrict, ...);
int vasprintf(char **, const char *, va_list);
@@ -12,7 +12,7 @@ int asprintf(char **, const char *, ...);
int vfprintf(FILE *, const char *restrict, va_list);
int vprintf(const char *restrict, va_list);
int vsnprintf(char *, size_t, const char *, va_list);
-int vsprintf(char *restrict, const char *restrict, va_list);
+int vsprintf(char *restrict, const char *restrict, va_list); // expected-note{{passing argument to parameter here}}
char * global_fmt;
diff --git a/test/Sema/incompatible-sign.c b/test/Sema/incompatible-sign.c
index b3c1e9a44e..6249feb6b1 100644
--- a/test/Sema/incompatible-sign.c
+++ b/test/Sema/incompatible-sign.c
@@ -1,5 +1,5 @@
// RUN: %clang_cc1 %s -verify -fsyntax-only
-int a(int* x);
+int a(int* x); // expected-note{{passing argument to parameter 'x' here}}
int b(unsigned* y) { return a(y); } // expected-warning {{passing 'unsigned int *' to parameter of type 'int *' converts between pointers to integer types with different sign}}
diff --git a/test/Sema/predefined-function.c b/test/Sema/predefined-function.c
index 74bc86fa57..1c40b6e8c2 100644
--- a/test/Sema/predefined-function.c
+++ b/test/Sema/predefined-function.c
@@ -4,7 +4,8 @@ char *funk(int format);
enum Test {A=-1};
char *funk(enum Test x);
-int eli(float b); // expected-note {{previous declaration is here}}
+int eli(float b); // expected-note {{previous declaration is here}} \
+// expected-note{{passing argument to parameter 'b' here}}
int b(int c) {return 1;}
int foo();
diff --git a/test/Sema/transparent-union.c b/test/Sema/transparent-union.c
index 03f6a53d05..cdfc8506d1 100644
--- a/test/Sema/transparent-union.c
+++ b/test/Sema/transparent-union.c
@@ -4,7 +4,7 @@ typedef union {
float *fp;
} TU __attribute__((transparent_union));
-void f(TU);
+void f(TU); // expected-note{{passing argument to parameter here}}
void g(int *ip, float *fp, char *cp) {
f(ip);
diff --git a/test/Sema/vector-assign.c b/test/Sema/vector-assign.c
index e06072928d..05fc3b13db 100644
--- a/test/Sema/vector-assign.c
+++ b/test/Sema/vector-assign.c
@@ -47,7 +47,7 @@ float test2(__attribute__((vector_size(16))) float a, int b) {
typedef long long __attribute__((__vector_size__(2 * sizeof(long long))))
longlongvec;
-void test3a(longlongvec *);
+void test3a(longlongvec *); // expected-note{{passing argument to parameter here}}
void test3(const unsigned *src) {
test3a(src); // expected-warning {{incompatible pointer types passing 'unsigned int const *' to parameter of type 'longlongvec *'}}
}
diff --git a/test/Sema/vector-cast.c b/test/Sema/vector-cast.c
index e655147d44..a717e86110 100644
--- a/test/Sema/vector-cast.c
+++ b/test/Sema/vector-cast.c
@@ -30,7 +30,7 @@ type 't1' and integer type 'short' of different size}}
}
-void f2(t2 X);
+void f2(t2 X); // expected-note{{passing argument to parameter 'X' here}}
void f3(t3 Y) {
f2(Y); // expected-warning {{incompatible vector types passing 't3' to parameter of type 't2'}}
diff --git a/test/SemaCXX/default1.cpp b/test/SemaCXX/default1.cpp
index 790208aa1d..e9d8a2f767 100644
--- a/test/SemaCXX/default1.cpp
+++ b/test/SemaCXX/default1.cpp
@@ -14,7 +14,8 @@ void h(int i, int j = 2, int k = 3,
int n);// expected-error {{missing default argument on parameter 'n'}}
struct S { } s;
-void i(int = s) { } // expected-error {{no viable conversion}}
+void i(int = s) { } // expected-error {{no viable conversion}} \
+// expected-note{{passing argument to parameter here}}
struct X {
X(int);
@@ -26,6 +27,8 @@ struct Y { // expected-note 2{{candidate}}
explicit Y(int);
};
-void k(Y y = 17); // expected-error{{no viable conversion}}
+void k(Y y = 17); // expected-error{{no viable conversion}} \
+// expected-note{{passing argument to parameter 'y' here}}
-void kk(Y = 17); // expected-error{{no viable conversion}}
+void kk(Y = 17); // expected-error{{no viable conversion}} \
+// expected-note{{passing argument to parameter here}}
diff --git a/test/SemaCXX/default2.cpp b/test/SemaCXX/default2.cpp
index a0999c0c4c..d9f1edf3b2 100644
--- a/test/SemaCXX/default2.cpp
+++ b/test/SemaCXX/default2.cpp
@@ -102,7 +102,8 @@ void test_Z(const Z& z) {
struct ZZ {
static ZZ g(int = 17);
- void f(ZZ z = g()); // expected-error{{no matching constructor for initialization}}
+ void f(ZZ z = g()); // expected-error{{no matching constructor for initialization}} \
+ // expected-note{{passing argument to parameter 'z' here}}
ZZ(ZZ&, int = 17); // expected-note{{candidate constructor}}
};
diff --git a/test/SemaCXX/elaborated-type-specifier.cpp b/test/SemaCXX/elaborated-type-specifier.cpp
index 3cd3a1bc22..2d0b571e02 100644
--- a/test/SemaCXX/elaborated-type-specifier.cpp
+++ b/test/SemaCXX/elaborated-type-specifier.cpp
@@ -22,7 +22,7 @@ namespace NS {
void test_elab2(struct S4 *s4);
};
- void X::test_elab2(S4 *s4) { }
+ void X::test_elab2(S4 *s4) { } // expected-note{{passing argument to parameter 's4' here}}
}
void test_X_elab(NS::X x) {
diff --git a/test/SemaCXX/member-location.cpp b/test/SemaCXX/member-location.cpp
index c3099d25e0..6f7e1f5775 100644
--- a/test/SemaCXX/member-location.cpp
+++ b/test/SemaCXX/member-location.cpp
@@ -1,5 +1,8 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
// PR4103: Make sure we have a location for the error
-class A { float a(int *); int b(); };
+class A {
+ float a(int *); // expected-note{{passing argument to parameter here}}
+ int b();
+};
int A::b() { return a(a((int*)0)); } // expected-error {{cannot initialize a parameter of type 'int *' with an rvalue of type 'float'}}
diff --git a/test/SemaCXX/overload-call.cpp b/test/SemaCXX/overload-call.cpp
index 472e805c29..feec9df6b7 100644
--- a/test/SemaCXX/overload-call.cpp
+++ b/test/SemaCXX/overload-call.cpp
@@ -425,7 +425,7 @@ namespace PR6078 {
namespace PR6177 {
struct String { String(char const*); };
- void f(bool const volatile&);
+ void f(bool const volatile&); // expected-note{{passing argument to parameter here}}
void f(String);
void g() { f(""); } // expected-error{{volatile lvalue reference to type 'bool const volatile' cannot bind to a value of unrelated type 'char const [1]'}}
diff --git a/test/SemaCXX/ref-init-ambiguous.cpp b/test/SemaCXX/ref-init-ambiguous.cpp
index 8844162052..a8e95a3953 100644
--- a/test/SemaCXX/ref-init-ambiguous.cpp
+++ b/test/SemaCXX/ref-init-ambiguous.cpp
@@ -17,7 +17,7 @@ void test(C c) {
const E2 &e2 = c; // expected-error {{reference initialization of type 'E2 const &' with initializer of type 'C' is ambiguous}}
}
-void foo(const E2 &);
+void foo(const E2 &);// expected-note{{passing argument to parameter here}}
const E2 & re(C c) {
foo(c); // expected-error {{reference initialization of type 'E2 const &' with initializer of type 'C' is ambiguous}}
diff --git a/test/SemaObjC/argument-checking.m b/test/SemaObjC/argument-checking.m
index 19caf3271c..9019a0fb24 100644
--- a/test/SemaObjC/argument-checking.m
+++ b/test/SemaObjC/argument-checking.m
@@ -2,14 +2,15 @@
struct S { int a; };
-extern int charStarFunc(char *);
-extern int charFunc(char);
+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;
--structMeth:(struct S)s;
--structMeth:(struct S)s :(struct S)s2;
+-(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() {
diff --git a/test/SemaObjC/block-type-safety.m b/test/SemaObjC/block-type-safety.m
index 2b31cacd73..402a658f3e 100644
--- a/test/SemaObjC/block-type-safety.m
+++ b/test/SemaObjC/block-type-safety.m
@@ -4,7 +4,7 @@
@interface Super @end
@interface Sub : Super @end
-void f2(void(^f)(Super *)) {
+void f2(void(^f)(Super *)) { // expected-note{{passing argument to parameter 'f' here}}
Super *o;
f(o);
}
@@ -18,7 +18,7 @@ void r0(Super* (^f)()) {
Super *o = f();
}
-void r1(Sub* (^f)()) {
+void r1(Sub* (^f)()) { // expected-note{{passing argument to parameter 'f' here}}
Sub *o = f();
}
@@ -95,7 +95,7 @@ void test2(void)
@end
@protocol P, P2;
-void f4(void (^f)(id<P> x)) {
+void f4(void (^f)(id<P> x)) { // expected-note{{passing argument to parameter 'f' here}}
NSArray<P2> *b;
f(b); // expected-warning {{passing 'NSArray<P2> *' to parameter of incompatible type 'id<P>'}}
}
diff --git a/test/SemaObjC/blocks.m b/test/SemaObjC/blocks.m
index 10239e5488..15aa5811cc 100644
--- a/test/SemaObjC/blocks.m
+++ b/test/SemaObjC/blocks.m
@@ -21,7 +21,7 @@ void foo4(id (^objectCreationBlock)(int)) {
return bar4(objectCreationBlock);
}
-void bar5(id(^)(void));
+void bar5(id(^)(void)); // expected-note{{passing argument to parameter here}}
void foo5(id (^objectCreationBlock)(int)) {
return bar5(objectCreationBlock); // expected-error {{incompatible block pointer types passing 'id (^)(int)' to parameter of type 'id (^)(void)'}}
}
diff --git a/test/SemaObjC/class-method-self.m b/test/SemaObjC/class-method-self.m
index ec0edf1200..ba70644eba 100644
--- a/test/SemaObjC/class-method-self.m
+++ b/test/SemaObjC/class-method-self.m
@@ -3,7 +3,7 @@
typedef struct objc_class *Class;
@interface XX
-- (void)addObserver:(XX*)o;
+- (void)addObserver:(XX*)o; // expected-note 2{{passing argument to parameter 'o' here}}
@end
diff --git a/test/SemaObjC/compatible-protocol-qualified-types.m b/test/SemaObjC/compatible-protocol-qualified-types.m
index 1c9cc2c494..0342622a11 100644
--- a/test/SemaObjC/compatible-protocol-qualified-types.m
+++ b/test/SemaObjC/compatible-protocol-qualified-types.m
@@ -44,7 +44,7 @@ extern NSString * const XCActiveSelectionLevel;
@interface NSTextStorage : NSObject
-- (void)setDelegate:(id <NSTextStorageDelegate>)delegate;
+- (void)setDelegate:(id <NSTextStorageDelegate>)delegate; // expected-note{{passing argument to parameter 'delegate' here}}
- (id <NSTextStorageDelegate>)delegate;
@end
diff --git a/test/SemaObjC/comptypes-legal.m b/test/SemaObjC/comptypes-legal.m
index e318d332f3..d83d559ee6 100644
--- a/test/SemaObjC/comptypes-legal.m
+++ b/test/SemaObjC/comptypes-legal.m
@@ -26,7 +26,7 @@ NSObject *ExternFunc (NSObject *filePath, NSObject *key);
typedef id FuncSignature (NSObject *arg1, Derived *arg2);
@interface Derived: NSObject
-+ (void)registerFunc:(FuncSignature *)function;
++ (void)registerFunc:(FuncSignature *)function; // expected-note{{passing argument to parameter 'function' here}}
@end
void foo(void)
diff --git a/test/SemaObjC/incompatible-protocol-qualified-types.m b/test/SemaObjC/incompatible-protocol-qualified-types.m
index 23cb50a362..494d23e8b2 100644
--- a/test/SemaObjC/incompatible-protocol-qualified-types.m
+++ b/test/SemaObjC/incompatible-protocol-qualified-types.m
@@ -8,7 +8,7 @@
@interface INTF @end
-INTF <MyProto1> * Func(INTF <MyProto1, MyProto2> *p2)
+INTF <MyProto1> * Func(INTF <MyProto1, MyProto2> *p2) // expected-note{{passing argument to parameter 'p2' here}}
{
return p2;
}
diff --git a/test/SemaObjC/method-arg-qualifier-warning.m b/test/SemaObjC/method-arg-qualifier-warning.m
index a064a7d7a5..463fb7fd77 100644
--- a/test/SemaObjC/method-arg-qualifier-warning.m
+++ b/test/SemaObjC/method-arg-qualifier-warning.m
@@ -3,7 +3,7 @@
typedef signed char BOOL;
@interface NSString
-- (BOOL)isEqualToString:(NSString *)aString;
+- (BOOL)isEqualToString:(NSString *)aString; // expected-note 2{{passing argument to parameter 'aString' here}}
@end
static const NSString * Identifier1 = @"Identifier1";
diff --git a/test/SemaObjC/protocol-id-test-3.m b/test/SemaObjC/protocol-id-test-3.m
index 89f11c3d75..624bab0c22 100644
--- a/test/SemaObjC/protocol-id-test-3.m
+++ b/test/SemaObjC/protocol-id-test-3.m
@@ -8,7 +8,7 @@
@interface INTF @end
-id<MyProto1> Func(INTF <MyProto1, MyProto2> *p2)
+id<MyProto1> Func(INTF <MyProto1, MyProto2> *p2) // expected-note 2{{passing argument to parameter 'p2' here}}
{
return p2;
}
diff --git a/test/SemaObjC/protocol-typecheck.m b/test/SemaObjC/protocol-typecheck.m
index 3d98df8aab..4eb1b2641a 100644
--- a/test/SemaObjC/protocol-typecheck.m
+++ b/test/SemaObjC/protocol-typecheck.m
@@ -9,7 +9,7 @@
@interface XX
- (void)setFlexElement:(NSObject <PWhatever, XCElementP> *)flexer;
-- (void)setFlexElement2:(NSObject <PWhatever, XCElementSpacerP> *)flexer;
+- (void)setFlexElement2:(NSObject <PWhatever, XCElementSpacerP> *)flexer; // expected-note{{passing argument to parameter 'flexer' here}}
@end
diff --git a/test/SemaObjC/warn-incompatible-builtin-types.m b/test/SemaObjC/warn-incompatible-builtin-types.m
index 8806d63baa..79c8cea665 100644
--- a/test/SemaObjC/warn-incompatible-builtin-types.m
+++ b/test/SemaObjC/warn-incompatible-builtin-types.m
@@ -2,7 +2,7 @@
// rdar 7634850
@interface Foo
-- (void)foo:(Class)class;
+- (void)foo:(Class)class; // expected-note{{passing argument to parameter 'class' here}}
@end
void FUNC() {
diff --git a/test/SemaObjC/warn-superclass-method-mismatch.m b/test/SemaObjC/warn-superclass-method-mismatch.m
index a4005ad2b2..52054739d5 100644
--- a/test/SemaObjC/warn-superclass-method-mismatch.m
+++ b/test/SemaObjC/warn-superclass-method-mismatch.m
@@ -9,7 +9,7 @@
@interface Base : Root
-(void) method: (int*) x; // expected-note {{previous declaration is here}}
-(void) method1: (Base*) x; // expected-note {{previous declaration is here}}
--(void) method2: (Sub*) x;
+-(void) method2: (Sub*) x; // expected-note{{passing argument to parameter 'x' here}}
+ method3: (int)x1 : (Base *)x2 : (float)x3; // expected-note {{previous declaration is here}}
+ mathod4: (id)x1;
- method5: (int) x : (double) d; // expected-note {{previous declaration is here}}
diff --git a/test/SemaObjCXX/message.mm b/test/SemaObjCXX/message.mm
index 97ee499aff..b75608e232 100644
--- a/test/SemaObjCXX/message.mm
+++ b/test/SemaObjCXX/message.mm
@@ -84,9 +84,11 @@ struct MutableString : public String { };
// C++-specific parameter types
@interface I5
-- method:(const String&)str1 other:(String&)str2;
+- method:(const String&)str1
+ other:(String&)str2; // expected-note{{passing argument to parameter 'str2' here}}
@end
void test_I5(I5 *i5, String s) {
[i5 method:"hello" other:s];
+ [i5 method:s other:"world"]; // expected-error{{non-const lvalue reference to type 'String' cannot bind to a value of unrelated type 'char const [6]'}}
}
diff --git a/test/SemaObjCXX/objc-pointer-conv.mm b/test/SemaObjCXX/objc-pointer-conv.mm
index 2504dcedb8..cc3264fcc4 100644
--- a/test/SemaObjCXX/objc-pointer-conv.mm
+++ b/test/SemaObjCXX/objc-pointer-conv.mm
@@ -26,7 +26,7 @@ void RandomFunc(CFMDRef theDict, const void *key, const void *value);
@end
@interface I
-- (void) Meth : (I*) Arg;
+- (void) Meth : (I*) Arg; // expected-note{{passing argument to parameter 'Arg' here}}
@end
void Func (I* arg); // expected-note {{candidate function not viable: no known conversion from 'I const *' to 'I *' for 1st argument}}
diff --git a/test/SemaTemplate/default-expr-arguments.cpp b/test/SemaTemplate/default-expr-arguments.cpp
index d2cc45b035..40b7f2b3cf 100644
--- a/test/SemaTemplate/default-expr-arguments.cpp
+++ b/test/SemaTemplate/default-expr-arguments.cpp
@@ -7,7 +7,8 @@ C<char>::C(int a0);
struct S { }; // expected-note 3 {{candidate constructor (the implicit copy constructor)}}
-template<typename T> void f1(T a, T b = 10) { } // expected-error{{no viable conversion}}
+template<typename T> void f1(T a, T b = 10) { } // expected-error{{no viable conversion}} \
+// expected-note{{passing argument to parameter 'b' here}}
template<typename T> void f2(T a, T b = T()) { }
@@ -25,8 +26,10 @@ void g() {
}
template<typename T> struct F {
- F(T t = 10); // expected-error{{no viable conversion}}
- void f(T t = 10); // expected-error{{no viable conversion}}
+ F(T t = 10); // expected-error{{no viable conversion}} \
+ // expected-note{{passing argument to parameter 't' here}}
+ void f(T t = 10); // expected-error{{no viable conversion}} \
+ // expected-note{{passing argument to parameter 't' here}}
};
struct FD : F<int> { };
@@ -99,7 +102,8 @@ void test_x2(X2<int> x2i, X2<NotDefaultConstructible> x2n) {
// PR5283
namespace PR5283 {
template<typename T> struct A {
- A(T = 1); // expected-error 3 {{cannot initialize a parameter of type 'int *' with an rvalue of type 'int'}}
+ A(T = 1); // expected-error 3 {{cannot initialize a parameter of type 'int *' with an rvalue of type 'int'}} \
+ // expected-note 3{{passing argument to parameter here}}
};
struct B : A<int*> {
diff --git a/test/SemaTemplate/instantiate-member-template.cpp b/test/SemaTemplate/instantiate-member-template.cpp
index c1260cf6a8..ae8425e716 100644
--- a/test/SemaTemplate/instantiate-member-template.cpp
+++ b/test/SemaTemplate/instantiate-member-template.cpp
@@ -44,7 +44,7 @@ struct X1 {
template<typename U>
struct Inner3 {
- void f0(T t, U u) {
+ void f0(T t, U u) { // expected-note{{passing argument to parameter 't' here}}
(void)(t + u); // expected-error{{invalid operands}}
}