"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
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.
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;
Diag(Loc, DiagKind) << FirstType << SecondType << Action
<< SrcExpr->getSourceRange() << Hint;
+ if (Complained)
+ *Complained = true;
return isInvalid;
}
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,
S.Diag(Kind.getLocation(), diag::err_reference_bind_to_vector_element)
<< Entity.getType().isVolatileQualified()
<< CurInitExpr->getSourceRange();
+ PrintInitLocationNote(S, Entity);
return S.ExprError();
}
== 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);
break;
}
+ PrintInitLocationNote(S, Entity);
return true;
}
/// \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.
double d;
};
Number zero(0.0f);
- void g(Number);
+ void g(Number); // expected-note 2{{passing argument to parameter here}}
}
void test2() {
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;
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;
// 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);
/* 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 *);
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}}
// 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 */;
}
enum { LESS };
-void foo(long (^comp)()) {
+void foo(long (^comp)()) { // expected-note{{passing argument to parameter 'comp' here}}
}
void (^test15f)(void);
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);
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;
// 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}}
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();
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);
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 *'}}
}
}
-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'}}
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);
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}}
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}}
};
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) {
// 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'}}
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]'}}
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}}
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() {
@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);
}
Super *o = f();
}
-void r1(Sub* (^f)()) {
+void r1(Sub* (^f)()) { // expected-note{{passing argument to parameter 'f' here}}
Sub *o = f();
}
@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>'}}
}
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)'}}
}
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
@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
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)
@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;
}
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";
@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;
}
@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
// rdar 7634850
@interface Foo
-- (void)foo:(Class)class;
+- (void)foo:(Class)class; // expected-note{{passing argument to parameter 'class' here}}
@end
void FUNC() {
@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}}
// 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]'}}
}
@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}}
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()) { }
}
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> { };
// 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*> {
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}}
}