tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] [BUG] Nested array/struct/union initialization proble


From: Dave Dodge
Subject: Re: [Tinycc-devel] [BUG] Nested array/struct/union initialization problem
Date: Wed, 26 Sep 2007 04:16:33 -0400
User-agent: Mutt/1.5.13 (2006-08-11)

On Wed, Sep 26, 2007 at 02:46:45AM -0500, Rob Landley wrote:
> Anyway, the first thing I'd do is try to pare the test case down to
> something smaller.

struct foo{
    union{
        int i;
    };
};

static struct foo f = {
    { .i = 0 }
};

> I'm currently looking at unary() for one of the other issues

I took a brief look at it earlier.  I traced it this far (line numbers
in tcc.c are a bit off due to the inserted trace code):

  decl_initializer called from decl_initializer_alloc:8136
  decl_initializer called from decl_designator:7598
  decl_initializer called from decl_initializer:7911
  expr_const1 called from init_putv:7641
  expr_eq called from expr_const1:7129
  uneq() called from expr_prod:6802
  unary called from uneq:6779
  unary:6368 tok=46
  unary:6612 t=46
  foo.c:8: unary: 6615: identifier expected

Basically I think it's entering the big switch in unary() with the '.'
as the token, which drops to the default case.  Give the union a field
name in the struct, _or_ remove the ".i=" from the initializer, and it
takes it with this trace:

  decl_initializer called from decl_initializer_alloc:8136
  decl_initializer called from decl_designator:7598
  decl_initializer called from decl_designator:7598
  expr_const1 called from init_putv:7641
  expr_eq called from expr_const1:7129
  uneq() called from expr_prod:6802
  unary called from uneq:6779
  unary:6368 tok=179

Note that this time the token is 179, even when you merely name the
union and leave the ".i=" in place.

                                                  -Dave Dodge




reply via email to

[Prev in Thread] Current Thread [Next in Thread]