From 0e827553345b7a50a4fd71b8d50d60adf773e534 Mon Sep 17 00:00:00 2001 From: Stephen Heumann Date: Mon, 3 Oct 2016 18:50:37 -0500 Subject: [PATCH] Fix error that could happen when a function call was used in a comparison expression. This resulted from the addition of the signed-to-unsigned comparison optimization. Specifically, it calls TypeOf for the expressions on each side of the comparison, and this did not handle function calls. That support has now been added, and will give the proper return type for direct and indirect calls to C functions. The IR for tool calls doesn't include the return type (just the number of bytes), so we return cgVoid for them. This is OK for the present use case. --- DAG.pas | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/DAG.pas b/DAG.pas index e3eeac5..5039884 100644 --- a/DAG.pas +++ b/DAG.pas @@ -2193,7 +2193,7 @@ case op^.opcode of pc_gil, pc_gli, pc_gdl, pc_gld, pc_iil, pc_ili, pc_idl, pc_ild, pc_ldc, pc_ldo, pc_lil, pc_lli, pc_ldl, pc_lld, pc_lod, pc_dec, pc_inc, pc_ind, pc_lbf, pc_lbu, pc_cop, pc_cbf, pc_cpi, pc_cpo, - pc_tri: + pc_tri, pc_cup, pc_cui: TypeOf := op^.optype; pc_lad, pc_lao, pc_lca, pc_lda, pc_psh, pc_ixa: @@ -2226,6 +2226,9 @@ case op^.opcode of pc_bno: TypeOf := TypeOf(op^.right); + pc_tl1: {pc_tl1 doesn't have type info.} + TypeOf := cgVoid; {Just return cgVoid for now.} + otherwise: Error(cge1); end; {case} end; {TypeOf}