mirror of
https://github.com/cc65/cc65.git
synced 2025-01-24 20:30:08 +00:00
Merge pull request #1840 from acqn/FnParamFix
[cc65] Fixed function parameters declared as function types rather than function pointers
This commit is contained in:
commit
d2628d5949
@ -1133,10 +1133,6 @@ static void Primary (ExprDesc* E)
|
||||
/* Enum or some other numeric constant */
|
||||
E->Flags = E_LOC_NONE | E_RTYPE_RVAL;
|
||||
E->IVal = Sym->V.ConstVal;
|
||||
} else if ((Sym->Flags & SC_FUNC) == SC_FUNC) {
|
||||
/* Function */
|
||||
E->Flags = E_LOC_GLOBAL | E_RTYPE_LVAL;
|
||||
E->Name = (uintptr_t) Sym->Name;
|
||||
} else if ((Sym->Flags & SC_AUTO) == SC_AUTO) {
|
||||
/* Local variable. If this is a parameter for a variadic
|
||||
** function, we have to add some address calculations, and the
|
||||
@ -1151,6 +1147,10 @@ static void Primary (ExprDesc* E)
|
||||
E->Flags = E_LOC_STACK | E_RTYPE_LVAL;
|
||||
E->IVal = Sym->V.Offs;
|
||||
}
|
||||
} else if ((Sym->Flags & SC_FUNC) == SC_FUNC) {
|
||||
/* Function */
|
||||
E->Flags = E_LOC_GLOBAL | E_RTYPE_LVAL;
|
||||
E->Name = (uintptr_t) Sym->Name;
|
||||
} else if ((Sym->Flags & SC_REGISTER) == SC_REGISTER) {
|
||||
/* Register variable, zero page based */
|
||||
E->Flags = E_LOC_REGISTER | E_RTYPE_LVAL;
|
||||
|
35
test/val/bug1838.c
Normal file
35
test/val/bug1838.c
Normal file
@ -0,0 +1,35 @@
|
||||
/* Bug 1838 - function parameters declared as function types rather than function pointers */
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
static int failures = 0;
|
||||
|
||||
typedef int fn_t(int);
|
||||
|
||||
int main(void)
|
||||
{
|
||||
void foo(fn_t*);
|
||||
fn_t bar;
|
||||
|
||||
foo(bar);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void foo(int func(int))
|
||||
{
|
||||
int n = func(42);
|
||||
|
||||
if (n != 12) {
|
||||
printf("n = %d, expected: 12\n", n);
|
||||
++failures;
|
||||
}
|
||||
}
|
||||
|
||||
int bar(int a)
|
||||
{
|
||||
if (a != 42) {
|
||||
printf("a = %d, expected: 42\n", a);
|
||||
++failures;
|
||||
}
|
||||
return 12;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user