diff options
| -rw-r--r-- | clang/include/clang/Basic/DiagnosticKinds.def | 2 | ||||
| -rw-r--r-- | clang/lib/Sema/SemaDeclObjC.cpp | 5 | ||||
| -rw-r--r-- | clang/test/SemaObjC/method-bad-param.m | 18 | 
3 files changed, 25 insertions, 0 deletions
diff --git a/clang/include/clang/Basic/DiagnosticKinds.def b/clang/include/clang/Basic/DiagnosticKinds.def index e1f0685d742..fd5215e0cc9 100644 --- a/clang/include/clang/Basic/DiagnosticKinds.def +++ b/clang/include/clang/Basic/DiagnosticKinds.def @@ -416,6 +416,8 @@ DIAG(err_expected_asm_operand, ERROR,       "expected string literal or '[' for asm operand")  DIAG(err_expected_selector_for_method, ERROR,       "expected selector for Objective-C method") +DIAG(err_object_as_method_param, ERROR, +     "can not use an object as parameter to a method")  DIAG(err_nsobject_attribute, ERROR,       "__attribute ((NSObject)) is for pointer types only") diff --git a/clang/lib/Sema/SemaDeclObjC.cpp b/clang/lib/Sema/SemaDeclObjC.cpp index f6a245a3172..d140b908a80 100644 --- a/clang/lib/Sema/SemaDeclObjC.cpp +++ b/clang/lib/Sema/SemaDeclObjC.cpp @@ -1349,6 +1349,11 @@ Sema::DeclTy *Sema::ActOnMethodDeclaration(        }        else if (argType->isFunctionType())          argType = Context.getPointerType(argType); +      else if (argType->isObjCInterfaceType()) { +        // FIXME! provide more precise location for the parameter +        Diag(MethodLoc, diag::err_object_as_method_param); +        return 0; +      }      } else        argType = Context.getObjCIdType();      ParmVarDecl* Param; diff --git a/clang/test/SemaObjC/method-bad-param.m b/clang/test/SemaObjC/method-bad-param.m new file mode 100644 index 00000000000..34f71e76a5c --- /dev/null +++ b/clang/test/SemaObjC/method-bad-param.m @@ -0,0 +1,18 @@ +// RUN: clang -fsyntax-only -verify %s + +@interface foo +@end + +@implementation foo +@end + +@interface bar +-(void) my_method:(foo) my_param; // expected-error {{can not use an object as parameter to a method}} +@end + +@implementation bar +-(void) my_method:(foo) my_param  // expected-error {{can not use an object as parameter to a method}} +{ +} +@end +  | 

