aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/checks.adb
diff options
context:
space:
mode:
authorArnaud Charlet <charlet@gcc.gnu.org>2014-08-04 11:57:00 +0200
committerArnaud Charlet <charlet@gcc.gnu.org>2014-08-04 11:57:00 +0200
commitbb304287342b02608f8df217b65f2a93f65ae90c (patch)
treef018ecd5df9867a82b2f011873e67be25b6d4580 /gcc/ada/checks.adb
parent7ed571892e5a8d10c14a674e38b980f60115ceb6 (diff)
downloadgcc-bb304287342b02608f8df217b65f2a93f65ae90c.zip
gcc-bb304287342b02608f8df217b65f2a93f65ae90c.tar.gz
gcc-bb304287342b02608f8df217b65f2a93f65ae90c.tar.bz2
[multiple changes]
2014-08-04 Vincent Celier <celier@adacore.com> * prj-dect.adb (Parse_Case_Construction): It is no longer an error if the variable for a case construction is not typed, only if the variable value is not a single string. Call Parse_Choice_List and End_Case_Construction with the new parameter to indicate that the variable is typed. * prj-strt.adb (End_Case_Construction): Only check the labels if the variable is typed. If the variable is not typed, issue a warning when there is no "when others" allternative. (Parse_Choice_List): Manage the labels only if the variable is typed. * prj-strt.ads (End_Case_Construction): New Boolean parameter String_Type. (Parse_Choice_List): Ditto. 2014-08-04 Ed Schonberg <schonberg@adacore.com> * sem_ch5.adb: Additional fix to Check_Predicate_Use. 2014-08-04 Vincent Celier <celier@adacore.com> * projects.texi: Update documentation of case constructions with variables that are not typed. 2014-08-04 Ed Schonberg <schonberg@adacore.com> * sem_ch8.adb (Build_Class_Wide_Wrapper): If the operator carries an Eliminated pragma, indicate that the wrapper is also to be eliminated, to prevent spurious errors when using gnatelim on programs that include box-initialization of equality operators (consequence of AI05-071).. 2014-08-04 Robert Dewar <dewar@adacore.com> * checks.adb (Activate_Overflow_Check): Handle floating-point case correctly. * checks.ads (Activate_Overflow_Check): Clarify handling of floating-point cases. * exp_util.adb (Check_Float_Op_Overflow): Reset Do_Overflow_Check flag if we generate an explicit overflow check (for Check_Float_Overflow mode). From-SVN: r213550
Diffstat (limited to 'gcc/ada/checks.adb')
-rw-r--r--gcc/ada/checks.adb51
1 files changed, 35 insertions, 16 deletions
diff --git a/gcc/ada/checks.adb b/gcc/ada/checks.adb
index 0b934eb..8072629 100644
--- a/gcc/ada/checks.adb
+++ b/gcc/ada/checks.adb
@@ -388,27 +388,46 @@ package body Checks is
-----------------------------
procedure Activate_Overflow_Check (N : Node_Id) is
+ Typ : constant Entity_Id := Etype (N);
+
begin
- -- Nothing to do for unconstrained floating-point types (the test for
- -- Etype (N) being present seems necessary in some cases, should be
- -- tracked down, but for now just ignore the check in this case ???),
- -- except if Check_Float_Overflow is set.
-
- if Present (Etype (N))
- and then Is_Floating_Point_Type (Etype (N))
- and then not Is_Constrained (Etype (N))
- and then not Check_Float_Overflow
- then
- return;
- end if;
+ -- Floating-point case. If Etype is not set (this can happen when we
+ -- activate a check on a node that has not yet been analyzed), then
+ -- we assume we do not have a floating-point type (as per our spec).
- -- Nothing to do for Rem/Mod/Plus (overflow not possible)
+ if Present (Typ) and then Is_Floating_Point_Type (Typ) then
- if Nkind_In (N, N_Op_Rem, N_Op_Mod, N_Op_Plus) then
- return;
+ -- Ignore call if we have no automatic overflow checks on the target
+ -- and Check_Float_Overflow mode is not set. These are the cases in
+ -- which we expect to generate infinities and NaN's with no check.
+
+ if not (Machine_Overflows_On_Target or Check_Float_Overflow) then
+ return;
+
+ -- Ignore for unary operations ("+", "-", abs) since these can never
+ -- result in overflow for floating-point cases.
+
+ elsif Nkind (N) in N_Unary_Op then
+ return;
+
+ -- Otherwise we will set the flag
+
+ else
+ null;
+ end if;
+
+ -- Discrete case
+
+ else
+ -- Nothing to do for Rem/Mod/Plus (overflow not possible, the check
+ -- for zero-divide is a divide check, not an overflow check).
+
+ if Nkind_In (N, N_Op_Rem, N_Op_Mod, N_Op_Plus) then
+ return;
+ end if;
end if;
- -- Otherwise set the flag
+ -- Fall through for cases where we do set the flag
Set_Do_Overflow_Check (N, True);
Possible_Local_Raise (N, Standard_Constraint_Error);