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

Handling of labled statements broken #21

Open
ckaestne opened this issue Jun 16, 2013 · 1 comment
Open

Handling of labled statements broken #21

ckaestne opened this issue Jun 16, 2013 · 1 comment
Labels

Comments

@ckaestne
Copy link
Owner

Parsing of labeled statements is incorrect (our grammar needs fixing)

We parse labels as separate statements. That is a: b: c(); is parsed as three statements: List(LabeledStatement(a), LabeledStatement(b), FunctionCall(c..)). In the ANSI C grammar this is a single statement LabeledStatement(a, LabeledStatement(b, FunctionCall(c..))). In GCC this is again handled differently, closer to our separate statements: the internal tree representation actually creates an internal block where needed.

Here is the original code block (one statement) from uclibc that illustrates the problem:

if (0)
        jin:{
        if ((a = *++haystack) == c)
          goto crest;
          }
        else
          a = *++haystack;

Corresponding grammar:
http://www.lysator.liu.se/c/ANSI-C-grammar-y.html
and corresponding parser code in GCC:
https://github.com/mirrors/gcc/blob/master/gcc/c/c-parser.c#L4457

Fixing the grammar will require follow up fixes in the data flow analysis and simple changes in the type system.

ckaestne added a commit that referenced this issue Jun 16, 2013
ckaestne added a commit that referenced this issue Jun 18, 2013
labels need a statement following them. several of our test files were actually incorrect and are rejected by gcc

corresponding changes in CFG are still pending
@ckaestne
Copy link
Owner Author

will be fixed in fix_goto branch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant