Give an error if a function pointer is redefined as a function.

This gives an error for code like the following, which was previously allowed:

void (*p)(int);
void p(int i) {}

Note that the opposite order still does not give a compiler error, but does give linker errors. Making sure we give a compiler error for all similar cases would require larger changes, but this patch at least catches some erroneous cases that were previously being allowed.
This commit is contained in:
Stephen Heumann 2022-01-11 22:21:33 -06:00
parent 61a382de0b
commit 3b35a65b1d
1 changed files with 1 additions and 1 deletions

View File

@ -1748,7 +1748,7 @@ if tPtr^.kind = functionType then begin {declare the identifier}
tPtr^.parameterList := p1;
end; {if}
t1 := variable^.itype;
if CompTypes(t1, tPtr) then begin
if (t1^.kind = functionType) and CompTypes(t1, tPtr) then begin
if t1^.prototyped and tPtr^.prototyped then begin
p2 := tPtr^.parameterList;
p1 := t1^.parameterList;