Patchwork [Ada] Check matching Float_Representation on OpenVMS

login
register
mail settings
Submitter Arnaud Charlet
Date Dec. 23, 2011, 9:37 a.m.
Message ID <20111223093707.GA2744@adacore.com>
Download mbox | patch
Permalink /patch/132981/
State New
Headers show

Comments

Arnaud Charlet - Dec. 23, 2011, 9:37 a.m.
On OpenVMS targets, a configuration pragma Float_Representation
indicates that the specified representation (IEEE, VAX) should
be the default for predefined floating point types and for
new floating point definitions.

Tested on x86_64-pc-linux-gnu, committed on trunk

2011-12-23  Geert Bosch  <bosch@adacore.com>

	* sem_ch3.adb (Can_Derive_From): Check matching Float_Rep on VMS.

Patch

Index: sem_ch3.adb
===================================================================
--- sem_ch3.adb	(revision 182654)
+++ sem_ch3.adb	(working copy)
@@ -15333,10 +15333,23 @@ 
          Spec : constant Entity_Id := Real_Range_Specification (Def);
 
       begin
+         --  Check specified "digits" constraint
+
          if Digs_Val > Digits_Value (E) then
             return False;
          end if;
 
+         --  Avoid types not matching pragma Float_Representation, if present
+
+         if (Opt.Float_Format = 'I' and then Float_Rep (E) /= IEEE_Binary)
+              or else
+            (Opt.Float_Format = 'V' and then Float_Rep (E) /= VAX_Native)
+         then
+            return False;
+         end if;
+
+         --  Check for matching range, if specified
+
          if Present (Spec) then
             if Expr_Value_R (Type_Low_Bound (E)) >
                Expr_Value_R (Low_Bound (Spec))