Merge pull request #2370 from acqn/VisibilityFix

[cc65] Fixed visibility of undeclared functions and objects
This commit is contained in:
Bob Andrews
2024-01-22 18:31:47 +01:00
committed by GitHub
6 changed files with 78 additions and 21 deletions

View File

@@ -0,0 +1,15 @@
/* Bug 2304 - Visibility of objects/functions undeclared in file scope but 'extern'-declared in unrelated block scopes */
void f1(void)
{
extern int a;
}
/* 'a' is still invisible in the file scope */
int main(void)
{
return a * 0; /* Usage of 'a' should be an error */
}
int a = 42;

View File

@@ -133,6 +133,12 @@ $(WORKDIR)/goto.$1.$2.prg: goto.c $(ISEQUAL) | $(WORKDIR)
$(CC65) -t sim$2 -$1 -o $$@ $$< 2>$(WORKDIR)/goto.$1.$2.out
$(ISEQUAL) $(WORKDIR)/goto.$1.$2.out goto.ref
# this one requires failure with --std=c89, it fails with --std=cc65 due to
# stricter checks
$(WORKDIR)/bug2304-implicit-func.$1.$2.prg: bug2304-implicit-func.c | $(WORKDIR)
$(if $(QUIET),echo misc/bug2304-implicit-func.$1.$2.prg)
$(NOT) $(CC65) --standard c89 -t sim$2 -$1 -o $$@ $$< $(NULLERR)
# should not compile until 3-byte struct by value tests are re-enabled
$(WORKDIR)/struct-by-value.$1.$2.prg: struct-by-value.c | $(WORKDIR)
$(if $(QUIET),echo misc/struct-by-value.$1.$2.prg)

View File

@@ -0,0 +1,21 @@
/* Bug 2304 - Visibility of objects/functions undeclared in file scope but 'extern'-declared in unrelated block scopes */
/* This one should fail even in C89 */
void f1(void)
{
extern unsigned int f();
}
/* 'f' is still invisible in the file scope */
int main(void)
{
f(); /* Should be a conflict since the implicit function type is incompatible */
return 0;
}
unsigned int f()
{
return 42;
}