summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve Naroff <snaroff@apple.com>2009-03-03 21:16:54 +0000
committerSteve Naroff <snaroff@apple.com>2009-03-03 21:16:54 +0000
commit27ed6f67668ae605a2441f5193c5921a95ceff3b (patch)
tree434e546956ac6fddcd611996ea3159b975823d17
parent39d6fba0d630a4895a7e227b5ea52992cbcd13b3 (diff)
downloadbcm5719-llvm-27ed6f67668ae605a2441f5193c5921a95ceff3b.tar.gz
bcm5719-llvm-27ed6f67668ae605a2441f5193c5921a95ceff3b.zip
Fix <rdar://problem/6252237> [sema] qualified id should be disallowed in @catch statements.
llvm-svn: 65969
-rw-r--r--clang/include/clang/Basic/DiagnosticSemaKinds.def2
-rw-r--r--clang/lib/Sema/SemaStmt.cpp11
-rw-r--r--clang/test/SemaObjC/catch-stmt.m3
3 files changed, 13 insertions, 3 deletions
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.def b/clang/include/clang/Basic/DiagnosticSemaKinds.def
index c02ee6e538c..f1495a2ef41 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.def
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.def
@@ -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
diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp
index 7e7edbe51ad..12db4337683 100644
--- a/clang/lib/Sema/SemaStmt.cpp
+++ b/clang/lib/Sema/SemaStmt.cpp
@@ -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);
diff --git a/clang/test/SemaObjC/catch-stmt.m b/clang/test/SemaObjC/catch-stmt.m
index 9aa6e057f4f..33ad9ddc813 100644
--- a/clang/test/SemaObjC/catch-stmt.m
+++ b/clang/test/SemaObjC/catch-stmt.m
@@ -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}}
}
}
OpenPOWER on IntegriCloud