Created attachment 57455 [details] Reproducer This error is present in GCC 11/12/13/14 -- can’t tell about GCC 10. The error doesn’t occur without -gnata. -- $ /opt/gcc-14.0.1-20240114-x86_64/bin/gnatmake alloc2.adb -gnatwa -gnatl -f -gnata gcc -c -gnatwa -gnatl -gnata alloc2.adb GNAT 14.0.1 20240114 (experimental) Copyright 1992-2023, Free Software Foundation, Inc. Compiling: alloc2.adb Source file time stamp: 2024-02-18 14:27:29 Compiled at: 2024-02-18 14:28:05 1. procedure Alloc2 is 2. type Grid is array (Positive range <>, Positive range <>) of Integer with 3. Dynamic_Predicate => Grid'First (1) = 1 and then Grid'First (2) = 1; 4. 5. type Grid_Ptr is access Grid; 6. 7. Data : Grid_Ptr := new Grid (1 .. 10, 1 .. 20); | >>> error: invalid use of subtype mark in expression or call 8. begin -- Alloc2 9. null; 10. end Alloc2; 10 lines: 1 error gnatmake: "alloc2.adb" compilation error
Presumably something goes wrong during the expansion of the check.
I'll have a look.
The master branch has been updated by Eric Botcazou <ebotcazou@gcc.gnu.org>: https://gcc.gnu.org/g:e71a4e81729516eed8782a255ff37617e6fd4b69 commit r14-9361-ge71a4e81729516eed8782a255ff37617e6fd4b69 Author: Eric Botcazou <ebotcazou@adacore.com> Date: Thu Mar 7 15:05:54 2024 +0100 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.
The releases/gcc-13 branch has been updated by Eric Botcazou <ebotcazou@gcc.gnu.org>: https://gcc.gnu.org/g:0e591e6f27a20c26672ea8c0550a6ef673c1fccf commit r13-8409-g0e591e6f27a20c26672ea8c0550a6ef673c1fccf Author: Eric Botcazou <ebotcazou@adacore.com> Date: Thu Mar 7 15:05:54 2024 +0100 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, remove call to Apply_Predicate_Check. gcc/testsuite/ * gnat.dg/predicate15.adb: New test.
The releases/gcc-12 branch has been updated by Eric Botcazou <ebotcazou@gcc.gnu.org>: https://gcc.gnu.org/g:f9e1d7aa8b4f0b8afff1de59fcadf1db0244b4e1 commit r12-10197-gf9e1d7aa8b4f0b8afff1de59fcadf1db0244b4e1 Author: Eric Botcazou <ebotcazou@adacore.com> Date: Thu Mar 7 15:05:54 2024 +0100 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, remove call to Apply_Predicate_Check. gcc/testsuite/ * gnat.dg/predicate15.adb: New test.
The releases/gcc-11 branch has been updated by Eric Botcazou <ebotcazou@gcc.gnu.org>: https://gcc.gnu.org/g:b26501b6e310345ad9f6423b3f8b9df178c5e7d9 commit r11-11272-gb26501b6e310345ad9f6423b3f8b9df178c5e7d9 Author: Eric Botcazou <ebotcazou@adacore.com> Date: Thu Mar 7 15:05:54 2024 +0100 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, remove call to Apply_Predicate_Check. gcc/testsuite/ * gnat.dg/predicate15.adb: New test.
Fixed on mainline and all branches.