+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>
* exp_ch3.adb (Expand_Freeze_Record_Type): Do not build an
-- objects on list Decls.
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 D (D1 : Integer) is new R (1, D1);
-- Handle C++ constructor calls. Note that we do not check that
-- 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.
elsif Is_CPP_Constructor_Call (Expr) then
-- using the standard Insert_Actions mechanism.
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,
-- 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
return No_List;
end if;
- -- Check for error of Type_Invariant'Class applied to a untagged type
- -- (check delayed to freeze time when full type is available).
+ -- Check for error of Type_Invariant'Class applied to an untagged
+ -- type (check delayed to freeze time when full type is available).
declare
Prag : constant Node_Id := Get_Pragma (E, Pragma_Invariant);
-- Otherwise set overflow mode defaults
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
-- we set STRICT in all three of the following cases. They are
-- flags set, so this was dead code anyway.
elsif Targparm.Backend_Divide_Checks_On_Target
- and
- Targparm.Backend_Overflow_Checks_On_Target
+ and
+ Targparm.Backend_Overflow_Checks_On_Target
then
Suppress_Options.Overflow_Mode_General := Strict;
Suppress_Options.Overflow_Mode_Assertions := Strict;
T2 := 0;
end if;
- -- Here we have T2 set to the contribution to the upper half
- -- of the result from the upper halves of the input values.
+ -- Here we have T2 set to the contribution to the upper half of the
+ -- result from the upper halves of the input values.
T1 := Xlo * Ylo;
T2 := T2 + Hi (T1);
Scale : Natural;
-- Scaling factor used for multiple-precision divide. Dividend and
- -- Divisor are multiplied by 2 ** Scale, and the final remainder
- -- is divided by the scaling factor. The reason for this scaling
- -- is to allow more accurate estimation of quotient digits.
+ -- Divisor are multiplied by 2 ** Scale, and the final remainder is
+ -- divided by the scaling factor. The reason for this scaling is to
+ -- allow more accurate estimation of quotient digits.
T1, T2, T3 : Uns64;
-- Temporary values
D (1) := 0;
end if;
- -- Now it is time for the dreaded multiple precision division. First
- -- an easy case, check for the simple case of a one digit divisor.
+ -- Now it is time for the dreaded multiple precision division. First an
+ -- easy case, check for the simple case of a one digit divisor.
if Zhi = 0 then
if D (1) /= 0 or else D (2) >= Zlo then
when 'o' =>
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_Assertions := Strict;
- -- At least one digit after the -gnato
+ -- All cases other than -gnato0 (overflow checking turned on)
else
- -- Handle first digit after -gnato
-
- Suppress_Options.Overflow_Mode_General :=
- Get_Overflow_Mode (Switch_Chars (Ptr));
- Ptr := Ptr + 1;
+ Suppress_Options.Suppress (Overflow_Check) := False;
- -- Only one digit after -gnato, set assertions mode to
- -- be the same as general mode.
+ -- Case of no digits after the -gnato
if Ptr > Max
or else Switch_Chars (Ptr) not in '1' .. '3'
then
- Suppress_Options.Overflow_Mode_Assertions :=
- Suppress_Options.Overflow_Mode_General;
+ Suppress_Options.Overflow_Mode_General := Strict;
+ Suppress_Options.Overflow_Mode_Assertions := Strict;
- -- Process second digit after -gnato
+ -- At least one digit after the -gnato
else
- Suppress_Options.Overflow_Mode_Assertions :=
+ -- Handle first digit after -gnato
+
+ Suppress_Options.Overflow_Mode_General :=
Get_Overflow_Mode (Switch_Chars (Ptr));
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;
Validity_Checks_On := False;
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;
-- -gnatP (periodic poll)