From: Eric Botcazou Date: Wed, 4 Mar 2026 13:27:06 +0000 (+0100) Subject: ada: Skip layout derivation for C-compatible unchecked union types X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=98404b20b9fd7376f8facea90167e97de665bef3;p=thirdparty%2Fgcc.git ada: Skip layout derivation for C-compatible unchecked union types The machinery that computes the layout of derived types does not support C-compatible unchecked union types, but their layout is fixed in any case. gcc/ada/ChangeLog: * gcc-interface/decl.cc (gnat_to_gnu_entity) : Do not derive the layout of C-compatible unchecked union types. --- diff --git a/gcc/ada/gcc-interface/decl.cc b/gcc/ada/gcc-interface/decl.cc index 9b64544a2f2..cf6c37f1ca2 100644 --- a/gcc/ada/gcc-interface/decl.cc +++ b/gcc/ada/gcc-interface/decl.cc @@ -3551,8 +3551,11 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition) } /* If this is a derived type with discriminants and these discriminants - affect the initial shape it has inherited, factor them in. */ - if (has_discr + affect the initial shape it has inherited, factor them in, but this + is not needed for a C-compatible Unchecked_Union since the variants + are at offset 0 in there. */ + if (TREE_CODE (gnu_type) == RECORD_TYPE + && has_discr && !is_extension && !Has_Record_Rep_Clause (gnat_entity) && Stored_Constraint (gnat_entity) != No_Elist