]> git.ipfire.org Git - thirdparty/gcc.git/commit
ada: Fix internal error on aggregates of self-referencing types
authorEric Botcazou <ebotcazou@adacore.com>
Tue, 4 Jul 2023 17:24:07 +0000 (19:24 +0200)
committerMarc Poulhiès <poulhies@adacore.com>
Tue, 18 Jul 2023 13:11:47 +0000 (15:11 +0200)
commitae250f9e3c6f469ff8ed6799225a7aaf6f75cce6
tree271d22ef8baa870b240e718cc2303486a4bc95bd
parent6c431c90947cb5a18d2b8807d5a94c644bd7021c
ada: Fix internal error on aggregates of self-referencing types

The front-end contains a specific mechanism to deal with aggregates of
self-referencing types by means of the Has_Self_Reference flag, which is
supposed to be set during semantic analysis and used during expansion.

The problem is that the first part overlooks aggregates of derived types
which implicitly contain references to an ancestor type (the second part
uses a broader condition but it is effectively guarded by the first one).

This changes both parts to use the same condition based on the Is_Ancestor
predicate, which seems to implement the expected semantic in this case.

gcc/ada/
* sem_type.ads (Is_Ancestor): Remove mention of tagged type.
* exp_aggr.adb: Add with and use clauses for Sem_Type.
(Build_Record_Aggr_Code.Replace_Type): Call Is_Ancestor to spot
self-references to the type of the aggregate.
* sem_aggr.adb (Resolve_Record_Aggregate.Add_Discriminant_Values):
Likewise.
gcc/ada/exp_aggr.adb
gcc/ada/sem_aggr.adb
gcc/ada/sem_type.ads