]> granicus.if.org Git - clang/commitdiff
Fix <rdar://problem/6252237> [sema] qualified id should be disallowed in @catch state...
authorSteve Naroff <snaroff@apple.com>
Tue, 3 Mar 2009 21:16:54 +0000 (21:16 +0000)
committerSteve Naroff <snaroff@apple.com>
Tue, 3 Mar 2009 21:16:54 +0000 (21:16 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65969 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/DiagnosticSemaKinds.def
lib/Sema/SemaStmt.cpp
test/SemaObjC/catch-stmt.m

index c02ee6e538ce3e77f15c6e265ad07d76824d2d35..f1495a2ef412206c0d653a310d825a6add5871b5 100644 (file)
@@ -962,6 +962,8 @@ DIAG(err_attribute_multiple_objc_gc, ERROR,
      "multiple garbage collection attributes specified for type")
 DIAG(err_catch_param_not_objc_type, ERROR,
      "@catch parameter is not an Objective-C class type")
+DIAG(warn_ignoring_qualifiers_on_catch_parm, WARNING,
+     "ignoring qualifiers on @catch parameter")
 
 
 // C++ casts
index 7e7edbe51ad10861ef6ee6e7a711834c41ec9196..12db4337683009c435687b151b256137023c8d53 100644 (file)
@@ -968,9 +968,14 @@ Sema::ActOnObjCAtCatchStmt(SourceLocation AtLoc,
   ParmVarDecl *PVD = static_cast<ParmVarDecl*>(Parm);
   
   // PVD == 0 implies @catch(...).
-  if (PVD && !Context.isObjCObjectPointerType(PVD->getType()))
-    return StmtError(Diag(PVD->getLocation(), 
-                          diag::err_catch_param_not_objc_type));
+  if (PVD) {
+    if (!Context.isObjCObjectPointerType(PVD->getType()))
+      return StmtError(Diag(PVD->getLocation(), 
+                       diag::err_catch_param_not_objc_type));
+    if (PVD->getType()->isObjCQualifiedIdType())
+      return StmtError(Diag(PVD->getLocation(), 
+                       diag::warn_ignoring_qualifiers_on_catch_parm));
+  }
     
   ObjCAtCatchStmt *CS = new (Context) ObjCAtCatchStmt(AtLoc, RParen,
     PVD, static_cast<Stmt*>(Body.release()), CatchList);
index 9aa6e057f4fded3841d98ca57d935d5d173d9759..33ad9ddc813fb71f8440ace351ae5f0d9996aa26 100644 (file)
@@ -1,10 +1,13 @@
 // RUN: clang -verify %s
 
+@protocol P;
+
 void f() {
   @try {
   } @catch (void a) { // expected-error{{@catch parameter is not an Objective-C class type}}
   } @catch (int) { // expected-error{{@catch parameter is not an Objective-C class type}}
   } @catch (int *b) { // expected-error{{@catch parameter is not an Objective-C class type}}
+  } @catch (id <P> c) { // expected-warning{{ignoring qualifiers on @catch parameter}}
   }
 }