Merge pull request #2370 from acqn/VisibilityFix
[cc65] Fixed visibility of undeclared functions and objects
This commit is contained in:
15
test/err/bug2304-var-use.c
Normal file
15
test/err/bug2304-var-use.c
Normal 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;
|
||||
@@ -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)
|
||||
|
||||
21
test/misc/bug2304-implicit-func.c
Normal file
21
test/misc/bug2304-implicit-func.c
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user