From 3b35a65b1db75bfbde61b6efa8be7cbe32413aca Mon Sep 17 00:00:00 2001 From: Stephen Heumann Date: Tue, 11 Jan 2022 22:21:33 -0600 Subject: [PATCH] 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. --- Parser.pas | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Parser.pas b/Parser.pas index e013d92..da45626 100644 --- a/Parser.pas +++ b/Parser.pas @@ -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;