Missing implicit cast inside CXXFunctionalCastExpr node.

Hello.

It looks like clang++ forgets the addition of implicit casts when
applying functional casts having an enum type as target type:

$ cat enum.cc
enum E { a };

void foo(void) {
  E(1U);
  E(1.9);
}

$ clang++ -cc1 -ast-dump enum.cc
[...]
void foo() (CompoundStmt 0x4a0b0f8 <enum.cc:3:16, line:6:1>
  (CXXFunctionalCastExpr 0x4a0b070 <line:4:3, col:6> 'enum E' functional
cast to enum E
    (IntegerLiteral 0x4a0b048 <col:5> 'int' 1))
  (CXXFunctionalCastExpr 0x4a0b0d0 <line:5:3, col:8> 'enum E' functional
cast to enum E
    (FloatingLiteral 0x4a0b0a8 <col:5> 'double' 1.900000e+00)))

As far as I recall, CXXFunctionalCastExpr is just a syntactic wrapper
and the semantics of the cast (eventually CK_NoOp) has to be found in an
embedded ImplicitCastExpr node.

Regards,
Enea.

CXXFunctionalCastExpr can have a cast kind... it should be visible
with -ast-dump (and correct) with r139011.

-Eli

Hello.

[...]

As far as I recall, CXXFunctionalCastExpr is just a syntactic wrapper
and the semantics of the cast (eventually CK_NoOp) has to be found in an
embedded ImplicitCastExpr node.

CXXFunctionalCastExpr can have a cast kind... it should be visible
with -ast-dump (and correct) with r139011.

-Eli

Thanks for the very quick fix.

It looks like I was somehow misunderstanding CXXFunctionalCastExpr.
Am I correct if I say that the argument expression of a (non type or
value dependent) CXXFunctionalCastExpr can only be one of:
  - CXXConstructExpr
  - CXXBindTemporaryExpr
  - ImplicitCastExpr
  - an expression having scalar type
?

Thanks in advance for any clarification.
Enea.

I don't know the complete list, but at the very least you're not
considering l-value casts (i.e. "typedef Class& ClassRef; [...]
ClassRef(Var) [...]"). Some casts can be represented without any extra
AST nodes, some casts require additional nodes (like CXXConstructExpr,
CXXBindTemporaryExpr, ImplicitCastExpr, MaterializeTemporaryExpr...
I'm not sure what the complete list is, and we might make some tweaks
in the future.)

-Eli