diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2024-03-07 15:05:54 +0100 |
---|---|---|
committer | Eric Botcazou <ebotcazou@adacore.com> | 2024-03-07 15:08:28 +0100 |
commit | e71a4e81729516eed8782a255ff37617e6fd4b69 (patch) | |
tree | a6742d6e025673ab2d40abe584e7b4f788ba516e /gcc/testsuite/gnat.dg | |
parent | 9970b576b7e4ae337af1268395ff221348c4b34a (diff) | |
download | gcc-e71a4e81729516eed8782a255ff37617e6fd4b69.zip gcc-e71a4e81729516eed8782a255ff37617e6fd4b69.tar.gz gcc-e71a4e81729516eed8782a255ff37617e6fd4b69.tar.bz2 |
Fix bogus error on allocator for array type with Dynamic_Predicate
This is a regression present on all active branches: the compiler gives
a bogus error on an allocator for an unconstrained array type declared
with a Dynamic_Predicate because Apply_Predicate_Check is invoked directly
on a subtype reference, which it cannot handle.
This moves the check to the resulting access value (after dereference) like
in Expand_Allocator_Expression.
gcc/ada/
PR ada/113979
* exp_ch4.adb (Expand_N_Allocator): In the subtype indication case,
call Apply_Predicate_Check on the resulting access value if needed.
gcc/testsuite/
* gnat.dg/predicate15.adb: New test.
Diffstat (limited to 'gcc/testsuite/gnat.dg')
-rw-r--r-- | gcc/testsuite/gnat.dg/predicate15.adb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/gcc/testsuite/gnat.dg/predicate15.adb b/gcc/testsuite/gnat.dg/predicate15.adb new file mode 100644 index 0000000..cf9e1d9 --- /dev/null +++ b/gcc/testsuite/gnat.dg/predicate15.adb @@ -0,0 +1,15 @@ +-- { dg-do compile } +-- { dg-options "-gnata" } + +procedure Predicate15 is + + type Grid is array (Positive range <>) of Integer with + Dynamic_Predicate => Grid'First = 1; + + type Grid_Ptr is access Grid; + + Data : Grid_Ptr := new Grid (1 .. 10); + +begin + null; +end; |