diff --git a/.gitattributes b/.gitattributes index da40e16398..f9a5ede566 100644 --- a/.gitattributes +++ b/.gitattributes @@ -13206,6 +13206,7 @@ tests/tbs/tb0667.pp svneol=native#text/pascal tests/tbs/tb0668a.pp svneol=native#text/pascal tests/tbs/tb0668b.pp svneol=native#text/pascal tests/tbs/tb0669.pp svneol=native#text/pascal +tests/tbs/tb0670.pp svneol=native#text/pascal tests/tbs/ub0060.pp svneol=native#text/plain tests/tbs/ub0069.pp svneol=native#text/plain tests/tbs/ub0119.pp svneol=native#text/plain diff --git a/compiler/scanner.pas b/compiler/scanner.pas index 5a27c51e6b..282ad9dd1c 100644 --- a/compiler/scanner.pas +++ b/compiler/scanner.pas @@ -1146,6 +1146,12 @@ type begin if isBoolean then result:=texprvalue.create_bool(not asBool) + else if is_ordinal(def) then + begin + result:=texprvalue.create_ord(value.valueord); + result.def:=def; + calc_not_ordvalue(result.value.valueord,result.def); + end else begin error('Boolean', 'NOT'); @@ -1162,6 +1168,14 @@ type v.error('Boolean','OR'); result:=texprvalue.create_error; end + else if is_ordinal(def) then + if is_ordinal(v.def) then + result:=texprvalue.create_ord(value.valueord or v.value.valueord) + else + begin + v.error('Ordinal','OR'); + result:=texprvalue.create_error; + end else begin error('Boolean','OR'); @@ -1178,6 +1192,14 @@ type v.error('Boolean','XOR'); result:=texprvalue.create_error; end + else if is_ordinal(def) then + if is_ordinal(v.def) then + result:=texprvalue.create_ord(value.valueord xor v.value.valueord) + else + begin + v.error('Ordinal','XOR'); + result:=texprvalue.create_error; + end else begin error('Boolean','XOR'); @@ -1194,6 +1216,14 @@ type v.error('Boolean','AND'); result:=texprvalue.create_error; end + else if is_ordinal(def) then + if is_ordinal(v.def) then + result:=texprvalue.create_ord(value.valueord and v.value.valueord) + else + begin + v.error('Ordinal','AND'); + result:=texprvalue.create_error; + end else begin error('Boolean','AND'); diff --git a/tests/tbs/tb0670.pp b/tests/tbs/tb0670.pp new file mode 100644 index 0000000000..23df21f3e9 --- /dev/null +++ b/tests/tbs/tb0670.pp @@ -0,0 +1,92 @@ +{ %NORUN } + +program tb0670; + +const + Value1 = $06; + Value2 = $60; + Value3 = $6000; + Value4 = $60000000; + Value5 = $60000000000; + + Value6 = $40; + Value7 = $4000; + Value8 = $40000000; + Value9 = $40000000000; + + ValueNot1 = not Value1; + ValueNot2 = not Value2; + ValueNot3 = not Value3; + ValueNot4 = not Value4; + ValueNot5 = not Value5; + + ValueOr1 = Value1 or Value2; + ValueOr2 = Value1 or Value3; + ValueOr3 = Value1 or Value4; + ValueOr4 = Value1 or Value5; + + ValueAnd1 = Value2 and Value6; + ValueAnd2 = Value3 and Value7; + ValueAnd3 = Value4 and Value8; + ValueAnd4 = Value5 and Value9; + +{ Test "not X" } + +{$if not (not Value1 = ValueNot1)} +{$error 'not Value1 = ValueNot1'} +{$endif} + +{$if not (not Value2 = ValueNot2)} +{$error 'not Value2 = ValueNot2'} +{$endif} + +{$if not (not Value3 = ValueNot3)} +{$error 'not Value3 = ValueNot3'} +{$endif} + +{$if not (not Value4 = ValueNot4)} +{$error 'not Value4 = ValueNot4'} +{$endif} + +{$if not (not Value5 = ValueNot5)} +{$error 'not Value5 = ValueNot5'} +{$endif} + +{ Test "X or Y" } + +{$if Value1 or Value2 <> ValueOr1} +{$error 'Value1 or Value2 = ValueOr1'} +{$endif} + +{$if Value1 or Value3 <> ValueOr2} +{$error 'Value1 or Value3 = ValueOr2'} +{$endif} + +{$if Value1 or Value4 <> ValueOr3} +{$error 'Value1 or Value4 = ValueOr3'} +{$endif} + +{$if Value1 or Value5 <> ValueOr4} +{$error 'Value1 or Value5 = ValueOr4'} +{$endif} + +{ Test "X and Y" } + +{$if Value2 and Value6 <> ValueAnd1 } +{$error 'Value2 and Value6 = ValueAnd1' } +{$endif} + +{$if Value3 and Value7 <> ValueAnd2 } +{$error 'Value3 and Value7 = ValueAnd2' } +{$endif} + +{$if Value4 and Value8 <> ValueAnd3 } +{$error 'Value4 and Value8 = ValueAnd3' } +{$endif} + +{$if Value5 and Value9 <> ValueAnd4 } +{$error 'Value5 and Value9 = ValueAnd4' } +{$endif} + +begin +end.