diff options
author | Piotr Trojanek <trojanek@adacore.com> | 2020-11-24 00:17:02 +0100 |
---|---|---|
committer | Pierre-Marie de Rodat <derodat@adacore.com> | 2020-12-15 06:41:52 -0500 |
commit | bc57641099316c8dde5258e1e3f5365ef1ac35d0 (patch) | |
tree | bbe6494daf7097dae5ac64f519fdbb52f82e3951 | |
parent | 7addd1cec71610bdad23a261e6c2e516eddb3aab (diff) | |
download | gcc-bc57641099316c8dde5258e1e3f5365ef1ac35d0.zip gcc-bc57641099316c8dde5258e1e3f5365ef1ac35d0.tar.gz gcc-bc57641099316c8dde5258e1e3f5365ef1ac35d0.tar.bz2 |
[Ada] Refactor repeated code for Pred and Succ attributes
gcc/ada/
* sem_attr.adb (Analyze_Attribute): Merge identical code for
Pred and Succ attributes.
-rw-r--r-- | gcc/ada/sem_attr.adb | 35 |
1 files changed, 7 insertions, 28 deletions
diff --git a/gcc/ada/sem_attr.adb b/gcc/ada/sem_attr.adb index 308e5cf..4e4c27a 100644 --- a/gcc/ada/sem_attr.adb +++ b/gcc/ada/sem_attr.adb @@ -5309,15 +5309,17 @@ package body Sem_Attr is -- Pred -- ---------- - when Attribute_Pred => + when Attribute_Pred + | Attribute_Succ + => Check_Scalar_Type; Check_E1; Resolve (E1, P_Base_Type); Set_Etype (N, P_Base_Type); - -- Since Pred works on the base type, we normally do no check for the - -- floating-point case, since the base type is unconstrained. But we - -- make an exception in Check_Float_Overflow mode. + -- Since Pred/Succ work on the base type, we normally do no check for + -- the floating-point case, since the base type is unconstrained. But + -- we make an exception in Check_Float_Overflow mode. if Is_Floating_Point_Type (P_Type) then if not Range_Checks_Suppressed (P_Base_Type) then @@ -6211,30 +6213,7 @@ package body Sem_Attr is -- Succ -- ---------- - when Attribute_Succ => - Check_Scalar_Type; - Check_E1; - Resolve (E1, P_Base_Type); - Set_Etype (N, P_Base_Type); - - -- Since Pred works on the base type, we normally do no check for the - -- floating-point case, since the base type is unconstrained. But we - -- make an exception in Check_Float_Overflow mode. - - if Is_Floating_Point_Type (P_Type) then - if not Range_Checks_Suppressed (P_Base_Type) then - Set_Do_Range_Check (E1); - end if; - - -- If not modular type, test for overflow check required - - else - if not Is_Modular_Integer_Type (P_Type) - and then not Range_Checks_Suppressed (P_Base_Type) - then - Enable_Range_Check (E1); - end if; - end if; + -- Shares processing with Pred attribute -------------------------------- -- System_Allocator_Alignment -- |