diff options
author | Steve Naroff <snaroff@apple.com> | 2009-04-08 23:52:26 +0000 |
---|---|---|
committer | Steve Naroff <snaroff@apple.com> | 2009-04-08 23:52:26 +0000 |
commit | a0c3e9cde1581b1b4d43ca89fdf413cd84eaec1f (patch) | |
tree | 2dac1b7c1ebd258bf5d7e9d221ac1562742f2833 | |
parent | 782f397c1459ef7d8b910c0fb6b95c5f1c19c14f (diff) |
Fix <rdar://problem/6770998> make cast of super illegal (again:-)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68659 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/clang/Basic/DiagnosticSemaKinds.td | 4 | ||||
-rw-r--r-- | lib/Sema/SemaExpr.cpp | 2 | ||||
-rw-r--r-- | test/SemaObjC/call-super-2.m | 19 |
3 files changed, 11 insertions, 14 deletions
diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index 3245323a74..11a16a279f 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/include/clang/Basic/DiagnosticSemaKinds.td @@ -1024,8 +1024,8 @@ def err_catch_param_not_objc_type : Error< "@catch parameter is not an Objective-C class type">; def err_illegal_qualifiers_on_catch_parm : Error< "illegal qualifiers on @catch parameter">; -def warn_super_cast_deprecated : Warning< - "casting 'super' is deprecated (it isn't an expression)">; +def err_illegal_super_cast : Error< + "cannot cast 'super' (it isn't an expression)">; // C++ casts diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index 4f8ad5b4a5..cb7a90fffc 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -2510,7 +2510,7 @@ bool Sema::CheckCastTypes(SourceRange TyR, QualType castType, Expr *&castExpr) { if (CheckVectorCast(TyR, castType, castExpr->getType())) return true; } else if (getLangOptions().ObjC1 && isa<ObjCSuperExpr>(castExpr)) { - Diag(castExpr->getLocStart(), diag::warn_super_cast_deprecated) << TyR; + return Diag(castExpr->getLocStart(), diag::err_illegal_super_cast) << TyR; } return false; } diff --git a/test/SemaObjC/call-super-2.m b/test/SemaObjC/call-super-2.m index f171007be0..92bec27c67 100644 --- a/test/SemaObjC/call-super-2.m +++ b/test/SemaObjC/call-super-2.m @@ -2,10 +2,7 @@ #include <stddef.h> -typedef struct objc_class *Class; -typedef struct objc_object { - Class isa; -} *id; +typedef struct objc_object *id; id objc_getClass(const char *s); @interface Object @@ -42,17 +39,17 @@ id objc_getClass(const char *s); + (int) class_func2 { int i = [(id <Func>)self class_func0]; - i += [(id <Func>)super class_func0]; // expected-warning {{casting 'super' is deprecated (it isn't an expression)}} + i += [(id <Func>)super class_func0]; // expected-error {{cannot cast 'super' (it isn't an expression)}} i += [(Class <Func>)self class_func0]; // expected-error {{protocol qualified 'Class' is unsupported}} - return i + [(Class <Func>)super class_func0]; // expected-error {{protocol qualified 'Class' is unsupported}} // expected-warning {{casting 'super' is deprecated (it isn't an expression)}} + return i + [(Class <Func>)super class_func0]; // expected-error {{protocol qualified 'Class' is unsupported}} // expected-error {{cannot cast 'super' (it isn't an expression)}} } + (int) class_func3 { - return [(Object <Func> *)super class_func0]; // expected-warning {{casting 'super' is deprecated (it isn't an expression)}} // expected-warning {{method '-class_func0' not found (return type defaults to 'id')}} // expected-warning {{incompatible pointer to integer conversion returning 'id', expected 'int'}} + return [(Object <Func> *)super class_func0]; // expected-error {{cannot cast 'super' (it isn't an expression)}} } + (int) class_func4 { - return [(Derived <Func> *)super class_func0]; // expected-warning {{casting 'super' is deprecated (it isn't an expression)}} // expected-warning {{method '-class_func0' not found (return type defaults to 'id')}} // expected-warning {{incompatible pointer to integer conversion returning 'id', expected 'int'}} + return [(Derived <Func> *)super class_func0]; // expected-error {{cannot cast 'super' (it isn't an expression)}} } + (int) class_func5 { @@ -74,15 +71,15 @@ id objc_getClass(const char *s); } - (int) instance_func2 { - return [(id <Func>)super instance_func0]; // expected-warning {{casting 'super' is deprecated (it isn't an expression)}} + return [(id <Func>)super instance_func0]; // expected-error {{cannot cast 'super' (it isn't an expression)}} } - (int) instance_func3 { - return [(Object <Func> *)super instance_func0]; // expected-warning {{casting 'super' is deprecated (it isn't an expression)}} + return [(Object <Func> *)super instance_func0]; // expected-error {{cannot cast 'super' (it isn't an expression)}} } - (int) instance_func4 { - return [(Derived <Func> *)super instance_func0]; // expected-warning {{casting 'super' is deprecated (it isn't an expression)}} + return [(Derived <Func> *)super instance_func0]; // expected-error {{cannot cast 'super' (it isn't an expression)}} } - (int) instance_func5 { |