From 5321ef2f84d96532665fa396790d6e6ceacdd031 Mon Sep 17 00:00:00 2001 From: Stephen Heumann Date: Tue, 20 Jun 2017 18:45:33 -0500 Subject: [PATCH] Treat array types as compatible with corresponding pointer types in function prototypes. This permits code like the following to compile, as it should: int foo(int*); int foo(int[]); int foo(int[42]); --- Parser.pas | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Parser.pas b/Parser.pas index 2a1057b..624b8b7 100644 --- a/Parser.pas +++ b/Parser.pas @@ -1596,7 +1596,18 @@ if tPtr^.kind = functionType then begin {declare the identifier} pt2 := p2^.parameterType else pt2 := p2^.parameter^.itype; - if not CompTypes(pt1, pt2) then begin + compatible := false; + if CompTypes(pt1, pt2) then + compatible := true + else begin + tk1 := pt1^.kind; + tk2 := pt2^.kind; + if (tk1 = arrayType) and (tk2 = pointerType) then + compatible := CompTypes(pt1^.aType, pt2^.pType) + else if (tk1 = pointerType) and (tk2 = arrayType) then + compatible := CompTypes(pt1^.pType, pt2^.aType) + end; {else} + if not compatible then begin Error(47); goto 1; end; {if}