]> git.ipfire.org Git - thirdparty/gcc.git/commit
Ada: Fix qualified name of discriminant incorrectly accepted in constraint
authorEric Botcazou <ebotcazou@adacore.com>
Wed, 5 Nov 2025 20:15:35 +0000 (21:15 +0100)
committerEric Botcazou <ebotcazou@adacore.com>
Wed, 5 Nov 2025 20:20:46 +0000 (21:20 +0100)
commit35e029530f256bb6302a3cae650d7eaef5514a36
tree11ed020e90061ed242c21fc09ff2de3fac36f9df
parent90f2ab4b6e1463d8cb89c70585e19987a58f3de1
Ada: Fix qualified name of discriminant incorrectly accepted in constraint

The RM 3.8(12/3) subclause says that a discriminant mentioned in a
constraint must appear alone as a direct name.  The last part is not
consistently checked and, while the first part is, it generates a
slightly different error message depending on the form of the input.

This fixes the last part and changes the first to use a single message.

gcc/ada/
PR ada/35793
* sem_res.adb (Check_Discriminant_Use): In a constraint context,
check that the discriminant appears alone as a direct name in all
cases and give a consistent error message when it does not.

gcc/testsuite/
* gnat.dg/specs/discr8.ads: New test.
gcc/ada/sem_res.adb
gcc/testsuite/gnat.dg/specs/discr8.ads [new file with mode: 0644]