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

ppci-cc: impossible to redefine a struct/union/enum tag in inner scopes #51

Closed
tstreiff opened this issue Jan 21, 2020 · 1 comment
Closed
Assignees

Comments

@tstreiff
Copy link
Contributor

C Struct/union/enum tags follow the same rules than other identifiers for scope. They may be redeclared in an inner scope and the inner declaration hides the outer ones.
The following legal code is reported as erroneous :

void f(int n) {
struct S { int a; };
if (n == 10) {
struct S { int b; } s; // error "multiple definitions"
s.b = 1;
}
s.a = 2;
}
4: struct S { int b; } s;
^ Multiple definitions
2020-01-22 00:37:59,248 | INFO | root | ppci 0.5.7 on CPython 3.6.9 on Linux
2020-01-22 00:37:59,254 | INFO | cbuilder | Starting C compilation (c99)
2020-01-22 00:37:59,256 | ERROR | root | Multiple definitions
2020-01-22 00:37:59,257 | ERROR | root | (bug20.c, 5, 5)

Same behaviour for union/enum (which share the tag namespace)

@windelbouwman windelbouwman self-assigned this Jun 6, 2020
@windelbouwman
Copy link
Owner

Agreed, verified this was implemented wrongly. Addressed in 2ac2d76.

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

No branches or pull requests

2 participants