aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/sinfo.adb
diff options
context:
space:
mode:
authorHristian Kirtchev <kirtchev@adacore.com>2018-05-23 10:21:42 +0000
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>2018-05-23 10:21:42 +0000
commit40016fa77fa2d0e814f9cd851c8863628c677c52 (patch)
tree8571747bcd27a480cae762f32d87764fb32c348e /gcc/ada/sinfo.adb
parent3d581777692c6e9a03c380daf2c86a64f226850d (diff)
downloadgcc-40016fa77fa2d0e814f9cd851c8863628c677c52.zip
gcc-40016fa77fa2d0e814f9cd851c8863628c677c52.tar.gz
gcc-40016fa77fa2d0e814f9cd851c8863628c677c52.tar.bz2
[Ada] Initialize_Scalars optimization causes spurious runtime check failure
This patch suppresses the optimization of scalar arrays when pragma Initialize_Scalars is in effect if the component type is subject to predicates. Since the scalar array is initialized with invalid values, these values may violate the predicate or a validity check within the predicate. ------------ -- Source -- ------------ -- gnat.adc pragma Initialize_Scalars; -- types.ads with System; use System; package Types is type Byte is mod System.Storage_Unit; subtype Inter_Byte is Byte; function Always_OK (B : Inter_Byte) return Boolean is (True); function Is_OK (B : Inter_Byte) return Boolean is (Always_OK (B)); subtype Final_Byte is Byte with Predicate => Is_OK (Final_Byte); type Bytes is array (1 .. 5) of Final_Byte; Obj : Bytes; end Types; -- main.adb with Types; use Types; procedure Main is begin null; end Main; ----------------- -- Compilation -- ----------------- $ gnatmake -q -gnata -gnatVa main.adb $ ./main 2018-05-23 Hristian Kirtchev <kirtchev@adacore.com> gcc/ada/ * exp_ch3.adb (Default_Initialize_Object): Do not optimize scalar array initialization when the component type has predicates. * exp_ch4.adb (Expand_N_Allocator): Do not optimize scalar array allocation when the component type has predicates. From-SVN: r260572
Diffstat (limited to 'gcc/ada/sinfo.adb')
0 files changed, 0 insertions, 0 deletions