mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-02-02 07:06:33 +00:00
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
This commit is contained in:
parent
3eeb741e6c
commit
4f4946aaaa
@ -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
|
||||
|
@ -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.
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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.
|
||||
|
@ -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() {
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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 *);
|
||||
|
@ -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}}
|
||||
|
@ -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 */;
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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}}
|
||||
|
||||
|
@ -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();
|
||||
|
@ -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);
|
||||
|
@ -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 *'}}
|
||||
}
|
||||
|
@ -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'}}
|
||||
|
@ -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}}
|
||||
|
@ -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}}
|
||||
};
|
||||
|
@ -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) {
|
||||
|
@ -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'}}
|
||||
|
||||
|
@ -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]'}}
|
||||
|
@ -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}}
|
||||
|
@ -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() {
|
||||
|
@ -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>'}}
|
||||
}
|
||||
|
@ -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)'}}
|
||||
}
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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";
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
||||
|
@ -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() {
|
||||
|
@ -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}}
|
||||
|
@ -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]'}}
|
||||
}
|
||||
|
@ -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}}
|
||||
|
@ -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*> {
|
||||
|
@ -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}}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user