[Ada] Refactor duplicated code for Adjacent, Copy_Sign and Remainder
authorPiotr Trojanek <trojanek@adacore.com>
Mon, 23 Nov 2020 15:40:06 +0000 (16:40 +0100)
committerPierre-Marie de Rodat <derodat@adacore.com>
Tue, 15 Dec 2020 11:41:49 +0000 (06:41 -0500)
gcc/ada/

* sem_attr.adb (Analyze_Attribute): Merge identical code for
Adjacent, Copy_Sign and Remainder attributes.
(Check_Floating_Point_Type_2): Fix style in comment.

gcc/ada/sem_attr.adb

index 3a05565..8f118af 100644 (file)
@@ -348,7 +348,7 @@ package body Sem_Attr is
 
       procedure Check_Floating_Point_Type_2;
       --  Verify that prefix of attribute N is a float type and that
-      --  two attribute expressions are present
+      --  two attribute expressions are present.
 
       procedure Check_Integer_Type;
       --  Verify that prefix of attribute N is an integer type
@@ -3159,7 +3159,10 @@ package body Sem_Attr is
       -- Adjacent --
       --------------
 
-      when Attribute_Adjacent =>
+      when Attribute_Adjacent
+         | Attribute_Copy_Sign
+         | Attribute_Remainder
+      =>
          Check_Floating_Point_Type_2;
          Set_Etype (N, P_Base_Type);
          Resolve (E1, P_Base_Type);
@@ -3617,11 +3620,7 @@ package body Sem_Attr is
       -- Copy_Sign --
       ---------------
 
-      when Attribute_Copy_Sign =>
-         Check_Floating_Point_Type_2;
-         Set_Etype (N, P_Base_Type);
-         Resolve (E1, P_Base_Type);
-         Resolve (E2, P_Base_Type);
+      --  Shares processing with Adjacent attribute
 
       -----------
       -- Count --
@@ -5710,11 +5709,7 @@ package body Sem_Attr is
       -- Remainder --
       ---------------
 
-      when Attribute_Remainder =>
-         Check_Floating_Point_Type_2;
-         Set_Etype (N, P_Base_Type);
-         Resolve (E1, P_Base_Type);
-         Resolve (E2, P_Base_Type);
+      --  Shares processing with Adjacent attribute
 
       ---------------------
       -- Restriction_Set --