You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$ clang x.c x.c:41:9: error: implicit declaration of function 'f' is invalid in C99 [-Werror,-Wimplicit-function-declaration] a = f(); ^1 error generated.
The issue is that main1 depends on f, but f gets generated below the function. It only happens when --disable-main is used, but we need to use it.
The text was updated successfully, but these errors were encountered:
I am not sure how to best test this in integration tests, due to the --disable-main. The @ccallback is needed, otherwise the function gets treated as unused.
Its a problem with pass_wrap_global_stmts_into_program. It only shifts user defined functions into _global_symbols (generated module) only when they are called. In your case main1 is never called so it stays in the global scope. Now C backend first visits all the functions in global scope and since main1 lies in global scope so C code of it is generated first. Then f is generated when the modules are visited. If main1 is shifted to _global_symbols then it depends on import_order_01 and hence f will always be generated before main1 (which is correct).
End moral - So, IMO global scope should only contain intrinsic functions generated by libasr in intrinsic_function_registry.h. All user defined functions should be shifted to _global_symbols modules irrespective of the fact whether they are called by the user or not.
import_order_01.py:
import_order_01b.py:
Compile using:
This then fails to compile due to:
The issue is that
main1
depends onf
, butf
gets generated below the function. It only happens when--disable-main
is used, but we need to use it.The text was updated successfully, but these errors were encountered: