[cfe-dev] Preliminary reinterpret_cast Sema patch

Argiris Kirtzidis akyrtzi at gmail.com
Thu Oct 23 00:02:23 PDT 2008


Doug Gregor wrote:
> Hmm... in the case of an error when type-checking the casts, we should
> not actually build a CXXCastExpr node. Rather, Sema::ActOnCXXCasts
> should return "true" so that the parser knows that there was an error.
>
> I suggest that both CheckConstCast and CheckReinterpretCast return a
> bool that is true when there is an error and false otherwise (this is
> the scheme used elsewhere in Clang). Then, ActOnCXXCasts will never
> build an ill-formed node in the AST (which is a good thing).
>   

Is there any harm in building semantically invalid nodes ?
It will not affect clients that care about semantics since they will not 
analyse the AST if there are errors (there could be invalid decls).
The clients that only care about the textual representation of the 
program, and not about the semantics, will get seriously impacted by not 
building the nodes, e.g. a refactoring client will not be able to pickup 
the use of a variable because the expression that references it is not 
added to the AST.

To mirror the decls marked as "invalid" we could have exprs marked as 
"invalid" too.

-Argiris



More information about the cfe-dev mailing list