From e9f5581ad479e2c53703d5799828399249a4be65 Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Wed, 7 Apr 2010 00:22:00 +0000 Subject: [PATCH] Improve on diagnostics when an objc class is used as a stand-alone type declaration. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100588 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Basic/DiagnosticSemaKinds.td | 3 ++- test/Parser/objc-init.m | 2 +- test/SemaObjC/blocks.m | 8 ++++---- test/SemaObjC/invalid-objc-decls-1.m | 4 ++-- test/SemaObjC/method-bad-param.m | 12 ++++++------ 5 files changed, 15 insertions(+), 14 deletions(-) diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index ebd3a4e252..a2f7147e44 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/include/clang/Basic/DiagnosticSemaKinds.td @@ -215,7 +215,8 @@ def ext_typedef_without_a_name : ExtWarn<"typedef requires a name">; def err_statically_allocated_object : Error< "interface type cannot be statically allocated">; def err_object_cannot_be_passed_returned_by_value : Error< - "interface type %1 cannot be %select{returned|passed}0 by value">; + "interface type %1 cannot be %select{returned|passed}0 by value" + "; did you forget * in %1">; def warn_enum_value_overflow : Warning<"overflow in enumeration value">; def warn_pragma_pack_invalid_alignment : Warning< "expected #pragma pack parameter to be '1', '2', '4', '8', or '16'">; diff --git a/test/Parser/objc-init.m b/test/Parser/objc-init.m index 0c23aebc87..0024f0278f 100644 --- a/test/Parser/objc-init.m +++ b/test/Parser/objc-init.m @@ -14,7 +14,7 @@ void test1() { id objects[] = {[NSNumber METH]}; } -void test2(NSNumber x) { // expected-error {{Objective-C interface type 'NSNumber' cannot be passed by value}} +void test2(NSNumber x) { // expected-error {{Objective-C interface type 'NSNumber' cannot be passed by value; did you forget * in 'NSNumber'}} id objects[] = {[x METH]}; } diff --git a/test/SemaObjC/blocks.m b/test/SemaObjC/blocks.m index ddac7d1759..afa3bdf071 100644 --- a/test/SemaObjC/blocks.m +++ b/test/SemaObjC/blocks.m @@ -39,10 +39,10 @@ void foo7(id (^x)(int)) { @end void foo8() { - void *P = ^(itf x) {}; // expected-error {{Objective-C interface type 'itf' cannot be passed by value}} - P = ^itf(int x) {}; // expected-error {{Objective-C interface type 'itf' cannot be returned by value}} - P = ^itf() {}; // expected-error {{Objective-C interface type 'itf' cannot be returned by value}} - P = ^itf{}; // expected-error {{Objective-C interface type 'itf' cannot be returned by value}} + void *P = ^(itf x) {}; // expected-error {{Objective-C interface type 'itf' cannot be passed by value; did you forget * in 'itf'}} + P = ^itf(int x) {}; // expected-error {{Objective-C interface type 'itf' cannot be returned by value; did you forget * in 'itf'}} + P = ^itf() {}; // expected-error {{Objective-C interface type 'itf' cannot be returned by value; did you forget * in 'itf'}} + P = ^itf{}; // expected-error {{Objective-C interface type 'itf' cannot be returned by value; did you forget * in 'itf'}} } diff --git a/test/SemaObjC/invalid-objc-decls-1.m b/test/SemaObjC/invalid-objc-decls-1.m index 2f3be285df..91bd8a8c86 100644 --- a/test/SemaObjC/invalid-objc-decls-1.m +++ b/test/SemaObjC/invalid-objc-decls-1.m @@ -27,8 +27,8 @@ struct whatever { } @end -Super foo( // expected-error{{interface interface type 'Super' cannot be returned by value}} - Super parm1) { // expected-error{{interface interface type 'Super' cannot be passed by value}} +Super foo( // expected-error{{interface interface type 'Super' cannot be returned by value; did you forget * in 'Super'}} + Super parm1) { // expected-error{{interface interface type 'Super' cannot be passed by value; did you forget * in 'Super'}} Super p1; // expected-error{{interface type cannot be statically allocated}} return p1; } diff --git a/test/SemaObjC/method-bad-param.m b/test/SemaObjC/method-bad-param.m index c1509bf9f6..324ed342f9 100644 --- a/test/SemaObjC/method-bad-param.m +++ b/test/SemaObjC/method-bad-param.m @@ -7,21 +7,21 @@ @end @interface bar --(void) my_method:(foo) my_param; // expected-error {{Objective-C interface type 'foo' cannot be passed by value}} -- (foo)cccccc:(long)ddddd; // expected-error {{Objective-C interface type 'foo' cannot be returned by value}} +-(void) my_method:(foo) my_param; // expected-error {{Objective-C interface type 'foo' cannot be passed by value; did you forget * in 'foo'}} +- (foo)cccccc:(long)ddddd; // expected-error {{Objective-C interface type 'foo' cannot be returned by value; did you forget * in 'foo'}} @end @implementation bar --(void) my_method:(foo) my_param // expected-error {{Objective-C interface type 'foo' cannot be passed by value}} +-(void) my_method:(foo) my_param // expected-error {{Objective-C interface type 'foo' cannot be passed by value; did you forget * in 'foo'}} { } -- (foo)cccccc:(long)ddddd // expected-error {{Objective-C interface type 'foo' cannot be returned by value}} +- (foo)cccccc:(long)ddddd // expected-error {{Objective-C interface type 'foo' cannot be returned by value; did you forget * in 'foo'}} { } @end -void somefunc(foo x) {} // expected-error {{Objective-C interface type 'foo' cannot be passed by value}} -foo somefunc2() {} // expected-error {{Objective-C interface type 'foo' cannot be returned by value}} +void somefunc(foo x) {} // expected-error {{Objective-C interface type 'foo' cannot be passed by value; did you forget * in 'foo'}} +foo somefunc2() {} // expected-error {{Objective-C interface type 'foo' cannot be returned by value; did you forget * in 'foo'}} // rdar://6780761 void f0(foo *a0) { -- 2.40.0