Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a parser bug in struct initialization. #65

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

gergo-
Copy link

@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