From d4eea8362605807327735727a9098abe1eb23b19 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Fri, 9 Apr 2010 00:35:39 +0000 Subject: [PATCH] Improve diagnostics when we fail to convert from a source type to a destination type for initialization, assignment, parameter-passing, etc. The main issue fixed here is that we used rather confusing wording for diagnostics such as t.c:2:9: warning: initializing 'char const [2]' discards qualifiers, expected 'char *' [-pedantic] char *name = __func__; ^ ~~~~~~~~ We're not initializing a 'char const [2]', we're initializing a 'char *' with an expression of type 'char const [2]'. Similar problems existed for other diagnostics in this area, so I've normalized them all with more precise descriptive text to say what we're initializing/converting/assigning/etc. from and to. The warning for the code above is now: t.c:2:9: warning: initializing 'char *' from an expression of type 'char const [2]' discards qualifiers [-pedantic] char *name = __func__; ^ ~~~~~~~~ Fixes . git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100832 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Basic/DiagnosticSemaKinds.td | 79 ++++++++++++++----- lib/Sema/SemaExpr.cpp | 22 +++++- test/Analysis/null-deref-ps.c | 4 +- test/Analysis/override-werror.c | 2 +- test/CXX/except/except.handle/p16.cpp | 4 +- test/FixIt/fixit-objc.m | 2 +- test/PCH/functions.c | 2 +- test/PCH/types.c | 2 +- test/Parser/altivec.c | 4 +- test/Parser/builtin_types_compatible.c | 2 +- test/Parser/cxx-altivec.cpp | 4 +- test/Parser/declarators.c | 2 +- test/Parser/implicit-casts.c | 2 +- test/Sema/address_spaces.c | 2 +- test/Sema/anonymous-struct-union.c | 2 +- test/Sema/array-constraint.c | 2 +- test/Sema/array-init.c | 14 ++-- test/Sema/block-call.c | 12 +-- test/Sema/block-misc.c | 2 +- test/Sema/block-return.c | 14 ++-- test/Sema/cast-to-union.c | 2 +- test/Sema/compound-literal.c | 2 +- test/Sema/conditional-expr.c | 8 +- test/Sema/conditional.c | 4 +- test/Sema/enum.c | 3 +- test/Sema/ext_vector_casts.c | 2 +- test/Sema/function-ptr.c | 6 +- test/Sema/function-redecl.c | 2 +- test/Sema/incompatible-sign.c | 2 +- test/Sema/invalid-init-diag.c | 2 +- test/Sema/pointer-conversion.c | 6 +- test/Sema/predef.c | 2 +- test/Sema/predefined-function.c | 2 +- test/Sema/statements.c | 2 +- test/Sema/struct-compat.c | 2 +- test/Sema/typedef-retain.c | 4 +- test/Sema/vector-assign.c | 42 +++++----- test/Sema/vector-cast.c | 2 +- test/Sema/warn-write-strings.c | 2 +- test/SemaCXX/copy-assignment.cpp | 2 +- test/SemaCXX/derived-to-base-ambig.cpp | 4 +- test/SemaCXX/member-pointer.cpp | 2 +- test/SemaObjC/argument-checking.m | 8 +- test/SemaObjC/block-type-safety.m | 8 +- test/SemaObjC/blocks.m | 2 +- test/SemaObjC/class-method-self.m | 4 +- .../compatible-protocol-qualified-types.m | 2 +- test/SemaObjC/comptypes-1.m | 12 +-- test/SemaObjC/comptypes-3.m | 18 ++--- test/SemaObjC/comptypes-6.m | 2 +- test/SemaObjC/comptypes-7.m | 32 ++++---- test/SemaObjC/comptypes-legal.m | 2 +- test/SemaObjC/conditional-expr-2.m | 2 +- test/SemaObjC/conditional-expr-3.m | 4 +- test/SemaObjC/conditional-expr-4.m | 2 +- test/SemaObjC/conditional-expr.m | 4 +- test/SemaObjC/id.m | 4 +- .../incompatible-protocol-qualified-types.m | 6 +- test/SemaObjC/message.m | 2 +- test/SemaObjC/method-arg-qualifier-warning.m | 4 +- test/SemaObjC/protocol-id-test-3.m | 12 +-- test/SemaObjC/protocol-typecheck.m | 2 +- test/SemaObjC/protocol-warn.m | 2 +- .../warn-incompatible-builtin-types.m | 18 ++--- test/SemaObjC/warn-write-strings.m | 2 +- test/SemaObjCXX/blocks.mm | 4 +- test/SemaObjCXX/objc-pointer-conv.mm | 2 +- test/SemaObjCXX/void_to_obj.mm | 2 +- test/SemaTemplate/fun-template-def.cpp | 2 +- .../SemaTemplate/instantiate-member-class.cpp | 4 +- 70 files changed, 254 insertions(+), 198 deletions(-) diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index e2d8d6fa77..27632f171f 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/include/clang/Basic/DiagnosticSemaKinds.td @@ -2229,44 +2229,81 @@ def warn_value_always_zero : Warning< // In most of these diagnostics the %2 is a value from the // Sema::AssignmentAction enumeration def err_typecheck_convert_incompatible : Error< - "incompatible type %select{assigning|passing|returning|converting|initializing|sending|casting}2" - " %1, expected %0">; + "%select{assigning to|passing|returning|converting|initializing|sending|casting}2" + " %0 " + "%select{from incompatible type|to parameter of incompatible type|" + "from a function with incompatible result type|to incompatible type|" + "from an expression of incompatible type|to parameter of incompatible type|" + "to incompatible type}2 %1">; def warn_incompatible_qualified_id : Warning< - "incompatible type %select{assigning|passing|returning|converting|initializing|sending|casting}2" - " %1, expected %0">; + "%select{assigning to|passing|returning|converting|initializing|sending|casting}2" + " %0 " + "%select{from incompatible type|to parameter of incompatible type|" + "from a function with incompatible result type|to incompatible type|" + "from an expression of incompatible type|to parameter of incompatible type|" + "to incompatible type}2 %1">; def ext_typecheck_convert_pointer_int : ExtWarn< "incompatible pointer to integer conversion " - "%select{assigning|passing|returning|converting|initializing|sending|casting}2 %1, expected %0">; + "%select{assigning to|passing|returning|converting|initializing|sending|casting}2" + " %0 " + "%select{from|to parameter of type|from a function with result type|to type|" + "from an expression of type|to parameter of type|to type}2 %1">; def ext_typecheck_convert_int_pointer : ExtWarn< "incompatible integer to pointer conversion " - "%select{assigning|passing|returning|converting|initializing|sending|casting}2 %1, expected %0">; + "%select{assigning to|passing|returning|converting|initializing|sending|casting}2" + " %0 " + "%select{from|to parameter of type|from a function with result type|to type|" + "from an expression of type|to parameter of type|to type}2 %1">; def ext_typecheck_convert_pointer_void_func : Extension< - "%select{assigning|passing|returning|converting|initializing|sending|casting}2" - " %1 converts between void* and function pointer, expected %0">; + "%select{assigning to|passing|returning|converting|initializing|sending|casting}2" + " %0 " + "%select{from|to parameter of type|from a function with result type|to type|" + "from an expression of type|to parameter of type|to type}2 %1 " + "converts between void pointer and function pointer">; def ext_typecheck_convert_incompatible_pointer_sign : ExtWarn< - "pointer types point to integer types with different sign " - "%select{assigning|passing|returning|converting|initializing|sending|casting}2 %1, expected %0">, + "%select{assigning to|passing|returning|converting|initializing|sending|casting}2" + " %0 " + "%select{from|to parameter of type|from a function with result type|to type|" + "from an expression of type|to parameter of type|to type}2 %1 " + "converts between pointers to integer types with different sign">, InGroup>; def ext_typecheck_convert_incompatible_pointer : ExtWarn< "incompatible pointer types " - "%select{assigning|passing|returning|converting|initializing|sending|casting}2 %1, expected %0">; + "%select{assigning to|passing|returning|converting|initializing|sending|casting}2" + " %0 " + "%select{from|to parameter of type|from a function with result type|to type|" + "from an expression of type|to parameter of type|to type}2 %1">; def ext_typecheck_convert_discards_qualifiers : ExtWarn< - "%select{assigning|passing|returning|converting|initializing|sending|casting}2" - " %1 discards qualifiers, expected %0">; + "%select{assigning to|passing|returning|converting|initializing|sending|casting}2" + " %0 " + "%select{from|to parameter of type|from a function with result type|to type|" + "from an expression of type|to parameter of type|to type}2 %1 discards " + "qualifiers">; def ext_nested_pointer_qualifier_mismatch : ExtWarn< - "%select{assigning|passing|returning|converting|initializing|sending|casting}2," - " %0 and %1 have different qualifiers in nested pointer types">; + "%select{assigning to|passing|returning|converting|initializing|sending|casting}2" + " %0 " + "%select{from|to parameter of type|from a function with result type|to type|" + "from an expression of type|to parameter of type|to type}2 %1 discards " + "qualifiers in nested pointer types">; def warn_incompatible_vectors : Warning< - "incompatible vector types %select{assigning|passing|returning|converting|initializing|sending|casting}2" - " %1, expected %0">, + "incompatible vector types " + "%select{assigning to|passing|returning|converting|initializing|sending|casting}2" + " %0 " + "%select{from|to parameter of type|from a function with result type|to type|" + "from an expression of type|to parameter of type|to type}2 %1">, InGroup, DefaultIgnore; def err_int_to_block_pointer : Error< - "invalid conversion " - "%select{assigning|passing|returning|converting|initializing|sending|casting}2" - " integer %1, expected block pointer %0">; + "invalid block pointer conversion " + "%select{assigning to|passing|returning|converting|initializing|sending|casting}2" + " %0 " + "%select{from|to parameter of type|from a function with result type|to type|" + "from an expression of type|to parameter of type|to type}2 %1">; def err_typecheck_convert_incompatible_block_pointer : Error< "incompatible block pointer types " - "%select{assigning|passing|returning|converting|initializing|sending|casting}2 %1, expected %0">; + "%select{assigning to|passing|returning|converting|initializing|sending|casting}2" + " %0 " + "%select{from|to parameter of type|from a function with result type|to type|" + "from an expression of type|to parameter of type|to type}2 %1">; def err_typecheck_convert_ambiguous : Error< "ambiguity in initializing value of type %0 with initializer of type %1">; diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index da0c0a0499..654b220499 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -7201,7 +7201,27 @@ bool Sema::DiagnoseAssignmentResult(AssignConvertType ConvTy, break; } - Diag(Loc, DiagKind) << DstType << SrcType << Action + QualType FirstType, SecondType; + switch (Action) { + case AA_Assigning: + case AA_Initializing: + // The destination type comes first. + FirstType = DstType; + SecondType = SrcType; + break; + + case AA_Returning: + case AA_Passing: + case AA_Converting: + case AA_Sending: + case AA_Casting: + // The source type comes first. + FirstType = SrcType; + SecondType = DstType; + break; + } + + Diag(Loc, DiagKind) << FirstType << SecondType << Action << SrcExpr->getSourceRange() << Hint; return isInvalid; } diff --git a/test/Analysis/null-deref-ps.c b/test/Analysis/null-deref-ps.c index 5376ca0eb3..5a1049c7d7 100644 --- a/test/Analysis/null-deref-ps.c +++ b/test/Analysis/null-deref-ps.c @@ -62,8 +62,8 @@ int f4(int *p) { int f4_b() { short array[2]; - uintptr_t x = array; // expected-warning{{incompatible pointer to integer conversion initializing}} - short *p = x; // expected-warning{{incompatible integer to pointer conversion initializing}} + uintptr_t x = array; // expected-warning{{incompatible pointer to integer conversion}} + short *p = x; // expected-warning{{incompatible integer to pointer conversion}} // The following branch should be infeasible. if (!(p = &array[0])) { diff --git a/test/Analysis/override-werror.c b/test/Analysis/override-werror.c index 522b9dcb94..f4854bb819 100644 --- a/test/Analysis/override-werror.c +++ b/test/Analysis/override-werror.c @@ -6,7 +6,7 @@ // analyzer results. char* f(int *p) { - return p; // expected-warning{{incompatible pointer types returning 'int *', expected 'char *'}} + return p; // expected-warning{{incompatible pointer types}} } void g(int *p) { diff --git a/test/CXX/except/except.handle/p16.cpp b/test/CXX/except/except.handle/p16.cpp index 87972f5985..4950a2f6aa 100644 --- a/test/CXX/except/except.handle/p16.cpp +++ b/test/CXX/except/except.handle/p16.cpp @@ -11,12 +11,12 @@ class X { public: X(const X &) { int *ip = 0; - ptr = ip; // expected-error{{incompatible type assigning 'int *', expected 'float *'}} + ptr = ip; // expected-error{{assigning to 'float *' from incompatible type 'int *'}} } ~X() { float *fp = 0; - ptr = fp; // expected-error{{incompatible type assigning 'float *', expected 'int *'}} + ptr = fp; // expected-error{{assigning to 'int *' from incompatible type 'float *'}} } }; diff --git a/test/FixIt/fixit-objc.m b/test/FixIt/fixit-objc.m index 665ac74441..072d50a69b 100644 --- a/test/FixIt/fixit-objc.m +++ b/test/FixIt/fixit-objc.m @@ -27,7 +27,7 @@ void h(id a); void f(Test *t) { NSString *a = "Foo"; id b = "Foo"; - A* c = "Foo"; // expected-warning {{incompatible pointer types initializing 'char [4]', expected 'A *'}} + A* c = "Foo"; // expected-warning {{incompatible pointer types initializing 'A *' from an expression of type 'char [4]'}} g("Foo"); h("Foo"); h(("Foo")); diff --git a/test/PCH/functions.c b/test/PCH/functions.c index eb8579ab2e..5d7849e129 100644 --- a/test/PCH/functions.c +++ b/test/PCH/functions.c @@ -15,7 +15,7 @@ float *test_f1(int val, double x, double y) { } void test_g0(int *x, float * y) { - g0(y); // expected-warning{{incompatible pointer types passing 'float *', expected 'int *'}} + g0(y); // expected-warning{{incompatible pointer types passing 'float *' to parameter of type 'int *'}} g0(x); } diff --git a/test/PCH/types.c b/test/PCH/types.c index 1ebc01be6a..5ca6a6893f 100644 --- a/test/PCH/types.c +++ b/test/PCH/types.c @@ -66,7 +66,7 @@ int_ptr_ptr ipp = &int_value_ptr; // TYPE_TYPEOF_EXPR typeof_17 *t17 = &int_value; struct S { int x, y; }; -typeof_17 t17_2 = (struct S){1, 2}; // expected-error{{incompatible type initializing}} +typeof_17 t17_2 = (struct S){1, 2}; // expected-error{{initializing 'typeof_17' (aka 'int') from an expression of incompatible type 'struct S'}} // TYPE_TYPEOF int_ptr_ptr2 ipp2 = &int_value_ptr; diff --git a/test/Parser/altivec.c b/test/Parser/altivec.c index c2a32cfa39..6c4601abe9 100644 --- a/test/Parser/altivec.c +++ b/test/Parser/altivec.c @@ -81,8 +81,8 @@ void f() { gccvector unsigned int gv = v; gccvector int gvi = (gccvector int)v; __attribute__((vector_size(8))) unsigned int gv8; - gv8 = gccv; // expected-error {{incompatible type assigning '__attribute__((__vector_size__(4 * sizeof(unsigned int)))) unsigned int', expected '__attribute__((__vector_size__(2 * sizeof(unsigned int)))) unsigned int'}} - av = gv8; // expected-error {{incompatible type assigning '__attribute__((__vector_size__(2 * sizeof(unsigned int)))) unsigned int', expected '__vector unsigned int'}} + gv8 = gccv; // expected-error {{assigning to '__attribute__((__vector_size__(2 * sizeof(unsigned int)))) unsigned int' from incompatible type '__attribute__((__vector_size__(4 * sizeof(unsigned int)))) unsigned int'}} + av = gv8; // expected-error {{assigning to '__vector unsigned int' from incompatible type '__attribute__((__vector_size__(2 * sizeof(unsigned int)))) unsigned int'}} v = gccv; __vector unsigned int tv = gccv; diff --git a/test/Parser/builtin_types_compatible.c b/test/Parser/builtin_types_compatible.c index 325615c7ee..ac81e7b08d 100644 --- a/test/Parser/builtin_types_compatible.c +++ b/test/Parser/builtin_types_compatible.c @@ -35,7 +35,7 @@ static void test() struct xx { int a; } x, y; c = __builtin_choose_expr(a+3-7, b, x); // expected-error{{'__builtin_choose_expr' requires a constant expression}} - c = __builtin_choose_expr(0, b, x); // expected-error{{incompatible type assigning 'struct xx', expected 'int'}} + c = __builtin_choose_expr(0, b, x); // expected-error{{assigning to 'int' from incompatible type 'struct xx'}} c = __builtin_choose_expr(5+3-7, b, x); y = __builtin_choose_expr(4+3-7, b, x); diff --git a/test/Parser/cxx-altivec.cpp b/test/Parser/cxx-altivec.cpp index 3610c0e049..13a270b8e6 100644 --- a/test/Parser/cxx-altivec.cpp +++ b/test/Parser/cxx-altivec.cpp @@ -81,8 +81,8 @@ void f() { gccvector unsigned int gv = v; gccvector int gvi = (gccvector int)v; __attribute__((vector_size(8))) unsigned int gv8; - gv8 = gccv; // expected-error {{incompatible type assigning '__attribute__((__vector_size__(4 * sizeof(unsigned int)))) unsigned int', expected '__attribute__((__vector_size__(2 * sizeof(unsigned int)))) unsigned int'}} - av = gv8; // expected-error {{incompatible type assigning '__attribute__((__vector_size__(2 * sizeof(unsigned int)))) unsigned int', expected '__vector unsigned int'}} + gv8 = gccv; // expected-error {{assigning to '__attribute__((__vector_size__(2 * sizeof(unsigned int)))) unsigned int' from incompatible type '__attribute__((__vector_size__(4 * sizeof(unsigned int)))) unsigned int'}} + av = gv8; // expected-error {{assigning to '__vector unsigned int' from incompatible type '__attribute__((__vector_size__(2 * sizeof(unsigned int)))) unsigned int'}} v = gccv; __vector unsigned int tv = gccv; diff --git a/test/Parser/declarators.c b/test/Parser/declarators.c index 91803c1c5d..31712af26c 100644 --- a/test/Parser/declarators.c +++ b/test/Parser/declarators.c @@ -53,7 +53,7 @@ myenum c; // expected-error {{must use 'enum' tag to refer to type 'myenum' float *test7() { // We should recover 'b' by parsing it with a valid type of "struct xyz", which // allows us to diagnose other bad things done with y, such as this. - return &b.y; // expected-warning {{incompatible pointer types returning 'int *', expected 'float *'}} + return &b.y; // expected-warning {{incompatible pointer types returning 'int *' from a function with result type 'float *'}} } struct xyz test8() { return a; } // a should be be marked invalid, no diag. diff --git a/test/Parser/implicit-casts.c b/test/Parser/implicit-casts.c index 900b4ece8b..a2b31f929f 100644 --- a/test/Parser/implicit-casts.c +++ b/test/Parser/implicit-casts.c @@ -14,7 +14,7 @@ void test2() { } int test3() { int a[2]; - a[0] = test3; // expected-warning{{incompatible pointer to integer conversion assigning 'int ()', expected 'int'}} + a[0] = test3; // expected-warning{{incompatible pointer to integer conversion assigning to 'int' from 'int ()'}} return 0; } short x; void test4(char c) { x += c; } diff --git a/test/Sema/address_spaces.c b/test/Sema/address_spaces.c index badd2383ab..6258114578 100644 --- a/test/Sema/address_spaces.c +++ b/test/Sema/address_spaces.c @@ -37,6 +37,6 @@ struct _st { __attribute__((address_space(256))) void * * const base = 0; void * get_0(void) { return base[0]; // expected-error {{illegal implicit cast between two pointers with different address spaces}} \ - expected-warning {{returning 'void __attribute__((address_space(256))) *' discards qualifiers, expected 'void *'}} + expected-warning {{returning 'void __attribute__((address_space(256))) *' from a function with result type 'void *' discards qualifiers}} } diff --git a/test/Sema/anonymous-struct-union.c b/test/Sema/anonymous-struct-union.c index 118854fd47..b91426ca6c 100644 --- a/test/Sema/anonymous-struct-union.c +++ b/test/Sema/anonymous-struct-union.c @@ -101,4 +101,4 @@ struct s2 { typedef struct { int x; } a_struct; -int tmp = (a_struct) { .x = 0 }; // expected-error {{incompatible type initializing 'a_struct', expected 'int'}} +int tmp = (a_struct) { .x = 0 }; // expected-error {{initializing 'int' from an expression of incompatible type 'a_struct'}} diff --git a/test/Sema/array-constraint.c b/test/Sema/array-constraint.c index 66f15c3a3c..8b577fa5d7 100644 --- a/test/Sema/array-constraint.c +++ b/test/Sema/array-constraint.c @@ -46,7 +46,7 @@ typedef int TA[I]; // expected-error {{variable length array declaration not all void strFunc(char *); const char staticAry[] = "test"; void checkStaticAry() { - strFunc(staticAry); // expected-warning{{passing 'char const [5]' discards qualifiers, expected 'char *'}} + strFunc(staticAry); // expected-warning{{passing 'char const [5]' to parameter of type 'char *' discards qualifiers}} } diff --git a/test/Sema/array-init.c b/test/Sema/array-init.c index 45d3183852..ac45ff77c8 100644 --- a/test/Sema/array-init.c +++ b/test/Sema/array-init.c @@ -9,7 +9,7 @@ int ary2[] = { x, y, z }; // expected-error{{initializer element is not a compil extern int fileScopeExtern[3] = { 1, 3, 5 }; // expected-warning{{'extern' variable has an initializer}} -static long ary3[] = { 1, "abc", 3, 4 }; // expected-warning{{incompatible pointer to integer conversion initializing 'char [4]', expected 'long'}} +static long ary3[] = { 1, "abc", 3, 4 }; // expected-warning{{incompatible pointer to integer conversion initializing 'long' from an expression of type 'char [4]'}} void func() { int x = 1; @@ -44,11 +44,11 @@ void func() { int a,b,c; } z = { 1 }; - struct threeElements *p = 7; // expected-warning{{incompatible integer to pointer conversion initializing 'int', expected 'struct threeElements *'}} + struct threeElements *p = 7; // expected-warning{{incompatible integer to pointer conversion initializing 'struct threeElements *' from an expression of type 'int'}} extern int blockScopeExtern[3] = { 1, 3, 5 }; // expected-error{{'extern' variable cannot have an initializer}} - static long x2[3] = { 1.0, "abc" , 5.8 }; // expected-warning{{incompatible pointer to integer conversion initializing 'char [4]', expected 'long'}} + static long x2[3] = { 1.0, "abc" , 5.8 }; // expected-warning{{incompatible pointer to integer conversion initializing 'long' from an expression of type 'char [4]'}} } void test() { @@ -155,10 +155,10 @@ void charArrays() { char c[] = { "Hello" }; int l[sizeof(c) == 6 ? 1 : -1]; - int i[] = { "Hello "}; // expected-warning{{incompatible pointer to integer conversion initializing 'char [7]', expected 'int'}} + int i[] = { "Hello "}; // expected-warning{{incompatible pointer to integer conversion initializing 'int' from an expression of type 'char [7]'}} char c2[] = { "Hello", "Good bye" }; //expected-warning{{excess elements in char array initializer}} - int i2[1] = { "Hello" }; //expected-warning{{incompatible pointer to integer conversion initializing 'char [6]', expected 'int'}} + int i2[1] = { "Hello" }; //expected-warning{{incompatible pointer to integer conversion initializing 'int' from an expression of type 'char [6]'}} char c3[5] = { "Hello" }; char c4[4] = { "Hello" }; //expected-warning{{initializer-string for char array is too long}} @@ -191,12 +191,12 @@ void autoStructTest() { struct s1 {char a; char b;} t1; struct s2 {struct s1 c;} t2 = { t1 }; // The following is a less than great diagnostic (though it's on par with EDG). -struct s1 t3[] = {t1, t1, "abc", 0}; //expected-warning{{incompatible pointer to integer conversion initializing 'char [4]', expected 'char'}} +struct s1 t3[] = {t1, t1, "abc", 0}; //expected-warning{{incompatible pointer to integer conversion initializing 'char' from an expression of type 'char [4]'}} int t4[sizeof t3 == 6 ? 1 : -1]; } struct foo { int z; } w; int bar (void) { - struct foo z = { w }; //expected-error{{incompatible type initializing 'struct foo', expected 'int'}} + struct foo z = { w }; //expected-error{{initializing 'int' from an expression of incompatible type 'struct foo'}} return z.z; } struct s3 {void (*a)(void);} t5 = {autoStructTest}; diff --git a/test/Sema/block-call.c b/test/Sema/block-call.c index 0aba75e14a..01906bc4f2 100644 --- a/test/Sema/block-call.c +++ b/test/Sema/block-call.c @@ -13,7 +13,7 @@ int main() { int (^IFP) () = PFR; // OK - const int (^CIC) () = IFP; // expected-error {{incompatible block pointer types initializing 'int (^)()', expected 'int const (^)()'}} + const int (^CIC) () = IFP; // expected-error {{incompatible block pointer types initializing 'int const (^)()' from an expression of type 'int (^)()'}} const int (^CICC) () = CIC; @@ -21,7 +21,7 @@ int main() { int * const (^IPCC1) () = IPCC; - int * (^IPCC2) () = IPCC; // expected-error {{incompatible block pointer types initializing 'int *const (^)()', expected 'int *(^)()'}} + int * (^IPCC2) () = IPCC; // expected-error {{incompatible block pointer types initializing 'int *(^)()' from an expression of type 'int *const (^)()'}} int (^IPCC3) (const int) = PFR; @@ -29,14 +29,14 @@ int main() { int (^IPCC5) (int, char (^CArg) (double)) = IPCC4; - int (^IPCC6) (int, char (^CArg) (float)) = IPCC4; // expected-error {{incompatible block pointer types initializing 'int (^)(int, char (^)(double))', expected 'int (^)(int, char (^)(float))'}} + int (^IPCC6) (int, char (^CArg) (float)) = IPCC4; // expected-error {{incompatible block pointer types initializing 'int (^)(int, char (^)(float))' from an expression of type 'int (^)(int, char (^)(double))'}} IPCC2 = 0; - IPCC2 = 1; // expected-error {{invalid conversion assigning integer 'int', expected block pointer 'int *(^)()'}} + IPCC2 = 1; // expected-error {{invalid block pointer conversion assigning to 'int *(^)()' from 'int'}} int (^x)() = 0; - int (^y)() = 3; // expected-error {{invalid conversion initializing integer 'int', expected block pointer 'int (^)()'}} + int (^y)() = 3; // expected-error {{invalid block pointer conversion initializing 'int (^)()' from an expression of type 'int'}} int a = 1; - int (^z)() = a+4; // expected-error {{invalid conversion initializing integer 'int', expected block pointer 'int (^)()'}} + int (^z)() = a+4; // expected-error {{invalid block pointer conversion initializing 'int (^)()' from an expression of type 'int'}} } int blah() { diff --git a/test/Sema/block-misc.c b/test/Sema/block-misc.c index ca71ab12b2..e31cdb5bcd 100644 --- a/test/Sema/block-misc.c +++ b/test/Sema/block-misc.c @@ -144,7 +144,7 @@ void foo(long (^comp)()) { void (^test15f)(void); void test15() { - foo(^{ return LESS; }); // expected-error {{incompatible block pointer types passing 'int (^)(void)', expected 'long (^)()'}} + foo(^{ return LESS; }); // expected-error {{incompatible block pointer types passing 'int (^)(void)' to parameter of type 'long (^)()'}} } __block int test16i; // expected-error {{__block attribute not allowed, only allowed on local variables}} diff --git a/test/Sema/block-return.c b/test/Sema/block-return.c index 2385106630..f4eff65ed4 100644 --- a/test/Sema/block-return.c +++ b/test/Sema/block-return.c @@ -4,7 +4,7 @@ typedef void (^CL)(void); CL foo() { short y; - short (^add1)(void) = ^{ return y+1; }; // expected-error {{incompatible block pointer types initializing 'int (^)(void)', expected 'short (^)(void)'}} + short (^add1)(void) = ^{ return y+1; }; // expected-error {{incompatible block pointer types initializing 'short (^)(void)' from an expression of type 'int (^)(void)'}} CL X = ^{ if (2) @@ -26,7 +26,7 @@ CL foo() { return (char*)0; }; - double (^A)(void) = ^ { // expected-error {{incompatible block pointer types initializing 'float (^)(void)', expected 'double (^)(void)'}} + double (^A)(void) = ^ { // expected-error {{incompatible block pointer types initializing 'double (^)(void)' from an expression of type 'float (^)(void)'}} if (1) return (float)1.0; else @@ -38,10 +38,10 @@ CL foo() { if (3) return ""; else - return 2; // expected-warning {{incompatible integer to pointer conversion returning 'int', expected 'char *'}} + return 2; // expected-warning {{incompatible integer to pointer conversion returning 'int' from a function with result type 'char *'}} }; - return ^{ return 1; }; // expected-error {{incompatible block pointer types returning 'int (^)(void)', expected 'CL'}} + return ^{ return 1; }; // expected-error {{incompatible block pointer types returning 'int (^)(void)' from a function with result type 'CL' (aka 'void (^)(void)')}} } typedef int (^CL2)(void); @@ -78,8 +78,8 @@ static int funk(char *s) { } void next(); void foo4() { - int (^xx)(const char *s) = ^(char *s) { return 1; }; // expected-error {{incompatible block pointer types initializing 'int (^)(char *)', expected 'int (^)(char const *)'}} - int (*yy)(const char *s) = funk; // expected-warning {{incompatible pointer types initializing 'int (char *)', expected 'int (*)(char const *)'}} + int (^xx)(const char *s) = ^(char *s) { return 1; }; // expected-error {{incompatible block pointer types initializing 'int (^)(char const *)' from an expression of type 'int (^)(char *)'}} + int (*yy)(const char *s) = funk; // expected-warning {{incompatible pointer types initializing 'int (*)(char const *)' from an expression of type 'int (char *)'}} int (^nested)(char *s) = ^(char *str) { void (^nest)(void) = ^(void) { printf("%s\n", str); }; next(); return 1; }; // expected-warning{{implicitly declaring C library function 'printf' with type 'int (char const *, ...)'}} \ // expected-note{{please include the header or explicitly provide a declaration for 'printf'}} @@ -109,7 +109,7 @@ void foo6() { void foo7() { - const int (^BB) (void) = ^{ const int i = 1; return i; }; // expected-error{{incompatible block pointer types initializing 'int (^)(void)', expected 'int const (^)(void)'}} + const int (^BB) (void) = ^{ const int i = 1; return i; }; // expected-error{{incompatible block pointer types initializing 'int const (^)(void)' from an expression of type 'int (^)(void)'}} const int (^CC) (void) = ^const int{ const int i = 1; return i; }; // OK int i; diff --git a/test/Sema/cast-to-union.c b/test/Sema/cast-to-union.c index 6856c17c72..a3683de10e 100644 --- a/test/Sema/cast-to-union.c +++ b/test/Sema/cast-to-union.c @@ -10,7 +10,7 @@ void test(int x) { union u w = (union u)2; // expected-warning {{C99 forbids casts to union type}} union u ww = (union u)1.0; // expected-error{{cast to union type from type 'double' not present in union}} -union u x = 7; // expected-error{{incompatible type initializing 'int', expected 'union u'}} +union u x = 7; // expected-error{{initializing 'union u' from an expression of incompatible type 'int'}} int i; union u zz = (union u)i; // expected-error{{initializer element is not a compile-time constant}} expected-warning {{C99 forbids casts to union type}} diff --git a/test/Sema/compound-literal.c b/test/Sema/compound-literal.c index 0c8ddd42d0..205fa719b5 100644 --- a/test/Sema/compound-literal.c +++ b/test/Sema/compound-literal.c @@ -9,7 +9,7 @@ static int *p = (int []){2,4}; static int x = (int){1}; static int *p2 = (int []){2,x}; // -expected-error {{initializer element is not a compile-time constant}} -static long *p3 = (long []){2,"x"}; // -expected-warning {{incompatible pointer to integer conversion initializing 'char [2]', expected 'long'}} +static long *p3 = (long []){2,"x"}; // -expected-warning {{incompatible pointer to integer conversion initializing 'long' from an expression of type 'char [2]'}} typedef struct { } cache_t; // -expected-warning{{use of empty struct extension}} static cache_t clo_I1_cache = ((cache_t) { } ); // -expected-warning{{use of GNU empty initializer extension}} diff --git a/test/Sema/conditional-expr.c b/test/Sema/conditional-expr.c index 5f01374be3..5e2c1a4624 100644 --- a/test/Sema/conditional-expr.c +++ b/test/Sema/conditional-expr.c @@ -13,11 +13,11 @@ void foo() { dp = vp; vp = dp; - ip = dp; // expected-warning {{incompatible pointer types assigning 'double *', expected 'int *'}} - dp = ip; // expected-warning {{incompatible pointer types assigning 'int *', expected 'double *'}} + ip = dp; // expected-warning {{incompatible pointer types assigning to 'int *' from 'double *'}} + dp = ip; // expected-warning {{incompatible pointer types assigning to 'double *' from 'int *'}} dp = 0 ? (double *)0 : (void *)0; vp = 0 ? (double *)0 : (void *)0; - ip = 0 ? (double *)0 : (void *)0; // expected-warning {{incompatible pointer types assigning 'double *', expected 'int *'}} + ip = 0 ? (double *)0 : (void *)0; // expected-warning {{incompatible pointer types assigning to 'int *' from 'double *'}} const int *cip; vp = (0 ? vp : cip); // expected-warning {{discards qualifiers}} @@ -66,5 +66,5 @@ extern int f1(void); int f0(int a) { // GCC considers this a warning. - return a ? f1() : nil; // expected-warning {{pointer/integer type mismatch in conditional expression ('int' and 'void *')}} expected-warning {{incompatible pointer to integer conversion returning 'void *', expected 'int'}} + return a ? f1() : nil; // expected-warning {{pointer/integer type mismatch in conditional expression ('int' and 'void *')}} expected-warning {{incompatible pointer to integer conversion returning 'void *' from a function with result type 'int'}} } diff --git a/test/Sema/conditional.c b/test/Sema/conditional.c index c3dbe1321b..3d7bccaf97 100644 --- a/test/Sema/conditional.c +++ b/test/Sema/conditional.c @@ -6,9 +6,9 @@ void _efree(void *ptr); void free(void *ptr); int _php_stream_free1() { - return (1 ? free(0) : _efree(0)); // expected-error {{incompatible type returning 'void', expected 'int'}} + return (1 ? free(0) : _efree(0)); // expected-error {{returning 'void' from a function with incompatible result type 'int'}} } int _php_stream_free2() { - return (1 ? _efree(0) : free(0)); // expected-error {{incompatible type returning 'void', expected 'int'}} + return (1 ? _efree(0) : free(0)); // expected-error {{returning 'void' from a function with incompatible result type 'int'}} } diff --git a/test/Sema/enum.c b/test/Sema/enum.c index 6177edff91..caab5d3756 100644 --- a/test/Sema/enum.c +++ b/test/Sema/enum.c @@ -91,8 +91,7 @@ static enum e1 badfunc(struct s1 *q) { typedef enum { an_enumerator = 20 } an_enum; -// FIXME: why is this only a warning? -char * s = (an_enum) an_enumerator; // expected-warning {{incompatible integer to pointer conversion initializing 'an_enum', expected 'char *'}} +char * s = (an_enum) an_enumerator; // expected-warning {{incompatible integer to pointer conversion initializing 'char *' from an expression of type 'an_enum'}} // PR4515 enum PR4515 {PR4515a=1u,PR4515b=(PR4515a-2)/2}; diff --git a/test/Sema/ext_vector_casts.c b/test/Sema/ext_vector_casts.c index cbda021cd2..d2976238c0 100644 --- a/test/Sema/ext_vector_casts.c +++ b/test/Sema/ext_vector_casts.c @@ -25,7 +25,7 @@ static void test() { ivec4 = (int4)vec4_3; i = (int)ivec4; // expected-error {{invalid conversion between vector type 'int4' and integer type 'int' of different size}} - i = ivec4; // expected-error {{incompatible type assigning 'int4', expected 'int'}} + i = ivec4; // expected-error {{assigning to 'int' from incompatible type 'int4'}} ivec4 = (int4)ptr; // expected-error {{invalid conversion between vector type 'int4' and scalar type 'int *'}} diff --git a/test/Sema/function-ptr.c b/test/Sema/function-ptr.c index c1ff8e1d7b..ff852725ba 100644 --- a/test/Sema/function-ptr.c +++ b/test/Sema/function-ptr.c @@ -3,9 +3,9 @@ typedef int unary_int_func(int arg); unary_int_func *func; unary_int_func *set_func(void *p) { - func = p; // expected-warning {{converts between void* and function pointer}} - p = func; // expected-warning {{converts between void* and function pointer}} + func = p; // expected-warning {{converts between void pointer and function pointer}} + p = func; // expected-warning {{converts between void pointer and function pointer}} - return p; // expected-warning {{converts between void* and function pointer}} + return p; // expected-warning {{converts between void pointer and function pointer}} } diff --git a/test/Sema/function-redecl.c b/test/Sema/function-redecl.c index 1302b34b10..b8a64af96b 100644 --- a/test/Sema/function-redecl.c +++ b/test/Sema/function-redecl.c @@ -123,7 +123,7 @@ a x; a2 x2; void test_x() { x(5); - x2(5); // expected-warning{{incompatible integer to pointer conversion passing 'int', expected 'int *'}} + x2(5); // expected-warning{{incompatible integer to pointer conversion passing 'int' to parameter of type 'int *'}} } enum e0 {}; diff --git a/test/Sema/incompatible-sign.c b/test/Sema/incompatible-sign.c index a1592efc4c..b3c1e9a44e 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 b(unsigned* y) { return a(y); } // expected-warning {{pointer types point to integer types with different sign}} +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/invalid-init-diag.c b/test/Sema/invalid-init-diag.c index dec7d6c18f..1ade42f31c 100644 --- a/test/Sema/invalid-init-diag.c +++ b/test/Sema/invalid-init-diag.c @@ -1,4 +1,4 @@ // RUN: %clang_cc1 %s -verify -fsyntax-only int a; -struct {int x;} x = a; // expected-error {{incompatible type initializing 'int', expected 'struct (^f) (void)) { } void test1() { - f2(^(Sub *o) { }); // expected-error {{incompatible block pointer types passing 'void (^)(Sub *)', expected 'void (^)(Super *)'}} + f2(^(Sub *o) { }); // expected-error {{incompatible block pointer types passing}} f3(^(Super *o) { }); // OK, block taking Super* may be called with a Sub* r0(^Super* () { return 0; }); // OK r0(^Sub* () { return 0; }); // OK, variable of type Super* gets return value of type Sub* r0(^id () { return 0; }); - r1(^Super* () { return 0; }); // expected-error {{incompatible block pointer types passing 'Super *(^)(void)', expected 'Sub *(^)()'}} + r1(^Super* () { return 0; }); // expected-error {{incompatible block pointer types passing}} r1(^Sub* () { return 0; }); // OK r1(^id () { return 0; }); @@ -97,10 +97,10 @@ void test2(void) @protocol P, P2; void f4(void (^f)(id

