forked from OSchip/llvm-project
Fix <rdar://problem/6252237> [sema] qualified id should be disallowed in @catch statements.
llvm-svn: 65969
This commit is contained in:
parent
39d6fba0d6
commit
27ed6f6766
|
@ -962,6 +962,8 @@ DIAG(err_attribute_multiple_objc_gc, ERROR,
|
||||||
"multiple garbage collection attributes specified for type")
|
"multiple garbage collection attributes specified for type")
|
||||||
DIAG(err_catch_param_not_objc_type, ERROR,
|
DIAG(err_catch_param_not_objc_type, ERROR,
|
||||||
"@catch parameter is not an Objective-C class type")
|
"@catch parameter is not an Objective-C class type")
|
||||||
|
DIAG(warn_ignoring_qualifiers_on_catch_parm, WARNING,
|
||||||
|
"ignoring qualifiers on @catch parameter")
|
||||||
|
|
||||||
|
|
||||||
// C++ casts
|
// C++ casts
|
||||||
|
|
|
@ -968,9 +968,14 @@ Sema::ActOnObjCAtCatchStmt(SourceLocation AtLoc,
|
||||||
ParmVarDecl *PVD = static_cast<ParmVarDecl*>(Parm);
|
ParmVarDecl *PVD = static_cast<ParmVarDecl*>(Parm);
|
||||||
|
|
||||||
// PVD == 0 implies @catch(...).
|
// PVD == 0 implies @catch(...).
|
||||||
if (PVD && !Context.isObjCObjectPointerType(PVD->getType()))
|
if (PVD) {
|
||||||
return StmtError(Diag(PVD->getLocation(),
|
if (!Context.isObjCObjectPointerType(PVD->getType()))
|
||||||
diag::err_catch_param_not_objc_type));
|
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,
|
ObjCAtCatchStmt *CS = new (Context) ObjCAtCatchStmt(AtLoc, RParen,
|
||||||
PVD, static_cast<Stmt*>(Body.release()), CatchList);
|
PVD, static_cast<Stmt*>(Body.release()), CatchList);
|
||||||
|
|
|
@ -1,10 +1,13 @@
|
||||||
// RUN: clang -verify %s
|
// RUN: clang -verify %s
|
||||||
|
|
||||||
|
@protocol P;
|
||||||
|
|
||||||
void f() {
|
void f() {
|
||||||
@try {
|
@try {
|
||||||
} @catch (void a) { // expected-error{{@catch parameter is not an Objective-C class type}}
|
} @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) { // 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 (int *b) { // expected-error{{@catch parameter is not an Objective-C class type}}
|
||||||
|
} @catch (id <P> c) { // expected-warning{{ignoring qualifiers on @catch parameter}}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue