Hi Steve,<div><br></div><div>One question about this patch. Will we be getting the "right" type for a casted super expression (i.e. the casted type)? If not, it seems like there is some possibility that we will end up miscompiling otherwise working code. Of course, this is probably very unlikely in practice...</div>
<div><br></div><div> - Daniel<br><br><div class="gmail_quote">On Mon, Apr 6, 2009 at 3:07 PM, Steve Naroff <span dir="ltr"><<a href="mailto:snaroff@apple.com">snaroff@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Author: snaroff<br>
Date: Mon Apr 6 17:07:54 2009<br>
New Revision: 68468<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=68468&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=68468&view=rev</a><br>
Log:<br>
Make casting 'super' a deprecated warning (instead of a hard error).<br>
<br>
This will simplify clang adoption, and is probably better "etiquette" (since gcc has always accepted this idiom without warning). Once we are over the adoption hurdle, we can turn this into an error.<br>
<br>
<br>
Modified:<br>
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td<br>
cfe/trunk/lib/Sema/SemaExpr.cpp<br>
cfe/trunk/test/SemaObjC/call-super-2.m<br>
<br>
Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=68468&r1=68467&r2=68468&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=68468&r1=68467&r2=68468&view=diff</a><br>
<br>
==============================================================================<br>
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)<br>
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Mon Apr 6 17:07:54 2009<br>
@@ -1020,8 +1020,8 @@<br>
"@catch parameter is not an Objective-C class type">;<br>
def err_illegal_qualifiers_on_catch_parm : Error<<br>
"illegal qualifiers on @catch parameter">;<br>
-def err_illegal_super_cast : Error<<br>
- "cannot cast 'super' (it isn't an expression)">;<br>
+def warn_super_cast_deprecated : Warning<<br>
+ "casting 'super' is deprecated (it isn't an expression)">;<br>
<br>
<br>
// C++ casts<br>
<br>
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=68468&r1=68467&r2=68468&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=68468&r1=68467&r2=68468&view=diff</a><br>
<br>
==============================================================================<br>
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)<br>
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Mon Apr 6 17:07:54 2009<br>
@@ -2500,7 +2500,7 @@<br>
if (CheckVectorCast(TyR, castType, castExpr->getType()))<br>
return true;<br>
} else if (getLangOptions().ObjC1 && isa<ObjCSuperExpr>(castExpr)) {<br>
- return Diag(castExpr->getLocStart(), diag::err_illegal_super_cast) << TyR;<br>
+ Diag(castExpr->getLocStart(), diag::warn_super_cast_deprecated) << TyR;<br>
}<br>
return false;<br>
}<br>
<br>
Modified: cfe/trunk/test/SemaObjC/call-super-2.m<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/call-super-2.m?rev=68468&r1=68467&r2=68468&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/call-super-2.m?rev=68468&r1=68467&r2=68468&view=diff</a><br>
<br>
==============================================================================<br>
--- cfe/trunk/test/SemaObjC/call-super-2.m (original)<br>
+++ cfe/trunk/test/SemaObjC/call-super-2.m Mon Apr 6 17:07:54 2009<br>
@@ -2,7 +2,10 @@<br>
<br>
#include <stddef.h><br>
<br>
-typedef struct objc_object *id;<br>
+typedef struct objc_class *Class;<br>
+typedef struct objc_object {<br>
+ Class isa;<br>
+} *id;<br>
id objc_getClass(const char *s);<br>
<br>
@interface Object<br>
@@ -39,17 +42,17 @@<br>
+ (int) class_func2<br>
{<br>
int i = [(id <Func>)self class_func0]; // expected-warning {{method '-class_func0' not found (return type defaults to 'id')}} // expected-warning {{incompatible pointer to integer conversion initializing 'id', expected 'int'}}<br>
- i += [(id <Func>)super class_func0]; // expected-error {{cannot cast 'super' (it isn't an expression)}}<br>
+ i += [(id <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 assigning 'id', expected 'int'}}<br>
i += [(Class <Func>)self class_func0]; // expected-error {{protocol qualified 'Class' is unsupported}}<br>
- return i + [(Class <Func>)super class_func0]; // expected-error {{protocol qualified 'Class' is unsupported}} // expected-error {{cannot cast 'super' (it isn't an expression)}}<br>
+ 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)}}<br>
}<br>
+ (int) class_func3<br>
{<br>
- return [(Object <Func> *)super class_func0]; // expected-error {{cannot cast 'super' (it isn't an expression)}}<br>
+ 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'}}<br>
}<br>
+ (int) class_func4<br>
{<br>
- return [(Derived <Func> *)super class_func0]; // expected-error {{cannot cast 'super' (it isn't an expression)}}<br>
+ 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'}}<br>
}<br>
+ (int) class_func5<br>
{<br>
@@ -71,15 +74,15 @@<br>
}<br>
- (int) instance_func2<br>
{<br>
- return [(id <Func>)super instance_func0]; // expected-error {{cannot cast 'super' (it isn't an expression)}}<br>
+ return [(id <Func>)super instance_func0]; // expected-warning {{casting 'super' is deprecated (it isn't an expression)}}<br>
}<br>
- (int) instance_func3<br>
{<br>
- return [(Object <Func> *)super instance_func0]; // expected-error {{cannot cast 'super' (it isn't an expression)}}<br>
+ return [(Object <Func> *)super instance_func0]; // expected-warning {{casting 'super' is deprecated (it isn't an expression)}}<br>
}<br>
- (int) instance_func4<br>
{<br>
- return [(Derived <Func> *)super instance_func0]; // expected-error {{cannot cast 'super' (it isn't an expression)}}<br>
+ return [(Derived <Func> *)super instance_func0]; // expected-warning {{casting 'super' is deprecated (it isn't an expression)}}<br>
}<br>
- (int) instance_func5<br>
{<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div>