x)) { NSArray *b; - f(b); // expected-warning {{incompatible type passing 'NSArray *', expected 'id

'}} + f(b); // expected-warning {{passing 'NSArray *' to parameter of incompatible type 'id

'}} } void test3() { - f4(^(NSArray* a) { }); // expected-error {{incompatible block pointer types passing 'void (^)(NSArray *)', expected 'void (^)(id

)'}} + f4(^(NSArray* a) { }); // expected-error {{incompatible block pointer types passing 'void (^)(NSArray *)' to parameter of type 'void (^)(id

)'}} } diff --git a/test/SemaObjC/blocks.m b/test/SemaObjC/blocks.m index afa3bdf071..10239e5488 100644 --- a/test/SemaObjC/blocks.m +++ b/test/SemaObjC/blocks.m @@ -23,7 +23,7 @@ void foo4(id (^objectCreationBlock)(int)) { void bar5(id(^)(void)); void foo5(id (^objectCreationBlock)(int)) { - return bar5(objectCreationBlock); // expected-error {{incompatible block pointer types passing 'id (^)(int)', expected 'id (^)(void)'}} + return bar5(objectCreationBlock); // expected-error {{incompatible block pointer types passing 'id (^)(int)' to parameter of type 'id (^)(void)'}} } void bar6(id(^)(int)); diff --git a/test/SemaObjC/class-method-self.m b/test/SemaObjC/class-method-self.m index 6f7d1fd93f..ec0edf1200 100644 --- a/test/SemaObjC/class-method-self.m +++ b/test/SemaObjC/class-method-self.m @@ -18,9 +18,9 @@ typedef struct objc_class *Class; static XX *obj; + (void)classMethod { - [obj addObserver:self]; // expected-warning {{incompatible pointer types sending 'Class', expected 'XX *'}} + [obj addObserver:self]; // expected-warning {{incompatible pointer types sending 'Class' to parameter of type 'XX *'}} Class whatever; - [obj addObserver:whatever]; // expected-warning {{incompatible pointer types sending 'Class', expected 'XX *'}} + [obj addObserver:whatever]; // expected-warning {{incompatible pointer types sending 'Class' to parameter of type 'XX *'}} } @end diff --git a/test/SemaObjC/compatible-protocol-qualified-types.m b/test/SemaObjC/compatible-protocol-qualified-types.m index 0df905c9ca..1c9cc2c494 100644 --- a/test/SemaObjC/compatible-protocol-qualified-types.m +++ b/test/SemaObjC/compatible-protocol-qualified-types.m @@ -69,7 +69,7 @@ extern NSString * const XCActiveSelectionLevel; - (NSTextStorage *)contents { - [_contents setDelegate:self]; // expected-warning {{incompatible type sending 'SKTText *', expected 'id'}} + [_contents setDelegate:self]; // expected-warning {{sending 'SKTText *' to parameter of incompatible type 'id'}} return 0; } diff --git a/test/SemaObjC/comptypes-1.m b/test/SemaObjC/comptypes-1.m index 5b1891d4af..98107eef21 100644 --- a/test/SemaObjC/comptypes-1.m +++ b/test/SemaObjC/comptypes-1.m @@ -34,25 +34,25 @@ int main() /* Assigning to a 'MyClass *' variable should always generate a warning, unless done from an 'id'. */ obj_c = obj; /* Ok */ - obj_c = obj_cp; // // expected-warning {{incompatible pointer types assigning 'MyOtherClass *', expected 'MyClass *'}} - obj_c = obj_C; // expected-warning {{incompatible pointer types assigning 'Class', expected 'MyClass *'}} + obj_c = obj_cp; // // expected-warning {{incompatible pointer types assigning to 'MyClass *' from 'MyOtherClass *'}} + obj_c = obj_C; // expected-warning {{incompatible pointer types assigning to 'MyClass *' from 'Class'}} /* Assigning to an 'id' variable should generate a warning if done from a 'MyClass *' (which doesn't implement MyProtocol), but not from an 'id' or from a 'MyOtherClass *' (which implements MyProtocol). */ obj_p = obj; /* Ok */ - obj_p = obj_c; // expected-warning {{incompatible type assigning 'MyClass *', expected 'id'}} + obj_p = obj_c; // expected-warning {{ assigning to 'id' from incompatible type 'MyClass *'}} obj_p = obj_cp; /* Ok */ - obj_p = obj_C; // expected-warning {{incompatible pointer types assigning 'Class', expected 'id'}} + obj_p = obj_C; // expected-warning {{incompatible pointer types assigning to 'id' from 'Class'}} /* Assigning to a 'MyOtherClass *' variable should always generate a warning, unless done from an 'id' or an 'id' (since MyOtherClass implements MyProtocol). */ obj_cp = obj; /* Ok */ - obj_cp = obj_c; // expected-warning {{incompatible pointer types assigning 'MyClass *', expected 'MyOtherClass *'}} + obj_cp = obj_c; // expected-warning {{incompatible pointer types assigning to 'MyOtherClass *' from 'MyClass *'}} obj_cp = obj_p; /* Ok */ - obj_cp = obj_C; // expected-warning {{incompatible pointer types assigning 'Class', expected 'MyOtherClass *'}} + obj_cp = obj_C; // expected-warning {{incompatible pointer types assigning to 'MyOtherClass *' from 'Class'}} /* Any comparison involving an 'id' must be without warnings. */ if (obj == obj_p) foo() ; /* Ok */ /*Bogus warning here in 2.95.4*/ diff --git a/test/SemaObjC/comptypes-3.m b/test/SemaObjC/comptypes-3.m index 94171d11d5..6c1ce419b6 100644 --- a/test/SemaObjC/comptypes-3.m +++ b/test/SemaObjC/comptypes-3.m @@ -26,21 +26,21 @@ int main() id obj_ab = nil; id obj_ac = nil; - obj_a = obj_b; // expected-warning {{incompatible type assigning 'id', expected 'id'}} + obj_a = obj_b; // expected-warning {{assigning to 'id' from incompatible type 'id'}} obj_a = obj_ab; /* Ok */ obj_a = obj_ac; /* Ok */ - obj_b = obj_a; // expected-warning {{incompatible type assigning 'id', expected 'id'}} + obj_b = obj_a; // expected-warning {{assigning to 'id' from incompatible type 'id'}} obj_b = obj_ab; /* Ok */ - obj_b = obj_ac; // expected-warning {{incompatible type assigning 'id', expected 'id'}} + obj_b = obj_ac; // expected-warning {{assigning to 'id' from incompatible type 'id'}} - obj_ab = obj_a; // expected-warning {{incompatible type assigning 'id', expected 'id'}} - obj_ab = obj_b; // expected-warning {{incompatible type assigning 'id', expected 'id'}} - obj_ab = obj_ac; // expected-warning {{incompatible type assigning 'id', expected 'id'}} + obj_ab = obj_a; // expected-warning {{assigning to 'id' from incompatible type 'id'}} + obj_ab = obj_b; // expected-warning {{assigning to 'id' from incompatible type 'id'}} + obj_ab = obj_ac; // expected-warning {{assigning to 'id' from incompatible type 'id'}} - obj_ac = obj_a; // expected-warning {{incompatible type assigning 'id', expected 'id'}} - obj_ac = obj_b; // expected-warning {{incompatible type assigning 'id', expected 'id'}} - obj_ac = obj_ab; // expected-warning {{incompatible type assigning 'id', expected 'id'}} + obj_ac = obj_a; // expected-warning {{assigning to 'id' from incompatible type 'id'}} + obj_ac = obj_b; // expected-warning {{assigning to 'id' from incompatible type 'id'}} + obj_ac = obj_ab; // expected-warning {{assigning to 'id' from incompatible type 'id'}} if (obj_a == obj_b) foo (); // expected-warning {{comparison of distinct pointer types ('id' and 'id')}} if (obj_b == obj_a) foo (); // expected-warning {{comparison of distinct pointer types ('id' and 'id')}} diff --git a/test/SemaObjC/comptypes-6.m b/test/SemaObjC/comptypes-6.m index 2911a390ef..cabf813679 100644 --- a/test/SemaObjC/comptypes-6.m +++ b/test/SemaObjC/comptypes-6.m @@ -9,7 +9,7 @@ extern Object* foo(void); static Derived *test(void) { - Derived *m = foo(); // expected-warning {{incompatible pointer types initializing 'Object *', expected 'Derived *'}} + Derived *m = foo(); // expected-warning {{incompatible pointer types initializing 'Derived *' from an expression of type 'Object *'}} return m; } diff --git a/test/SemaObjC/comptypes-7.m b/test/SemaObjC/comptypes-7.m index 2519c41c82..df627e5300 100644 --- a/test/SemaObjC/comptypes-7.m +++ b/test/SemaObjC/comptypes-7.m @@ -24,27 +24,27 @@ int main() /* These should all generate warnings. */ - obj = i; // expected-warning {{incompatible integer to pointer conversion assigning 'int', expected 'id'}} - obj = j; // expected-warning {{incompatible pointer types assigning 'int *', expected 'id'}} + obj = i; // expected-warning {{incompatible integer to pointer conversion assigning to 'id' from 'int'}} + obj = j; // expected-warning {{incompatible pointer types assigning to 'id' from 'int *'}} - obj_p = i; // expected-warning {{incompatible integer to pointer conversion assigning 'int', expected 'id'}} - obj_p = j; // expected-warning {{incompatible pointer types assigning 'int *', expected 'id'}} + obj_p = i; // expected-warning {{incompatible integer to pointer conversion assigning to 'id' from 'int'}} + obj_p = j; // expected-warning {{ incompatible pointer types assigning to 'id' from 'int *'}} - obj_c = i; // expected-warning {{incompatible integer to pointer conversion assigning 'int', expected 'MyClass *'}} - obj_c = j; // expected-warning {{incompatible pointer types assigning 'int *', expected 'MyClass *'}} + obj_c = i; // expected-warning {{ incompatible integer to pointer conversion assigning to 'MyClass *' from 'int'}} + obj_c = j; // expected-warning {{incompatible pointer types assigning to 'MyClass *' from 'int *'}} - obj_C = i; // expected-warning {{incompatible integer to pointer conversion assigning 'int', expected 'Class'}} - obj_C = j; // expected-warning {{incompatible pointer types assigning 'int *', expected 'Class'}} + obj_C = i; // expected-warning {{incompatible integer to pointer conversion assigning to 'Class' from 'int'}} + obj_C = j; // expected-warning {{incompatible pointer types assigning to 'Class' from 'int *'}} - i = obj; // expected-warning {{incompatible pointer to integer conversion assigning 'id', expected 'int'}} - i = obj_p; // expected-warning {{incompatible pointer to integer conversion assigning 'id', expected 'int'}} - i = obj_c; // expected-warning {{incompatible pointer to integer conversion assigning 'MyClass *', expected 'int'}} - i = obj_C; // expected-warning {{incompatible pointer to integer conversion assigning 'Class', expected 'int'}} + i = obj; // expected-warning {{incompatible pointer to integer conversion assigning to 'int' from 'id'}} + i = obj_p; // expected-warning {{incompatible pointer to integer conversion assigning to 'int' from 'id'}} + i = obj_c; // expected-warning {{incompatible pointer to integer conversion assigning to 'int' from 'MyClass *'}} + i = obj_C; // expected-warning {{incompatible pointer to integer conversion assigning to 'int' from 'Class'}} - j = obj; // expected-warning {{incompatible pointer types assigning 'id', expected 'int *'}} - j = obj_p; // expected-warning {{incompatible pointer types assigning 'id', expected 'int *'}} - j = obj_c; // expected-warning {{incompatible pointer types assigning 'MyClass *', expected 'int *'}} - j = obj_C; // expected-warning {{incompatible pointer types assigning 'Class', expected 'int *'}} + j = obj; // expected-warning {{incompatible pointer types assigning to 'int *' from 'id'}} + j = obj_p; // expected-warning {{ incompatible pointer types assigning to 'int *' from 'id'}} + j = obj_c; // expected-warning {{incompatible pointer types assigning to 'int *' from 'MyClass *'}} + j = obj_C; // expected-warning {{incompatible pointer types assigning to 'int *' from 'Class'}} if (obj == i) foo() ; // expected-warning {{comparison between pointer and integer ('id' and 'int')}} if (i == obj) foo() ; // expected-warning {{comparison between pointer and integer ('int' and 'id')}} diff --git a/test/SemaObjC/comptypes-legal.m b/test/SemaObjC/comptypes-legal.m index 8caf18563b..e318d332f3 100644 --- a/test/SemaObjC/comptypes-legal.m +++ b/test/SemaObjC/comptypes-legal.m @@ -33,5 +33,5 @@ void foo(void) { // GCC currently allows this (it has some fiarly new support for covariant return types and contravariant argument types). // Since registerFunc: expects a Derived object as it's second argument, I don't know why this would be legal. - [Derived registerFunc: ExternFunc]; // expected-warning{{incompatible pointer types sending 'NSObject *(NSObject *, NSObject *)', expected 'FuncSignature *'}} + [Derived registerFunc: ExternFunc]; // expected-warning{{incompatible pointer types sending 'NSObject *(NSObject *, NSObject *)' to parameter of type 'FuncSignature *'}} } diff --git a/test/SemaObjC/conditional-expr-2.m b/test/SemaObjC/conditional-expr-2.m index e97b693dfc..fdf3d1381a 100644 --- a/test/SemaObjC/conditional-expr-2.m +++ b/test/SemaObjC/conditional-expr-2.m @@ -25,5 +25,5 @@ void foo (int i, NSKey *NSKeyValueCoding_NullValue, UpdatesList *nukedUpdatesLis obj = i ? NSKeyValueCoding_NullValue : nukedUpdatesList; // expected-warning{{incompatible operand types ('NSKey *' and 'UpdatesList *')}} key = i ? NSKeyValueCoding_NullValue : nukedUpdatesList; // expected-warning{{incompatible operand types ('NSKey *' and 'UpdatesList *')}} key = i ? NSKeyValueCoding_NullValue : keysub; - keysub = i ? NSKeyValueCoding_NullValue : keysub; // expected-warning{{incompatible pointer types assigning 'NSKey *', expected 'KeySub *'}} + keysub = i ? NSKeyValueCoding_NullValue : keysub; // expected-warning{{incompatible pointer types assigning to 'KeySub *' from 'NSKey *'}} } diff --git a/test/SemaObjC/conditional-expr-3.m b/test/SemaObjC/conditional-expr-3.m index 312f77a15f..9f34ca0e69 100644 --- a/test/SemaObjC/conditional-expr-3.m +++ b/test/SemaObjC/conditional-expr-3.m @@ -27,11 +27,11 @@ void f1(id x, A *a) { } void f2(id x) { - id l = x; // expected-warning {{incompatible type initializing 'id', expected 'id'}} + id l = x; // expected-warning {{initializing 'id' from an expression of incompatible type 'id'}} } void f3(A *a) { - id l = a; // expected-warning {{incompatible type initializing 'A *', expected 'id'}} + id l = a; // expected-warning {{ initializing 'id' from an expression of incompatible type 'A *'}} } void f4(int cond, id x, A *a) { diff --git a/test/SemaObjC/conditional-expr-4.m b/test/SemaObjC/conditional-expr-4.m index 84652e4513..944c1753dd 100644 --- a/test/SemaObjC/conditional-expr-4.m +++ b/test/SemaObjC/conditional-expr-4.m @@ -26,7 +26,7 @@ A *f1_a(int cond, A *a) { } void *f1_const_a(int x, void *p, const A * q) { - void *r = x ? p : q; // expected-warning{{initializing 'void const *' discards qualifiers, expected 'void *'}} + void *r = x ? p : q; // expected-warning{{initializing 'void *' from an expression of type 'void const *' discards qualifiers}} return r; } diff --git a/test/SemaObjC/conditional-expr.m b/test/SemaObjC/conditional-expr.m index 1436f7ee0e..74ab59bdb9 100644 --- a/test/SemaObjC/conditional-expr.m +++ b/test/SemaObjC/conditional-expr.m @@ -27,7 +27,7 @@ @implementation DTFilterOutputStream2 // expected-warning {{incomplete implementation}} - (id)initWithNextOutputStream:(id ) outputStream { id nextOutputStream = [self nextOutputStream]; - self = nextOutputStream; // expected-warning {{incompatible type assigning 'id', expected 'DTFilterOutputStream2 *'}} + self = nextOutputStream; // expected-warning {{assigning to 'DTFilterOutputStream2 *' from incompatible type 'id'}} return nextOutputStream ? nextOutputStream : self; // expected-warning {{incompatible operand types ('id' and 'DTFilterOutputStream2 *')}} } @end @@ -36,7 +36,7 @@ @implementation DTFilterOutputStream3 // expected-warning {{cannot find interface declaration for 'DTFilterOutputStream3'}} - (id)initWithNextOutputStream:(id ) outputStream { id nextOutputStream = [self nextOutputStream]; // expected-warning {{method '-nextOutputStream' not found (return type defaults to 'id')}} - self = nextOutputStream; // expected-warning {{incompatible type assigning 'id', expected 'DTFilterOutputStream3 *'}} + self = nextOutputStream; // expected-warning {{assigning to 'DTFilterOutputStream3 *' from incompatible type 'id'}} return nextOutputStream ? nextOutputStream : self; // expected-warning {{incompatible operand types ('id' and 'DTFilterOutputStream3 *')}} } @end diff --git a/test/SemaObjC/id.m b/test/SemaObjC/id.m index 206127a5cc..27b84dedf8 100644 --- a/test/SemaObjC/id.m +++ b/test/SemaObjC/id.m @@ -9,8 +9,8 @@ void foo() { // Test assignment compatibility of Class and id. No warning should be // produced. // rdar://6770142 - Class and id are compatible. - S = T; // expected-warning {{incompatible pointer types assigning 'Class', expected 'id'}} - T = S; // expected-warning {{incompatible pointer types assigning 'id', expected 'Class'}} + S = T; // expected-warning {{incompatible pointer types assigning to 'id' from 'Class'}} + T = S; // expected-warning {{incompatible pointer types assigning to 'Class' from 'id'}} R = T; T = R; R = S; S = R; } diff --git a/test/SemaObjC/incompatible-protocol-qualified-types.m b/test/SemaObjC/incompatible-protocol-qualified-types.m index 7eb540ad55..23cb50a362 100644 --- a/test/SemaObjC/incompatible-protocol-qualified-types.m +++ b/test/SemaObjC/incompatible-protocol-qualified-types.m @@ -21,15 +21,15 @@ INTF * Func1(INTF *p2) INTF * Func2(INTF *p2) { - Func(p2); // expected-warning {{incompatible pointer types passing 'INTF *', expected 'INTF *}} - return p2; // expected-warning {{incompatible pointer types returning 'INTF *', expected 'INTF *}} + Func(p2); // expected-warning {{incompatible pointer types passing 'INTF *' to parameter of type 'INTF *'}} + return p2; // expected-warning {{incompatible pointer types returning 'INTF *' from a function with result type 'INTF *'}} } INTF * Func3(INTF *p2) { - return p2; // expected-warning {{incompatible pointer types returning 'INTF *', expected 'INTF *}} + return p2; // expected-warning {{incompatible pointer types returning 'INTF *' from a function with result type 'INTF *'}} } diff --git a/test/SemaObjC/message.m b/test/SemaObjC/message.m index 57b1097962..fc4bfcc95c 100644 --- a/test/SemaObjC/message.m +++ b/test/SemaObjC/message.m @@ -87,7 +87,7 @@ struct S { int X; } S; int test5(int X) { int a = [X somemsg]; // expected-warning {{receiver type 'int' is not 'id'}} \ expected-warning {{method '-somemsg' not found}} \ - expected-warning {{incompatible pointer to integer conversion initializing 'id', expected 'int'}} + expected-warning {{incompatible pointer to integer conversion initializing 'int' from an expression of type 'id'}} int b = [S somemsg]; // expected-error {{bad receiver type 'struct S'}} } diff --git a/test/SemaObjC/method-arg-qualifier-warning.m b/test/SemaObjC/method-arg-qualifier-warning.m index 397f24135f..a064a7d7a5 100644 --- a/test/SemaObjC/method-arg-qualifier-warning.m +++ b/test/SemaObjC/method-arg-qualifier-warning.m @@ -12,8 +12,8 @@ static NSString * const Identifier3 = @"Identifier3"; int main () { - [@"Identifier1" isEqualToString:Identifier1]; // expected-warning {{sending 'NSString const *' discards qualifiers, expected 'NSString *'}} - [@"Identifier2" isEqualToString:Identifier2]; // expected-warning {{sending 'NSString const *' discards qualifiers, expected 'NSString *'}} + [@"Identifier1" isEqualToString:Identifier1]; // expected-warning {{sending 'NSString const *' to parameter of type 'NSString *' discards qualifiers}} + [@"Identifier2" isEqualToString:Identifier2]; // expected-warning {{sending 'NSString const *' to parameter of type 'NSString *' discards qualifiers}} [@"Identifier3" isEqualToString:Identifier3]; return 0; } diff --git a/test/SemaObjC/protocol-id-test-3.m b/test/SemaObjC/protocol-id-test-3.m index 3538b0e05e..89f11c3d75 100644 --- a/test/SemaObjC/protocol-id-test-3.m +++ b/test/SemaObjC/protocol-id-test-3.m @@ -29,15 +29,15 @@ id Func(INTF *p2) id Gunc2(id p2) { - Func(p2); // expected-warning {{incompatible type passing 'id', expected 'INTF *'}} - return p2; // expected-warning {{incompatible type returning 'id', expected 'id'}} + Func(p2); // expected-warning {{passing 'id' to parameter of incompatible type 'INTF *'}} + return p2; // expected-warning {{returning 'id' from a function with incompatible result type 'id'}} } id Gunc3(id p2) { - return p2; // expected-warning {{incompatible type returning 'id', expected 'id'}} + return p2; // expected-warning {{returning 'id' from a function with incompatible result type 'id'}} } @@ -61,13 +61,13 @@ INTF * Hunc1(id p2) INTF * Hunc2(id p2) { - Func(p2); // expected-warning {{incompatible type passing 'id', expected 'INTF *'}} - return p2; // expected-warning {{incompatible type returning 'id', expected 'INTF *'}} + Func(p2); // expected-warning {{passing 'id' to parameter of incompatible type 'INTF *'}} + return p2; // expected-warning {{returning 'id' from a function with incompatible result type 'INTF *'}} } INTF * Hunc3(id p2) { - return p2; // expected-warning {{incompatible type returning 'id', expected 'INTF *'}} + return p2; // expected-warning {{returning 'id' from a function with incompatible result type 'INTF *'}} } diff --git a/test/SemaObjC/protocol-typecheck.m b/test/SemaObjC/protocol-typecheck.m index d9cde87d4c..3d98df8aab 100644 --- a/test/SemaObjC/protocol-typecheck.m +++ b/test/SemaObjC/protocol-typecheck.m @@ -20,6 +20,6 @@ void func() { [obj setFlexElement:flexer]; // FIXME: GCC provides the following diagnostic (which is much better): // protocol-typecheck.m:21: warning: class 'NSObject ' does not implement the 'XCElementSpacerP' protocol - [obj setFlexElement2:flexer2]; // expected-warning{{incompatible pointer types sending 'NSObject *', expected 'NSObject *'}} + [obj setFlexElement2:flexer2]; // expected-warning{{incompatible pointer types sending 'NSObject *' to parameter of type 'NSObject *'}} } diff --git a/test/SemaObjC/protocol-warn.m b/test/SemaObjC/protocol-warn.m index d0c51e3ffa..2d04238058 100644 --- a/test/SemaObjC/protocol-warn.m +++ b/test/SemaObjC/protocol-warn.m @@ -51,5 +51,5 @@ UIWebPDFView *getView() { UIWebBrowserView *browserView; UIWebPDFView *pdfView; - return pdfView ? pdfView : browserView; // expected-warning {{incompatible pointer types returning 'UIView *', expected 'UIWebPDFView *'}} + return pdfView ? pdfView : browserView; // expected-warning {{incompatible pointer types returning 'UIView *' from a function with result type 'UIWebPDFView *'}} } diff --git a/test/SemaObjC/warn-incompatible-builtin-types.m b/test/SemaObjC/warn-incompatible-builtin-types.m index 2a5005a396..8806d63baa 100644 --- a/test/SemaObjC/warn-incompatible-builtin-types.m +++ b/test/SemaObjC/warn-incompatible-builtin-types.m @@ -10,8 +10,8 @@ void FUNC() { SEL s1, s2; id i, i1; Foo *f; - [f foo:f]; // expected-warning {{incompatible pointer types sending 'Foo *', expected 'Class'}} - c = f; // expected-warning {{incompatible pointer types assigning 'Foo *', expected 'Class'}} + [f foo:f]; // expected-warning {{incompatible pointer types sending 'Foo *' to parameter of type 'Class'}} + c = f; // expected-warning {{incompatible pointer types assigning to 'Class' from 'Foo *'}} c = i; @@ -21,22 +21,22 @@ void FUNC() { i = i1; - s1 = i; // expected-warning {{incompatible pointer types assigning 'id', expected 'SEL'}} - i = s1; // expected-warning {{incompatible pointer types assigning 'SEL', expected 'id'}} + s1 = i; // expected-warning {{incompatible pointer types assigning to 'SEL' from 'id'}} + i = s1; // expected-warning {{incompatible pointer types assigning to 'id' from 'SEL'}} s1 = s2; - s1 = c; // expected-warning {{incompatible pointer types assigning 'Class', expected 'SEL'}} + s1 = c; // expected-warning {{incompatible pointer types assigning to 'SEL' from 'Class'}} - c = s1; // expected-warning {{incompatible pointer types assigning 'SEL', expected 'Class'}} + c = s1; // expected-warning {{incompatible pointer types assigning to 'Class' from 'SEL'}} f = i; - f = c; // expected-warning {{incompatible pointer types assigning 'Class', expected 'Foo *'}} + f = c; // expected-warning {{incompatible pointer types assigning to 'Foo *' from 'Class'}} - f = s1; // expected-warning {{incompatible pointer types assigning 'SEL', expected 'Foo *'}} + f = s1; // expected-warning {{incompatible pointer types assigning to 'Foo *' from 'SEL'}} i = f; - s1 = f; // expected-warning {{incompatible pointer types assigning 'Foo *', expected 'SEL'}} + s1 = f; // expected-warning {{incompatible pointer types assigning to 'SEL' from 'Foo *'}} } diff --git a/test/SemaObjC/warn-write-strings.m b/test/SemaObjC/warn-write-strings.m index 938f0be772..c0b7741125 100644 --- a/test/SemaObjC/warn-write-strings.m +++ b/test/SemaObjC/warn-write-strings.m @@ -1,4 +1,4 @@ // RUN: %clang_cc1 -verify -fsyntax-only -Wwrite-strings %s // PR4804 -char* x = "foo"; // expected-warning {{initializing 'char const [4]' discards qualifiers, expected 'char *'}} +char* x = "foo"; // expected-warning {{initializing 'char *' from an expression of type 'char const [4]' discards qualifiers}} diff --git a/test/SemaObjCXX/blocks.mm b/test/SemaObjCXX/blocks.mm index 72de171336..fd0df4e6e2 100644 --- a/test/SemaObjCXX/blocks.mm +++ b/test/SemaObjCXX/blocks.mm @@ -3,12 +3,12 @@ void bar(id(^)(void)); void foo(id (^objectCreationBlock)(void)) { - return bar(objectCreationBlock); // expected-warning{{incompatible pointer types converting 'id (^)()', expected 'id (^)()'}} + return bar(objectCreationBlock); // expected-warning{{incompatible pointer types converting 'id (^)()' to type 'id (^)()'}} } void bar2(id(*)(void)); void foo2(id (*objectCreationBlock)(void)) { - return bar2(objectCreationBlock); // expected-warning{{incompatible pointer types converting 'id (*)()', expected 'id (*)()'}} + return bar2(objectCreationBlock); // expected-warning{{incompatible pointer types converting 'id (*)()' to type 'id (*)()'}} } void bar3(id(*)()); // expected-note{{candidate function}} diff --git a/test/SemaObjCXX/objc-pointer-conv.mm b/test/SemaObjCXX/objc-pointer-conv.mm index 144bda4390..02ed58b012 100644 --- a/test/SemaObjCXX/objc-pointer-conv.mm +++ b/test/SemaObjCXX/objc-pointer-conv.mm @@ -32,7 +32,7 @@ void RandomFunc(CFMDRef theDict, const void *key, const void *value); void Func (I* arg); // expected-note {{candidate function not viable: no known conversion from 'I const *' to 'I *' for 1st argument}} void foo(const I *p, I* sel) { - [sel Meth : p]; // expected-error {{incompatible type sending 'I const *', expected 'I *'}} + [sel Meth : p]; // expected-error {{sending 'I const *' to parameter of incompatible type 'I *'}} Func(p); // expected-error {{no matching function for call to 'Func'}} } diff --git a/test/SemaObjCXX/void_to_obj.mm b/test/SemaObjCXX/void_to_obj.mm index 932827e614..52510c84f1 100644 --- a/test/SemaObjCXX/void_to_obj.mm +++ b/test/SemaObjCXX/void_to_obj.mm @@ -7,5 +7,5 @@ void func() { XX *obj; void *vv; - obj = vv; // expected-error{{incompatible type assigning 'void *', expected 'XX *'}} + obj = vv; // expected-error{{assigning to 'XX *' from incompatible type 'void *'}} } diff --git a/test/SemaTemplate/fun-template-def.cpp b/test/SemaTemplate/fun-template-def.cpp index 1c9b232f6d..309921c0a6 100644 --- a/test/SemaTemplate/fun-template-def.cpp +++ b/test/SemaTemplate/fun-template-def.cpp @@ -42,7 +42,7 @@ T f1(T t1, U u1, int i1) dummy d1 = sizeof(t1); // expected-error {{no viable conversion}} dummy d2 = offsetof(T, foo); // expected-error {{no viable conversion}} dummy d3 = __alignof(u1); // expected-error {{no viable conversion}} - i1 = typeid(t1); // expected-error {{incompatible type assigning}} + i1 = typeid(t1); // expected-error {{assigning to 'int' from incompatible type 'std::type_info const'}} return u1; } diff --git a/test/SemaTemplate/instantiate-member-class.cpp b/test/SemaTemplate/instantiate-member-class.cpp index 44f396e47a..938c57b75e 100644 --- a/test/SemaTemplate/instantiate-member-class.cpp +++ b/test/SemaTemplate/instantiate-member-class.cpp @@ -18,8 +18,8 @@ X::X *xi; // expected-error{{qualified reference to 'X' is a constructor na X::X *xf; // expected-error{{qualified reference to 'X' is a constructor name rather than a type wherever a constructor can be declared}} void test_naming() { - c1 = c2; // expected-error{{incompatible type assigning 'X::C *', expected 'X::C *'}} - xi = xf; // expected-error{{incompatible type assigning}} + c1 = c2; // expected-error{{assigning to 'X::C *' from incompatible type 'X::C *'}} + xi = xf; // expected-error{{assigning to 'X::X *' from incompatible type 'X::X *'}} // FIXME: error above doesn't print the type X::X cleanly! } -- 2.40.0