diff options
Diffstat (limited to 'src/ortho')
-rw-r--r-- | src/ortho/debug/ortho_debug-disp.adb | 31 | ||||
-rw-r--r-- | src/ortho/oread/ortho_front.adb | 2 |
2 files changed, 29 insertions, 4 deletions
diff --git a/src/ortho/debug/ortho_debug-disp.adb b/src/ortho/debug/ortho_debug-disp.adb index 51707786e..8bdcce98e 100644 --- a/src/ortho/debug/ortho_debug-disp.adb +++ b/src/ortho/debug/ortho_debug-disp.adb @@ -572,9 +572,32 @@ package body Ortho_Debug.Disp is end case; end Disp_Cnode; - -- Disp E whose expected type is ETYPE (may not be set). - procedure Disp_Enode (E : O_Enode; Etype : O_Tnode) + function Is_Neg_Neg (E : O_Enode) return Boolean is + Lit : O_Cnode; + begin + pragma Assert (E.Kind = OE_Neg_Ov); + case E.Operand.Kind is + when OE_Neg_Ov => + return True; + when OE_Lit => + Lit := E.Operand.Lit; + case Lit.Kind is + when OC_Signed_Lit => + return Lit.S_Val < 0; + when OC_Float_Lit => + return Lit.F_Val < 0.0; + when others => + null; + end case; + when others => + null; + end case; + return False; + end Is_Neg_Neg; + + -- Disp E whose expected type is ETYPE (may not be set). + procedure Disp_Enode (E : O_Enode; Etype : O_Tnode) is begin case E.Kind is when OE_Lit => @@ -620,7 +643,9 @@ package body Ortho_Debug.Disp is when others => Disp_Enode_Name (E.Kind); end case; - if E.Kind /= OE_Neg_Ov then + -- Don't print space after '-' unless the operand is also '-'. + -- (avoid to print --, which is a comment). + if E.Kind /= OE_Neg_Ov or else Is_Neg_Neg (E) then Put (' '); end if; Disp_Enode (E.Operand, Etype); diff --git a/src/ortho/oread/ortho_front.adb b/src/ortho/oread/ortho_front.adb index 559ace797..deaa5cf7d 100644 --- a/src/ortho/oread/ortho_front.adb +++ b/src/ortho/oread/ortho_front.adb @@ -1755,7 +1755,7 @@ package body Ortho_Front is Res := New_Lit (Parse_Minus_Num (Atype)); Res_Type := Atype; else - Parse_Primary_Expression (Atype, Res, Res_Type); + Parse_Unary_Expression (Atype, Res, Res_Type); Res := New_Monadic_Op (ON_Neg_Ov, Res); end if; when Tok_Not => |