[cfe-commits] r68468 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaExpr.cpp test/SemaObjC/call-super-2.m

steve naroff snaroff at apple.com
Tue Apr 7 08:30:15 PDT 2009


On Apr 6, 2009, at 8:19 PM, Daniel Dunbar wrote:

> Hi Steve,
>
> 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...
>

Hey Daniel,

I think the benefit of the warning downgrade outweighs the likelihood  
of miscompiling working code. Since warnings (in general) can result  
in incorrect runtime behavior, I don't see a big problem.

Another point: The other reason I decided to do this (other than  
etiquette) is the workaround isn't always easy to describe.

Just to be clear...like you/Fariborz/etc., I prefer to make this an  
error (so this is a compromise in the name of source compatibility).

snaroff

>  - Daniel
>
> On Mon, Apr 6, 2009 at 3:07 PM, Steve Naroff <snaroff at apple.com>  
> wrote:
> Author: snaroff
> Date: Mon Apr  6 17:07:54 2009
> New Revision: 68468
>
> URL: http://llvm.org/viewvc/llvm-project?rev=68468&view=rev
> Log:
> Make casting 'super' a deprecated warning (instead of a hard error).
>
> 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.
>
>
> Modified:
>    cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>    cfe/trunk/lib/Sema/SemaExpr.cpp
>    cfe/trunk/test/SemaObjC/call-super-2.m
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=68468&r1=68467&r2=68468&view=diff
>
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Mon Apr  6  
> 17:07:54 2009
> @@ -1020,8 +1020,8 @@
>   "@catch parameter is not an Objective-C class type">;
>  def err_illegal_qualifiers_on_catch_parm : Error<
>   "illegal qualifiers on @catch parameter">;
> -def err_illegal_super_cast : Error<
> -  "cannot cast 'super' (it isn't an expression)">;
> +def warn_super_cast_deprecated : Warning<
> +  "casting 'super' is deprecated (it isn't an expression)">;
>
>
>  // C++ casts
>
> Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=68468&r1=68467&r2=68468&view=diff
>
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
> --- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaExpr.cpp Mon Apr  6 17:07:54 2009
> @@ -2500,7 +2500,7 @@
>     if (CheckVectorCast(TyR, castType, castExpr->getType()))
>       return true;
>   } else if (getLangOptions().ObjC1 && isa<ObjCSuperExpr>(castExpr)) {
> -    return Diag(castExpr->getLocStart(),  
> diag::err_illegal_super_cast) << TyR;
> +    Diag(castExpr->getLocStart(), diag::warn_super_cast_deprecated)  
> << TyR;
>   }
>   return false;
>  }
>
> Modified: cfe/trunk/test/SemaObjC/call-super-2.m
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/call-super-2.m?rev=68468&r1=68467&r2=68468&view=diff
>
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
> --- cfe/trunk/test/SemaObjC/call-super-2.m (original)
> +++ cfe/trunk/test/SemaObjC/call-super-2.m Mon Apr  6 17:07:54 2009
> @@ -2,7 +2,10 @@
>
>  #include <stddef.h>
>
> -typedef struct objc_object *id;
> +typedef struct objc_class *Class;
> +typedef struct objc_object {
> +    Class isa;
> +} *id;
>  id objc_getClass(const char *s);
>
>  @interface Object
> @@ -39,17 +42,17 @@
>  + (int) class_func2
>  {
>    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'}}
> -   i += [(id <Func>)super class_func0];    // expected-error  
> {{cannot cast 'super' (it isn't an expression)}}
> +   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'}}
>    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-error  
> {{cannot cast 'super' (it isn't an expression)}}
> +   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)}}
>  }
>  + (int) class_func3
>  {
> -   return [(Object <Func> *)super class_func0];  // expected-error  
> {{cannot cast 'super' (it isn't an expression)}}
> +   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'}}
>  }
>  + (int) class_func4
>  {
> -   return [(Derived <Func> *)super class_func0]; // expected-error  
> {{cannot cast 'super' (it isn't an expression)}}
> +   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'}}
>  }
>  + (int) class_func5
>  {
> @@ -71,15 +74,15 @@
>  }
>  - (int) instance_func2
>  {
> -   return [(id <Func>)super instance_func0]; // expected-error  
> {{cannot cast 'super' (it isn't an expression)}}
> +   return [(id <Func>)super instance_func0]; // expected-warning  
> {{casting 'super' is deprecated (it isn't an expression)}}
>  }
>  - (int) instance_func3
>  {
> -   return [(Object <Func> *)super instance_func0]; // expected- 
> error {{cannot cast 'super' (it isn't an expression)}}
> +   return [(Object <Func> *)super instance_func0]; // expected- 
> warning {{casting 'super' is deprecated (it isn't an expression)}}
>  }
>  - (int) instance_func4
>  {
> -   return [(Derived <Func> *)super instance_func0]; // expected- 
> error {{cannot cast 'super' (it isn't an expression)}}
> +   return [(Derived <Func> *)super instance_func0]; // expected- 
> warning {{casting 'super' is deprecated (it isn't an expression)}}
>  }
>  - (int) instance_func5
>  {
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20090407/3f0a1a8d/attachment.html>


More information about the cfe-commits mailing list