-
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
invalid_combos = [(None, "static"), | ||
("extern", "static"), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
("static", None)] | ||
combo = (old_storage_class, new_storage_class) | ||
if combo in invalid_combos: | ||
message = "Invalid redefine of storage class. Was {}, but now {}".format( | ||
old_storage_class, new_storage_class | ||
) | ||
self.invalid_redeclaration(sym, declaration, message) | ||
|
||
if not declaration.storage_class: | ||
if sym.declaration.storage_class: | ||
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 commentThe 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. |
||
declaration.storage_class = old_storage_class | ||
|
||
def invalid_redeclaration( | ||
self, sym, declaration, message="Invalid redefinition" | ||
|
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.