Merge pull request #1863 from acqn/LinkageFix

[cc65] Fixed symbol visibility and usage problems with extern/static declarations
This commit is contained in:
Bob Andrews
2022-10-09 18:59:12 +02:00
committed by GitHub
4 changed files with 76 additions and 16 deletions

31
test/val/extern.c Normal file
View File

@@ -0,0 +1,31 @@
/* Test for shadowing and linkage of file-scope "static" and block-scope "extern" declarations */
static int g(int x); /* Generated functions with internal linkage are not always kept in cc65 */
int main(void)
{
char f = 'f'; /* Shadows global "int f(void)" (if any) */
char c = 'c'; /* Shadows global "int c" (if any) */
{
void* f = 0; /* Shadows local "char f" */
void* c = 0; /* Shadows local "char c" */
{
int f(void); /* Shadows local "char f" and "void* f" */
extern int g(int); /* Shadows global "int g(int x)" */
extern int c; /* Shadows local "char c" and "void* c" */
return f() ^ g(c); /* Link to global "int g(int x)" */
}
}
}
int c = 42;
int f(void)
{
return 42;
}
int g(int x)
{
return x;
}