]> granicus.if.org Git - clang/commitdiff
Diagnose use of incomplete type on method argument type of
authorFariborz Jahanian <fjahanian@apple.com>
Fri, 17 Sep 2010 22:07:07 +0000 (22:07 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Fri, 17 Sep 2010 22:07:07 +0000 (22:07 +0000)
method definitions instead of crashing in code gen.
Fixes radar 8421082.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@114223 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDeclObjC.cpp
test/SemaObjC/method-bad-param.m

index a6902a3e391c8a15246525aec9d8751b1e4caee5..98c676b5cf97758d17e5d6b2ff60d655ed8aea9e 100644 (file)
@@ -55,9 +55,15 @@ void Sema::ActOnStartOfObjCMethodDef(Scope *FnBodyScope, Decl *D) {
 
   // Introduce all of the other parameters into this scope.
   for (ObjCMethodDecl::param_iterator PI = MDecl->param_begin(),
-       E = MDecl->param_end(); PI != E; ++PI)
+       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 ((*PI)->getIdentifier())
       PushOnScopeChains(*PI, FnBodyScope);
+  }
 }
 
 Decl *Sema::
index 324ed342f9188a611be0b4ec53b78c1c1499f0e1..388e44724d5b68510caf37301b31b76ba2b57a70 100644 (file)
@@ -28,3 +28,17 @@ void f0(foo *a0) {
   extern void g0(int x, ...);
   g0(1, *(foo*)0);  // expected-error {{cannot pass object with interface type 'foo' by-value through variadic function}}
 }
+
+// rdar://8421082
+enum bogus; // expected-note {{forward declaration of 'enum bogus'}}
+
+@interface fee  {
+}
+- (void)crashMe:(enum bogus)p;
+@end
+
+@implementation fee
+- (void)crashMe:(enum bogus)p { // expected-error {{variable has incomplete type 'enum bogus'}}
+}
+@end
+