Skip to content

Fix a parser bug in struct initialization.#65

Open
gergo- wants to merge 1 commit intorui314:masterfrom
gergo-:struct_init
Open

Fix a parser bug in struct initialization.#65
gergo- wants to merge 1 commit intorui314:masterfrom
gergo-:struct_init

Conversation

@gergo-
Copy link
Copy Markdown

@gergo- gergo- commented Jun 10, 2015

When initializing a struct containing a struct via a variable (see
test/initializer.c, function test_struct()):

struct foo { int a; int b; } f = { 1, 2 };
struct { struct foo f; } b = { f };

8cc failed with a type error:
[ERROR] parse.c:617: (null): incompatible kind: <(struct (int) (int))>

The read_initializer_elem function did not expect an identifier as a valid
struct member initializer. This patch seems to fix that (make fulltest
passes with the above-mentioned test added).

When initializing a struct containing a struct via a variable (see
test/initializer.c, function test_struct()):

    struct foo { int a; int b; } f = { 1, 2 };
    struct { struct foo f; } b = { f };

8cc failed with a type error:
[ERROR] parse.c:617: (null): incompatible kind: <int> <(struct (int) (int))>

The read_initializer_elem function did not expect an identifier as a valid
struct member initializer. This patch seems to fix that (make fulltest
passes with the above-mentioned test added).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant