diff options
author | Hristian Kirtchev <kirtchev@adacore.com> | 2018-05-25 09:05:15 +0000 |
---|---|---|
committer | Pierre-Marie de Rodat <pmderodat@gcc.gnu.org> | 2018-05-25 09:05:15 +0000 |
commit | bf5899e71ea7ca1cc3ae9007c2d5e06ee4108d2a (patch) | |
tree | 5839a309bf58d480c43a1065d5ddf6721c4c94ac /gcc | |
parent | f70b01165e6d392a110cb963060ea2a17feebbb7 (diff) | |
download | gcc-bf5899e71ea7ca1cc3ae9007c2d5e06ee4108d2a.zip gcc-bf5899e71ea7ca1cc3ae9007c2d5e06ee4108d2a.tar.gz gcc-bf5899e71ea7ca1cc3ae9007c2d5e06ee4108d2a.tar.bz2 |
[Ada] Spurious range check with Initialize_Scalars
This patch modifies the expansion of default-initialized array objects when
pragma Initialize_Scalars or Normalize_Scalars is in effect to suppress the
generation of checks on the constructed in-place aggregate. The aggregate
intentionally contains invalid values which may not necessarily fit the
constraints of a particular component type. Check suppression ensures that
no spurious checks are generated, and that the effects of the pragmas are
carried out.
------------
-- Source --
------------
-- gnat.adc
pragma Initialize_Scalars;
-- init_scalar.adb
with Ada.Text_IO; use Ada.Text_IO;
procedure Init_Scalar is
type Fixed is delta 0.25 range -12.0 .. 1270.0;
type Fixed_Array is array (1 .. 1) of Fixed;
begin
begin
declare
Obj : Fixed;
pragma Unreferenced (Obj);
begin null; end;
exception
when others => Put_Line ("ERROR: Fixed raised exception");
end;
begin
declare
Obj : Fixed_Array;
pragma Unreferenced (Obj);
begin null; end;
exception
when others => Put_Line ("ERROR: Fixed_Array raised exception");
end;
end Init_Scalar;
-----------------
-- Compilation --
-----------------
$ gnatmake -q init_scalar.adb
$ ./init_scalar
2018-05-25 Hristian Kirtchev <kirtchev@adacore.com>
gcc/ada/
* exp_ch3.adb (Default_Initialize_Object): Ensure that the analysis of
the in-place initialization aggregate created for pragmas
Initialize_Scalars or Normalize_Scalars is performed with checks
suppressed.
From-SVN: r260740
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ada/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/ada/exp_ch3.adb | 3 |
2 files changed, 9 insertions, 1 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index ec7bee6..ba22139 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,10 @@ +2018-05-25 Hristian Kirtchev <kirtchev@adacore.com> + + * exp_ch3.adb (Default_Initialize_Object): Ensure that the analysis of + the in-place initialization aggregate created for pragmas + Initialize_Scalars or Normalize_Scalars is performed with checks + suppressed. + 2018-05-25 Arnaud Charlet <charlet@adacore.com> * exp_aggr.adb (Convert_To_Positional): Bump default for diff --git a/gcc/ada/exp_ch3.adb b/gcc/ada/exp_ch3.adb index d1ed971..db93b64 100644 --- a/gcc/ada/exp_ch3.adb +++ b/gcc/ada/exp_ch3.adb @@ -6109,7 +6109,8 @@ package body Exp_Ch3 is N => Obj_Def, Size => Esize (Def_Id))); - Analyze_And_Resolve (Expression (N), Typ); + Analyze_And_Resolve + (Expression (N), Typ, Suppress => All_Checks); -- Otherwise invoke the type init proc, generate: -- Type_Init_Proc (Obj); |