[cfe-dev] [cfe-commits] r100942 - /cfe/trunk/lib/CodeGen/CGObjC.cpp

David Chisnall csdavec at swan.ac.uk
Sat Apr 10 15:00:32 PDT 2010

On 10 Apr 2010, at 22:41, Chris Lattner wrote:

> By your logic, we would accept cast of super... But we don't and it is intentional.  This is the same issue.

No, because cast of super is never a sensible thing to do.  The class of super is fixed at compile time, so casting it is always wrong.  If code does this, then it should be fixed.

In contrast, putting parentheses around super does not change its semantics.  If you wish for clang not to support this, what do you propose as the alternative for the (currently in use in existing code) use case that I described in my last mail?  

Cast of super is a work around for calling private methods in the superclass.  You can work around its lack trivially with a private category on the superclass.  You have not proposed a way of replacing macros that conditionally call a method (a widely-used idiom) when they are passed super as an argument.  If the macro takes an expression, it must be parenthetical.  If the macro takes super, it must not be parenthetical.    

Note that the fact that Smalltalk does not support this construct is not an issue because Smalltalk does not use the C preprocessor, it uses a much more sane model for AST transforms.  The same is true of Java.  Only the fact that Objective-C is used with the C preprocessor makes this an issue.


More information about the cfe-dev mailing list