diff options
author | Ed Schonberg <schonberg@adacore.com> | 2018-05-22 13:20:26 +0000 |
---|---|---|
committer | Pierre-Marie de Rodat <pmderodat@gcc.gnu.org> | 2018-05-22 13:20:26 +0000 |
commit | f2df0100b287653c12f807c2e9d6a64d0982428f (patch) | |
tree | 97bfbd872c5c76d53e4338777630148c57efbc92 | |
parent | b8bbe7398f494f96ab33d9c4ee32c83f220d3543 (diff) | |
download | gcc-f2df0100b287653c12f807c2e9d6a64d0982428f.zip gcc-f2df0100b287653c12f807c2e9d6a64d0982428f.tar.gz gcc-f2df0100b287653c12f807c2e9d6a64d0982428f.tar.bz2 |
[Ada] Spurious size error on fixed point type with aspect Small
This path fixes a spurious size error on a fixed point that carries an
aspect specification for the 'Small of the type, when there is a subsequent
derivation of that type before the type is frozen, the given 'Small is not
not a power of two, and the bounds of the type require its full size, also
given by an aspect specification.
2018-05-22 Ed Schonberg <schonberg@adacore.com>
gcc/ada/
* freeze.adb (Freeze_Fixed_Point_Type): If the first subtype has
delayed aspects, analyze them now, os that the representation of the
type (size, bounds) can be computed and validated.
gcc/testsuite/
* gnat.dg/fixedpnt3.adb: New testcase.
From-SVN: r260511
-rw-r--r-- | gcc/ada/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/ada/freeze.adb | 10 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/gnat.dg/fixedpnt3.adb | 16 |
4 files changed, 36 insertions, 0 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 6b3e907..aae611c 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,9 @@ +2018-05-22 Ed Schonberg <schonberg@adacore.com> + + * freeze.adb (Freeze_Fixed_Point_Type): If the first subtype has + delayed aspects, analyze them now, os that the representation of the + type (size, bounds) can be computed and validated. + 2018-05-22 Olivier Hainque <hainque@adacore.com> * libgnat/s-dwalin.adb (Enable_Cache): Skip symbols outside of the diff --git a/gcc/ada/freeze.adb b/gcc/ada/freeze.adb index 44067e1..da77818 100644 --- a/gcc/ada/freeze.adb +++ b/gcc/ada/freeze.adb @@ -7466,6 +7466,16 @@ package body Freeze is -- Start of processing for Freeze_Fixed_Point_Type begin + -- The type, or its first subtype if we are freezing the anonymous + -- base, may have a delayed Small aspect. It must be analyzed now, + -- so that all characteristics of the type (size, bounds) can be + -- computed and validated in the call to Minimum_Size that follows. + + if Has_Delayed_Aspects (First_Subtype (Typ)) then + Analyze_Aspects_At_Freeze_Point (First_Subtype (Typ)); + Set_Has_Delayed_Aspects (First_Subtype (Typ), False); + end if; + -- If Esize of a subtype has not previously been set, set it now if Unknown_Esize (Typ) then diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ca61568..6422003 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2018-05-22 Ed Schonberg <schonberg@adacore.com> + + * gnat.dg/fixedpnt3.adb: New testcase. + 2018-05-22 Justin Squirek <squirek@adacore.com> * gnat.dg/pure_function1.adb, gnat.dg/pure_function1.ads, diff --git a/gcc/testsuite/gnat.dg/fixedpnt3.adb b/gcc/testsuite/gnat.dg/fixedpnt3.adb new file mode 100644 index 0000000..0c2b14a --- /dev/null +++ b/gcc/testsuite/gnat.dg/fixedpnt3.adb @@ -0,0 +1,16 @@ +-- { dg-do compile } +-- { dg-options "-gnatws" } + +procedure Fixedpnt3 is + C_Unit : constant := 0.001; + + type T_Fixed_Point is + delta C_Unit range (-2 ** 63) * C_Unit .. (2 ** 63 - 1) * C_Unit + with Size => 64, Small => C_Unit; + + type T_Short_Fixed_Point is + new T_Fixed_Point range (-2 ** 31) * C_Unit .. (2 ** 31 - 1) * C_Unit + with Size => 32; +begin + null; +end Fixedpnt3; |