]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[Ada] Do not back-annotate maximum size for limited types
authorEric Botcazou <ebotcazou@adacore.com>
Thu, 18 Nov 2021 21:47:05 +0000 (22:47 +0100)
committerPierre-Marie de Rodat <derodat@adacore.com>
Thu, 2 Dec 2021 16:26:31 +0000 (16:26 +0000)
gcc/ada/

* gcc-interface/decl.c (gnat_to_gnu_entity): Do not back-annotate a
maximum size for the Esize of limited record and concurrent types.

gcc/ada/gcc-interface/decl.c

index f0c17fc5eabc17be5f1d5d1eeae9b2093080dc4a..93b6eb5bb4520697c9a8be8501dad084dfe5ff2e 100644 (file)
@@ -4426,8 +4426,12 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition)
          tree size = TYPE_SIZE (gnu_type);
 
          /* If the size is self-referential, annotate the maximum value
-            after saturating it, if need be, to avoid a No_Uint value.  */
-         if (CONTAINS_PLACEHOLDER_P (size))
+            after saturating it, if need be, to avoid a No_Uint value.
+            But do not do it for cases where Analyze_Object_Declaration
+            in Sem_Ch3 would build a default subtype for objects.  */
+         if (CONTAINS_PLACEHOLDER_P (size)
+             && !Is_Limited_Record (gnat_entity)
+             && !Is_Concurrent_Type (gnat_entity))
            {
              const unsigned int align
                = UI_To_Int (Alignment (gnat_entity)) * BITS_PER_UNIT;