[cfe-dev] Nested implicit casts?

Enea Zaffanella zaffanella at cs.unipr.it
Mon Jan 11 12:58:04 CST 2010


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)?

Thanks in advance for any explanation,
Enea Zaffanella.



More information about the cfe-dev mailing list