-
Notifications
You must be signed in to change notification settings - Fork 36
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 issue #70 about storage class v2 #72
base: master
Are you sure you want to change the base?
Conversation
Could we discuss this? This bug is annoying because without fix, using a library variable like "errno" is not possible. |
Yes, we should discuss this! I was examining the change, and I realized I did not understand it fully, will have a close look at it. I agree that this is very annoying, since this is a very common pattern. |
@@ -320,17 +320,21 @@ def check_redeclaration_storage_class(self, sym, declaration): | |||
old_storage_class = sym.declaration.storage_class | |||
new_storage_class = declaration.storage_class | |||
# None == automatic storage class. | |||
invalid_combos = [(None, "static"), ("extern", "static")] | |||
# changes of linkage between internal and external are illegal |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Playing around a bit at this site makes it appear differently, you can declare a function as non-static after first specifying it as static.
declaration.storage_class = sym.declaration.storage_class | ||
# if new storage-class is "extern", keep the old storage-class | ||
# otherwise use the new one | ||
if new_storage_class == "extern": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than changing the storage class, it is probably better to change the position in the Symbol.declarations list of this declaration.
invalid_combos = [(None, "static"), ("extern", "static")] | ||
# changes of linkage between internal and external are illegal | ||
invalid_combos = [(None, "static"), | ||
("extern", "static"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed this code a bit, so that there are booleans checking for previously static or not.
Much better. It solves the "errno" issue. I tried to test most combinations and there are 2 small problems remaining:
Current ppci-cc accpts the 3rd line whereas it should not since it is an attempt to change linkage.
Current ppci-cc correctly accepts the 2nd line which is correct, but it changes the linkage from "internal" to "external" whereas the linkage should be kept "internal" (the function "f" is declared global in the object file. The C standard states:
and:
|
No description provided.