aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2022-03-21 08:35:53 +0100
committerPierre-Marie de Rodat <derodat@adacore.com>2022-05-17 08:25:43 +0000
commitd678717ab233610588ae15fcddeb20b39ac7daf5 (patch)
treeb6538731df5f29487a1f0e42bc774e8884803ccf /gcc
parente2f7d58cda63c8764b0c55f13ddee3c9b114182e (diff)
downloadgcc-d678717ab233610588ae15fcddeb20b39ac7daf5.zip
gcc-d678717ab233610588ae15fcddeb20b39ac7daf5.tar.gz
gcc-d678717ab233610588ae15fcddeb20b39ac7daf5.tar.bz2
[Ada] Deal with derived record types in Has_Compatible_Representation
More precisely, untagged record types, as tagged record types are already handled by the predicate. If the derived type has not been given its own representation clause, then the representations are the same. gcc/ada/ * sem_ch13.adb (Has_Compatible_Representation): Return true for derived untagged record types without representation clause.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/sem_ch13.adb10
1 files changed, 10 insertions, 0 deletions
diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb
index 93f5e45..ac94de7 100644
--- a/gcc/ada/sem_ch13.adb
+++ b/gcc/ada/sem_ch13.adb
@@ -13539,6 +13539,16 @@ package body Sem_Ch13 is
if Is_Packed (T1) /= Is_Packed (T2) then
return False;
+ -- If the operand type is derived from the target type and no clause
+ -- has been given after the derivation, then the representations are
+ -- the same since the derived type inherits that of the parent type.
+
+ elsif Is_Derived_Type (T2)
+ and then Etype (T2) = T1
+ and then not Has_Record_Rep_Clause (T2)
+ then
+ return True;
+
-- Otherwise we must check components. Typ2 maybe a constrained
-- subtype with fewer components, so we compare the components
-- of the base types.