[cfe-dev] Surprising cast

Abramo Bagnara abramo.bagnara at gmail.com
Sat Dec 11 15:25:18 PST 2010


Il 11/12/2010 23:33, John McCall ha scritto:
> On Dec 11, 2010, at 9:21 AM, Abramo Bagnara wrote:
>> $ cat p.c
>> enum {
>>  a = 1
>> };
>> $ clang -cc1 -ast-dump p.c
>> typedef char *__builtin_va_list;
>> enum  {
>>    a = (ImplicitCastExpr 0xb9e11f0 <p.c:2:7> 'int' <IntegralCast>
>>  (IntegerLiteral 0xb9e11a0 <col:7> 'int' 1))
>>
>> };
>>
>> The implicit cast from int to int is deliberate?
> 
> Seems unnecessary to me;  probably something is just making an explicit expression instead of using ImpCastExprToType (which would be appropriate here, I think).

The mess is done near the end of Sema::ActOnEnumBody: there is no check
that NewTy is different from current InitExpr type and and an implicit
cast is added unconditionally.



More information about the cfe-dev mailing list