[cfe-dev] Code generation for structure/union initializers...

Steve Naroff snaroff at apple.com
Thu Jan 24 16:58:59 PST 2008


Folks,

Commit r46339 now does semantic analysis for struct/union initializers.

There still seem to be bugs in the code generator that prevent the  
test cases below from working correctly.

I originally thought the bugs would go away when the proper  
ImplicitCastExprs were in place. From my perspective, the AST's below  
look fine...

snaroff

[snaroff:llvm/tools/clang] snarofflocal% cat bugs.c
typedef union { unsigned char __c[8]; double __d; } __huge_val_t;

void func() {
   static __huge_val_t union_bug = { { 0, 0, 0, 0, 0, 0, 0xf0, 0x7f } };

   struct a {int b; int c};
   struct a incomplete_init = {5};
}

[snaroff:llvm/tools/clang] snarofflocal% ../../Debug/bin/clang bugs.c - 
ast-dump
typedef char *__builtin_va_list;
typedef union <anonymous> __huge_val_t;

void func()
(CompoundStmt 0x9067b0 <bugs.c:3:13, line:8:1>
   (DeclStmt 0x906670 <:0:0>
     0x906360 "static __huge_val_t union_bug =
       (InitListExpr 0x9065c0 <bugs.c:4:35, col:70>  
'__huge_val_t':'union <anonymous>'
         (InitListExpr 0x906580 <col:37, col:68> 'unsigned char [8]'
           (ImplicitCastExpr 0x9065f0 <col:39> 'unsigned char'
             (IntegerLiteral 0x906480 <col:39> 'int' 0))
           (ImplicitCastExpr 0x906600 <col:42> 'unsigned char'
             (IntegerLiteral 0x9064a0 <col:42> 'int' 0))
           (ImplicitCastExpr 0x906610 <col:45> 'unsigned char'
             (IntegerLiteral 0x9064c0 <col:45> 'int' 0))
           (ImplicitCastExpr 0x906620 <col:48> 'unsigned char'
             (IntegerLiteral 0x9064e0 <col:48> 'int' 0))
           (ImplicitCastExpr 0x906630 <col:51> 'unsigned char'
             (IntegerLiteral 0x906500 <col:51> 'int' 0))
           (ImplicitCastExpr 0x906640 <col:54> 'unsigned char'
             (IntegerLiteral 0x906520 <col:54> 'int' 0))
           (ImplicitCastExpr 0x906650 <col:57> 'unsigned char'
             (IntegerLiteral 0x906540 <col:57> 'int' 240))
           (ImplicitCastExpr 0x906660 <col:63> 'unsigned char'
             (IntegerLiteral 0x906560 <col:63> 'int' 127))))"
   (DeclStmt 0x906700 <:0:0>
     0x906680 "struct a;"
   (DeclStmt 0x9067a0 <col:0>
     0x906720 "struct a incomplete_init =
       (InitListExpr 0x906770 <bugs.c:7:30, col:32> 'struct a'
         (IntegerLiteral 0x906750 <col:31> 'int' 5))")

[snaroff:llvm/tools/clang] snarofflocal%




More information about the cfe-dev mailing list