[cfe-commits] r65969 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.def lib/Sema/SemaStmt.cpp test/SemaObjC/catch-stmt.m

Steve Naroff snaroff at apple.com
Tue Mar 3 13:16:56 PST 2009


Author: snaroff
Date: Tue Mar  3 15:16:54 2009
New Revision: 65969

URL: http://llvm.org/viewvc/llvm-project?rev=65969&view=rev
Log:
Fix <rdar://problem/6252237> [sema] qualified id should be disallowed in @catch statements.

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

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.def?rev=65969&r1=65968&r2=65969&view=diff

==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.def (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.def Tue Mar  3 15:16:54 2009
@@ -962,6 +962,8 @@
      "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

Modified: cfe/trunk/lib/Sema/SemaStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmt.cpp?rev=65969&r1=65968&r2=65969&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaStmt.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmt.cpp Tue Mar  3 15:16:54 2009
@@ -968,9 +968,14 @@
   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);

Modified: cfe/trunk/test/SemaObjC/catch-stmt.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/catch-stmt.m?rev=65969&r1=65968&r2=65969&view=diff

==============================================================================
--- cfe/trunk/test/SemaObjC/catch-stmt.m (original)
+++ cfe/trunk/test/SemaObjC/catch-stmt.m Tue Mar  3 15:16:54 2009
@@ -1,10 +1,13 @@
 // RUN: clang -verify %s
 
+ at 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}}
   }
 }
 





More information about the cfe-commits mailing list