Commit e9a79435 by Robert Dewar Committed by Arnaud Charlet

exp_ch5.adb, [...]: Minor comment correction.

2014-07-31  Robert Dewar  <dewar@adacore.com>

	* exp_ch5.adb, freeze.adb, exp_ch3.adb: Minor comment correction.
	* s-arit64.adb: Minor reformatting.

2014-07-31  Robert Dewar  <dewar@adacore.com>

	* gnat1drv.adb (Adjust_Global_Switches): Default for overflow
	checking is enabled except in GNAT_Mode.
	* switch-c.adb (Scan_Front_End_Switches): Implement -gnato0
	(suppress overflow checks).

From-SVN: r213327
parent 7c0c194b
2014-07-31 Robert Dewar <dewar@adacore.com>
* exp_ch5.adb, freeze.adb, exp_ch3.adb: Minor comment correction.
* s-arit64.adb: Minor reformatting.
2014-07-31 Robert Dewar <dewar@adacore.com>
* gnat1drv.adb (Adjust_Global_Switches): Default for overflow
checking is enabled except in GNAT_Mode.
* switch-c.adb (Scan_Front_End_Switches): Implement -gnato0
(suppress overflow checks).
2014-07-31 Ed Schonberg <schonberg@adacore.com> 2014-07-31 Ed Schonberg <schonberg@adacore.com>
* exp_ch3.adb (Expand_Freeze_Record_Type): Do not build an * exp_ch3.adb (Expand_Freeze_Record_Type): Do not build an
......
...@@ -1752,7 +1752,7 @@ package body Exp_Ch3 is ...@@ -1752,7 +1752,7 @@ package body Exp_Ch3 is
-- objects on list Decls. -- objects on list Decls.
function Build_Init_Call_Thru (Parameters : List_Id) return List_Id; function Build_Init_Call_Thru (Parameters : List_Id) return List_Id;
-- Given a untagged type-derivation that declares discriminants, e.g. -- Given an untagged type-derivation that declares discriminants, e.g.
-- --
-- type R (R1, R2 : Integer) is record ... end record; -- type R (R1, R2 : Integer) is record ... end record;
-- type D (D1 : Integer) is new R (1, D1); -- type D (D1 : Integer) is new R (1, D1);
...@@ -5838,7 +5838,7 @@ package body Exp_Ch3 is ...@@ -5838,7 +5838,7 @@ package body Exp_Ch3 is
-- Handle C++ constructor calls. Note that we do not check that -- Handle C++ constructor calls. Note that we do not check that
-- Typ is a tagged type since the equivalent Ada type of a C++ -- Typ is a tagged type since the equivalent Ada type of a C++
-- class that has no virtual methods is a untagged limited -- class that has no virtual methods is an untagged limited
-- record type. -- record type.
elsif Is_CPP_Constructor_Call (Expr) then elsif Is_CPP_Constructor_Call (Expr) then
......
...@@ -106,7 +106,7 @@ package body Exp_Ch5 is ...@@ -106,7 +106,7 @@ package body Exp_Ch5 is
-- using the standard Insert_Actions mechanism. -- using the standard Insert_Actions mechanism.
procedure Expand_Assign_Record (N : Node_Id); procedure Expand_Assign_Record (N : Node_Id);
-- N is an assignment of a untagged record value. This routine handles -- N is an assignment of an untagged record value. This routine handles
-- the case where the assignment must be made component by component, -- the case where the assignment must be made component by component,
-- either because the target is not byte aligned, or there is a change -- either because the target is not byte aligned, or there is a change
-- of representation, or when we have a tagged type with a representation -- of representation, or when we have a tagged type with a representation
......
...@@ -4537,8 +4537,8 @@ package body Freeze is ...@@ -4537,8 +4537,8 @@ package body Freeze is
return No_List; return No_List;
end if; end if;
-- Check for error of Type_Invariant'Class applied to a untagged type -- Check for error of Type_Invariant'Class applied to an untagged
-- (check delayed to freeze time when full type is available). -- type (check delayed to freeze time when full type is available).
declare declare
Prag : constant Node_Id := Get_Pragma (E, Pragma_Invariant); Prag : constant Node_Id := Get_Pragma (E, Pragma_Invariant);
......
...@@ -511,9 +511,13 @@ procedure Gnat1drv is ...@@ -511,9 +511,13 @@ procedure Gnat1drv is
-- Otherwise set overflow mode defaults -- Otherwise set overflow mode defaults
else else
-- Otherwise set overflow checks off by default -- Overflow checks are on by default (Suppress set False) except in
-- GNAT_Mode, where we want them off by default (we are not ready to
-- enable overflow checks in the compiler yet, for one thing the case
-- of 64-bit checks needs System.Arith_64 which is not a compiler
-- unit and it is a pain to try to include it in the compiler.
Suppress_Options.Suppress (Overflow_Check) := True; Suppress_Options.Suppress (Overflow_Check) := GNAT_Mode;
-- Set appropriate default overflow handling mode. Note: at present -- Set appropriate default overflow handling mode. Note: at present
-- we set STRICT in all three of the following cases. They are -- we set STRICT in all three of the following cases. They are
...@@ -531,8 +535,8 @@ procedure Gnat1drv is ...@@ -531,8 +535,8 @@ procedure Gnat1drv is
-- flags set, so this was dead code anyway. -- flags set, so this was dead code anyway.
elsif Targparm.Backend_Divide_Checks_On_Target elsif Targparm.Backend_Divide_Checks_On_Target
and and
Targparm.Backend_Overflow_Checks_On_Target Targparm.Backend_Overflow_Checks_On_Target
then then
Suppress_Options.Overflow_Mode_General := Strict; Suppress_Options.Overflow_Mode_General := Strict;
Suppress_Options.Overflow_Mode_Assertions := Strict; Suppress_Options.Overflow_Mode_Assertions := Strict;
......
...@@ -259,8 +259,8 @@ package body System.Arith_64 is ...@@ -259,8 +259,8 @@ package body System.Arith_64 is
T2 := 0; T2 := 0;
end if; end if;
-- Here we have T2 set to the contribution to the upper half -- Here we have T2 set to the contribution to the upper half of the
-- of the result from the upper halves of the input values. -- result from the upper halves of the input values.
T1 := Xlo * Ylo; T1 := Xlo * Ylo;
T2 := T2 + Hi (T1); T2 := T2 + Hi (T1);
...@@ -332,9 +332,9 @@ package body System.Arith_64 is ...@@ -332,9 +332,9 @@ package body System.Arith_64 is
Scale : Natural; Scale : Natural;
-- Scaling factor used for multiple-precision divide. Dividend and -- Scaling factor used for multiple-precision divide. Dividend and
-- Divisor are multiplied by 2 ** Scale, and the final remainder -- Divisor are multiplied by 2 ** Scale, and the final remainder is
-- is divided by the scaling factor. The reason for this scaling -- divided by the scaling factor. The reason for this scaling is to
-- is to allow more accurate estimation of quotient digits. -- allow more accurate estimation of quotient digits.
T1, T2, T3 : Uns64; T1, T2, T3 : Uns64;
-- Temporary values -- Temporary values
...@@ -383,8 +383,8 @@ package body System.Arith_64 is ...@@ -383,8 +383,8 @@ package body System.Arith_64 is
D (1) := 0; D (1) := 0;
end if; end if;
-- Now it is time for the dreaded multiple precision division. First -- Now it is time for the dreaded multiple precision division. First an
-- an easy case, check for the simple case of a one digit divisor. -- easy case, check for the simple case of a one digit divisor.
if Zhi = 0 then if Zhi = 0 then
if D (1) /= 0 or else D (2) >= Zlo then if D (1) /= 0 or else D (2) >= Zlo then
......
...@@ -953,38 +953,57 @@ package body Switch.C is ...@@ -953,38 +953,57 @@ package body Switch.C is
when 'o' => when 'o' =>
Ptr := Ptr + 1; Ptr := Ptr + 1;
Suppress_Options.Suppress (Overflow_Check) := False;
-- Case of no digits after the -gnato -- Case of -gnato0 (overflow checking turned off)
if Ptr <= Max and then Switch_Chars (Ptr) = '0' then
Ptr := Ptr + 1;
Suppress_Options.Suppress (Overflow_Check) := True;
-- We set strict mode in case overflow checking is turned
-- on locally (also records that we had a -gnato switch).
if Ptr > Max or else Switch_Chars (Ptr) not in '1' .. '3' then
Suppress_Options.Overflow_Mode_General := Strict; Suppress_Options.Overflow_Mode_General := Strict;
Suppress_Options.Overflow_Mode_Assertions := Strict; Suppress_Options.Overflow_Mode_Assertions := Strict;
-- At least one digit after the -gnato -- All cases other than -gnato0 (overflow checking turned on)
else else
-- Handle first digit after -gnato Suppress_Options.Suppress (Overflow_Check) := False;
Suppress_Options.Overflow_Mode_General :=
Get_Overflow_Mode (Switch_Chars (Ptr));
Ptr := Ptr + 1;
-- Only one digit after -gnato, set assertions mode to -- Case of no digits after the -gnato
-- be the same as general mode.
if Ptr > Max if Ptr > Max
or else Switch_Chars (Ptr) not in '1' .. '3' or else Switch_Chars (Ptr) not in '1' .. '3'
then then
Suppress_Options.Overflow_Mode_Assertions := Suppress_Options.Overflow_Mode_General := Strict;
Suppress_Options.Overflow_Mode_General; Suppress_Options.Overflow_Mode_Assertions := Strict;
-- Process second digit after -gnato -- At least one digit after the -gnato
else else
Suppress_Options.Overflow_Mode_Assertions := -- Handle first digit after -gnato
Suppress_Options.Overflow_Mode_General :=
Get_Overflow_Mode (Switch_Chars (Ptr)); Get_Overflow_Mode (Switch_Chars (Ptr));
Ptr := Ptr + 1; Ptr := Ptr + 1;
-- Only one digit after -gnato, set assertions mode to be
-- the same as general mode.
if Ptr > Max
or else Switch_Chars (Ptr) not in '1' .. '3'
then
Suppress_Options.Overflow_Mode_Assertions :=
Suppress_Options.Overflow_Mode_General;
-- Process second digit after -gnato
else
Suppress_Options.Overflow_Mode_Assertions :=
Get_Overflow_Mode (Switch_Chars (Ptr));
Ptr := Ptr + 1;
end if;
end if; end if;
end if; end if;
...@@ -1026,6 +1045,13 @@ package body Switch.C is ...@@ -1026,6 +1045,13 @@ package body Switch.C is
Validity_Checks_On := False; Validity_Checks_On := False;
Opt.Suppress_Checks := True; Opt.Suppress_Checks := True;
-- Set overflow mode checking to strict in case it gets
-- turned on locally (also signals that overflow checking
-- has been specifically turned off).
Suppress_Options.Overflow_Mode_General := Strict;
Suppress_Options.Overflow_Mode_Assertions := Strict;
end if; end if;
-- -gnatP (periodic poll) -- -gnatP (periodic poll)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment