[cfe-dev] InitListExpr::getSyntacticForm and C++

Abramo Bagnara abramo.bagnara at gmail.com
Tue Jan 25 11:49:08 PST 2011

Il 25/01/2011 20:37, John McCall ha scritto:
> On Jan 25, 2011, at 11:18 AM, Abramo Bagnara wrote:
>> I've just verified that in:
>> class C {
>> public:
>>  C(int a);
>> };
>> C v[3] = {1,2,3.0};
>> the InitListExpr returned by InitListExpr::getSyntacticForm misses all
>> the fundamental info about implicit casts and CXXConstructExpr.
>> Is this deliberate (why?) or it is a bug to fix?
> Does the syntactic form normally have any of this stuff?  I thought it was just the initializer list as it was written in the source, without further analysis or comment.

As you can see from the typescript above, implicit casts are where they
are expected, but AST is without CXXConstructExpr and implicit cast when
initialized type is a class.

$ cat t.c

int v[3] = {1,2,3.0};
$ clang -cc1 -ast-dump t.c
typedef char *__builtin_va_list;
int v[3] = (InitListExpr 0xaed1f90 <t.c:2:12, col:20> 'int [3]'
  (IntegerLiteral 0xaed1ef0 <col:13> 'int' 1)
  (IntegerLiteral 0xaed1f10 <col:15> 'int' 2)
  (ImplicitCastExpr 0xaed1fd0 <col:17> 'int' <FloatingToIntegral>
    (FloatingLiteral 0xaed1f30 <col:17> 'double' 3.000000e+00)))

More information about the cfe-dev mailing list