From: Reid Kleckner Date: Mon, 24 Jun 2013 14:38:26 +0000 (+0000) Subject: [Sema] Call CheckParmForFunctionDef on ObjC method parameters X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8c0501c7370d894a735692b92fab62bbb05d86bd;p=clang [Sema] Call CheckParmForFunctionDef on ObjC method parameters CheckParmForFunctionDef performs standard checks for type completeness and other things like a destructor check for the MSVC++ ABI. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@184740 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Sema/Sema.h b/include/clang/Sema/Sema.h index 71e2aaf5de..82de36908c 100644 --- a/include/clang/Sema/Sema.h +++ b/include/clang/Sema/Sema.h @@ -2244,7 +2244,8 @@ public: CallExpr *CE, FunctionDecl *FD); /// Helpers for dealing with blocks and functions. - bool CheckParmsForFunctionDef(ParmVarDecl **Param, ParmVarDecl **ParamEnd, + bool CheckParmsForFunctionDef(ParmVarDecl *const *Param, + ParmVarDecl *const *ParamEnd, bool CheckParameterNames); void CheckCXXDefaultArguments(FunctionDecl *FD); void CheckExtraCXXDefaultArguments(Declarator &D); diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp index 163d5fe849..996f20cc91 100644 --- a/lib/Sema/SemaChecking.cpp +++ b/lib/Sema/SemaChecking.cpp @@ -5758,7 +5758,8 @@ void Sema::CheckBitFieldInitialization(SourceLocation InitLoc, /// takes care of any checks that cannot be performed on the /// declaration itself, e.g., that the types of each of the function /// parameters are complete. -bool Sema::CheckParmsForFunctionDef(ParmVarDecl **P, ParmVarDecl **PEnd, +bool Sema::CheckParmsForFunctionDef(ParmVarDecl *const *P, + ParmVarDecl *const *PEnd, bool CheckParameterNames) { bool HasInvalidParm = false; for (; P != PEnd; ++P) { diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp index 8ce4ef3e4b..a818d37459 100644 --- a/lib/Sema/SemaDeclObjC.cpp +++ b/lib/Sema/SemaDeclObjC.cpp @@ -324,14 +324,14 @@ void Sema::ActOnStartOfObjCMethodDef(Scope *FnBodyScope, Decl *D) { PushOnScopeChains(MDecl->getSelfDecl(), FnBodyScope); PushOnScopeChains(MDecl->getCmdDecl(), FnBodyScope); + // The ObjC parser requires parameter names so there's no need to check. + CheckParmsForFunctionDef(MDecl->param_begin(), MDecl->param_end(), + /*CheckParameterNames=*/false); + // Introduce all of the other parameters into this scope. for (ObjCMethodDecl::param_iterator PI = MDecl->param_begin(), E = MDecl->param_end(); PI != E; ++PI) { ParmVarDecl *Param = (*PI); - if (!Param->isInvalidDecl() && - RequireCompleteType(Param->getLocation(), Param->getType(), - diag::err_typecheck_decl_incomplete_type)) - Param->setInvalidDecl(); if (!Param->isInvalidDecl() && getLangOpts().ObjCAutoRefCount && !HasExplicitOwnershipAttr(*this, Param)) diff --git a/test/SemaObjC/method-bad-param.m b/test/SemaObjC/method-bad-param.m index 30aba7b9d0..ad67a34edb 100644 --- a/test/SemaObjC/method-bad-param.m +++ b/test/SemaObjC/method-bad-param.m @@ -46,3 +46,13 @@ enum bogus; // expected-note {{forward declaration of 'enum bogus'}} - (int[6])arrayRet; // expected-error {{function cannot return array type 'int [6]'}} - (int())funcRet; // expected-error {{function cannot return function type 'int ()'}} @end + +@interface qux +- (void) my_method: (int)arg; // expected-note {{method 'my_method:' declared here}} +@end + +// FIXME: The diagnostic and recovery here could probably be improved. +@implementation qux // expected-warning {{method definition for 'my_method:' not found}} +- (void) my_method: (int) { // expected-error {{expected identifier}} +} +@end diff --git a/test/SemaObjCXX/microsoft-abi-byval.mm b/test/SemaObjCXX/microsoft-abi-byval.mm new file mode 100644 index 0000000000..f0c4caa9e0 --- /dev/null +++ b/test/SemaObjCXX/microsoft-abi-byval.mm @@ -0,0 +1,14 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -cxx-abi microsoft -Wno-objc-root-class %s + +class Foo { + ~Foo(); // expected-note {{implicitly declared private here}} +}; + +@interface bar +- (void) my_method: (Foo)arg; +@end + +@implementation bar +- (void) my_method: (Foo)arg { // expected-error {{variable of type 'Foo' has private destructor}} +} +@end