checks.adb (Expr_Known_Valid): If floating-point validity checks are enabled...
authorEd Schonberg <schonber@gnat.com>
Wed, 27 Oct 2004 12:29:32 +0000 (14:29 +0200)
committerArnaud Charlet <charlet@gcc.gnu.org>
Wed, 27 Oct 2004 12:29:32 +0000 (14:29 +0200)
2004-10-26  Ed Schonberg  <schonberg@gnat.com>

* checks.adb (Expr_Known_Valid): If floating-point validity checks are
enabled, check the result of unary and binary operations when the
expression is the right-hand side of an assignment.

From-SVN: r89645

gcc/ada/checks.adb

index 357d9f290ecfa37fc5bb34b94c4d9246e7c98c7c..a60b21d4ae45cd02fbe1d4501d4181a549232eb4 100644 (file)
@@ -3792,13 +3792,26 @@ package body Checks is
 
       --  The result of any function call or operator is always considered
       --  valid, since we assume the necessary checks are done by the call.
+      --  For operators on floating-point operations, we must also check
+      --  when the operation is the right-hand side of an assignment, or
+      --  is an actual in a call.
 
-      elsif Nkind (Expr) in N_Binary_Op
-              or else
-            Nkind (Expr) in N_Unary_Op
-              or else
-            Nkind (Expr) = N_Function_Call
+      elsif
+        Nkind (Expr) in N_Binary_Op or else Nkind (Expr) in N_Unary_Op
       then
+         if Is_Floating_Point_Type (Typ)
+            and then Validity_Check_Floating_Point
+            and then
+              (Nkind (Parent (Expr)) = N_Assignment_Statement
+                or else Nkind (Parent (Expr)) = N_Function_Call
+                or else Nkind (Parent (Expr)) = N_Parameter_Association)
+         then
+            return False;
+         else
+            return True;
+         end if;
+
+      elsif Nkind (Expr) = N_Function_Call then
          return True;
 
       --  For all other cases, we do not know the expression is valid