[cfe-dev] Nested implicit casts?

Eli Friedman eli.friedman at gmail.com
Mon Jan 11 10:16:48 PST 2010


On Mon, Jan 11, 2010 at 10:58 AM, Enea Zaffanella
<zaffanella at cs.unipr.it> wrote:
> Hello.
>
> Dumping the AST for the following program:
>
> int f(signed char v) { return v < 1U; }
>
> we obtain an implicit cast expression that (immediately) contains
> another implicit cast expression:
>
> int f(signed char v) (CompoundStmt 0x174c530 <test.c:1:22, col:39>
>   (ReturnStmt 0x174c510 <col:24, col:35>
>     (BinaryOperator 0x174c4d0 <col:31, col:35> 'int' '<'
>       (ImplicitCastExpr 0x174c4a0 <col:31> 'unsigned int' <Unknown>
>         (ImplicitCastExpr 0x174c470 <col:31> 'int' <IntegralCast>
>           (DeclRefExpr 0x174c3f8 <col:31> 'signed char' ParmVar='v'
> 0x174c2c0)))
>       (IntegerLiteral 0x174c430 <col:35> 'unsigned int' 1))))
>
>
> Is that meant to be OK?
>
> I am asking because, when looking to dumps from older clang revisions, I
> got the (probably false) impression that some effort was done in order
> to merge chains of consecutive implicit casts into a single one.
>
> Is it the case that now the two casts are not merged because they have
> different kind (one is an IntegralCast, the other is Unknown)?

Yes, precisely, although that's actually a bug in this case (both
casts should be of type IntegralCast).

-Eli




More information about the cfe-dev mailing list