[Ada] Refactor duplicated code for floating point attributes
authorPiotr Trojanek <trojanek@adacore.com>
Mon, 23 Nov 2020 12:47:39 +0000 (13:47 +0100)
committerPierre-Marie de Rodat <derodat@adacore.com>
Mon, 14 Dec 2020 15:51:55 +0000 (10:51 -0500)
gcc/ada/

* sem_attr.adb (Analyze_Attribute): Merge identical code for
Ceiling, Floor, Fraction, Machine, Machine_Rounding, Model,
Rounding and Unbiased_Rounding.

gcc/ada/sem_attr.adb

index 504ca97..847d863 100644 (file)
@@ -3395,7 +3395,15 @@ package body Sem_Attr is
       -- Ceiling --
       -------------
 
-      when Attribute_Ceiling =>
+      when Attribute_Ceiling
+         | Attribute_Floor
+         | Attribute_Fraction
+         | Attribute_Machine
+         | Attribute_Machine_Rounding
+         | Attribute_Model
+         | Attribute_Rounding
+         | Attribute_Unbiased_Rounding
+      =>
          Check_Floating_Point_Type_1;
          Set_Etype (N, P_Base_Type);
          Resolve (E1, P_Base_Type);
@@ -4091,10 +4099,7 @@ package body Sem_Attr is
       -- Floor --
       -----------
 
-      when Attribute_Floor =>
-         Check_Floating_Point_Type_1;
-         Set_Etype (N, P_Base_Type);
-         Resolve (E1, P_Base_Type);
+      --  Shares processing with Ceiling attribute
 
       ----------
       -- Fore --
@@ -4108,10 +4113,7 @@ package body Sem_Attr is
       -- Fraction --
       --------------
 
-      when Attribute_Fraction =>
-         Check_Floating_Point_Type_1;
-         Set_Etype (N, P_Base_Type);
-         Resolve (E1, P_Base_Type);
+      --  Shares processing with Ceiling attribute
 
       --------------
       -- From_Any --
@@ -4690,10 +4692,7 @@ package body Sem_Attr is
       -- Machine --
       -------------
 
-      when Attribute_Machine =>
-         Check_Floating_Point_Type_1;
-         Set_Etype (N, P_Base_Type);
-         Resolve (E1, P_Base_Type);
+      --  Shares processing with Ceiling attribute
 
       ------------------
       -- Machine_Emax --
@@ -4741,10 +4740,7 @@ package body Sem_Attr is
       -- Machine_Rounding --
       ----------------------
 
-      when Attribute_Machine_Rounding =>
-         Check_Floating_Point_Type_1;
-         Set_Etype (N, P_Base_Type);
-         Resolve (E1, P_Base_Type);
+      --  Shares processing with Ceiling attribute
 
       --------------------
       -- Machine_Rounds --
@@ -4866,10 +4862,7 @@ package body Sem_Attr is
       -- Model --
       -----------
 
-      when Attribute_Model =>
-         Check_Floating_Point_Type_1;
-         Set_Etype (N, P_Base_Type);
-         Resolve (E1, P_Base_Type);
+      --  Shares processing with Ceiling attribute
 
       ----------------
       -- Model_Emin --
@@ -5844,10 +5837,7 @@ package body Sem_Attr is
       -- Rounding --
       --------------
 
-      when Attribute_Rounding =>
-         Check_Floating_Point_Type_1;
-         Set_Etype (N, P_Base_Type);
-         Resolve (E1, P_Base_Type);
+      --  Shares processing with Ceiling attribute
 
       ---------------
       -- Safe_Emax --
@@ -6611,10 +6601,7 @@ package body Sem_Attr is
       -- Unbiased_Rounding --
       -----------------------
 
-      when Attribute_Unbiased_Rounding =>
-         Check_Floating_Point_Type_1;
-         Set_Etype (N, P_Base_Type);
-         Resolve (E1, P_Base_Type);
+      --  Shares processing with Ceiling attribute
 
       ----------------------
       -- Unchecked_Access --