]> git.ipfire.org Git - thirdparty/gcc.git/commit
ada: Reject illegal uses of type/subtype current instance
authorSteve Baird <baird@adacore.com>
Mon, 8 Jul 2024 21:02:15 +0000 (14:02 -0700)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Fri, 2 Aug 2024 07:08:05 +0000 (09:08 +0200)
commite2fe0b18a66aafdd489ba9dbf148794906732f64
tree1342ac68bed2af810ffb088fbeec0f9ef4cb361a
parenta846b4cfc7383e7a2550993cbf669b94db838069
ada: Reject illegal uses of type/subtype current instance

The current instance of a type or subtype (see RM 8.6) is an object or
value, not a type or subtype. So a name denoting such a current instance is
illegal in any context that requires a name denoting a type or subtype.
In some cases this error was not detected.

gcc/ada/

* sem_ch8.adb (Find_Type): If Is_Current_Instance returns True for
N (and Comes_From_Source (N) is also True) then flag an error.
Call Is_Current_Instance (twice) instead of duplicating (twice)
N_Access_Definition-related code in Is_Current_Instance.
* sem_util.adb (Is_Current_Instance): Implement
access-type-related clauses of the RM 8.6 current instance rule.
For pragmas Predicate and Predicate_Failure, distinguish between
the first and subsequent pragma arguments.
gcc/ada/sem_ch8.adb
gcc/ada/sem_util.adb