From 6934c8890d98d3e983d35dde38425af978a4ef95 Mon Sep 17 00:00:00 2001 From: Stephen Heumann Date: Tue, 12 Jul 2022 18:35:52 -0500 Subject: [PATCH] Detect several cases of inappropriate operand types being used with ++ or --. --- Expression.pas | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Expression.pas b/Expression.pas index 0143053..1668162 100644 --- a/Expression.pas +++ b/Expression.pas @@ -3131,7 +3131,9 @@ var else expressionType := doublePtr; goto 1; - end; {else if} + end {if} + else if baseType = cgVoid then + Error(65); end {if} else {if iType^.kind in [pointerType,arrayType] then} begin lSize := iType^.pType^.size; @@ -3183,18 +3185,25 @@ var expressionType := expressionType^.aType else if expressionType^.kind = pointerType then expressionType := expressionType^.pType; + if tqConst in expressionType^.qualifiers then + Error(93); if expressionType^.kind = scalarType then if expressionType^.baseType in [cgByte,cgUByte,cgWord,cgUWord,cgReal,cgDouble,cgComp,cgExtended] then tp := expressionType^.baseType else tp := UsualUnaryConversions - else + else begin + if expressionType^.kind in [structType,unionType,definedType] then + Error(66); tp := UsualUnaryConversions; + end; {else} if (tp in [cgByte,cgUByte,cgWord,cgUword]) and (expressionType^.cType <> ctBool) and not isBitField then Gen0t(pc_i, tp) {do indirect inc/dec} + else if tp = cgVoid then + Error(65) else begin t1 := GetTemp(cgLongSize); Gen2t(pc_str, t1, 0, cgULong);