-
Notifications
You must be signed in to change notification settings - Fork 173
Always insert global symbols to _global_symbols module
#1732
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
Conversation
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.
LGTM! Thanks for fixing this. This was on my TODO list, but I kept forgetting about it.
So, from now on, we will always have two symbols in the TranslationUnit. If the program uses an IntrinsicFunction then the TranslationUnit also includes that function in the global scope.
Empty program:
(TranslationUnit
(SymbolTable
1
{
_global_symbols:
(Module
(SymbolTable
3
{
})
_global_symbols
[]
.false.
.false.
),
main_program:
(Program
(SymbolTable
2
{
})
main_program
[]
[]
)
})
[]
)|
Thanks for pointing out. I don't create |
certik
left a comment
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 think it looks good, thanks for fixing it!
|
Hm, this PR broke (lp) lpython/integration_tests(main) $ lpython --show-c --disable-main import_order_01.py -I.
#include <inttypes.h>
#include <stdlib.h>
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include <lfortran_intrinsics.h>
#define ASSERT(cond) \
{ \
if (!(cond)) { \
printf("%s%s", "ASSERT failed: ", __FILE__); \
printf("%s%s", "\nfunction ", __func__); \
printf("%s%d%s", "(), line number ", __LINE__, " at \n"); \
printf("%s%s", #cond, "\n"); \
exit(1); \
} \
}
#define ASSERT_MSG(cond, msg) \
{ \
if (!(cond)) { \
printf("%s%s", "ASSERT failed: ", __FILE__); \
printf("%s%s", "\nfunction ", __func__); \
printf("%s%d%s", "(), line number ", __LINE__, " at \n"); \
printf("%s%s", #cond, "\n"); \
printf("%s", "ERROR MESSAGE:\n"); \
printf("%s%s", msg, "\n"); \
exit(1); \
} \
}
struct dimension_descriptor
{
int32_t lower_bound, length;
};
// Implementations
int32_t f()
{
int32_t _lpython_return_variable;
_lpython_return_variable = 42;
return _lpython_return_variable;
}
void main1()
{
int32_t a;
a = f();
printf("%d\n", a);
}
int main(int argc, char* argv[])
{
return 0;
}Hopefully it can be fixed with a subsequent PR, otherwise we'll need to revert it. |
|
Let me see. Probably a corner case. |
This fixes a regression introduced by lcompilers#1732.
Closes #1727
#1727 (comment)