]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Fix generation of JSON output for data representation
authorYannick Moy <moy@adacore.com>
Tue, 18 Jul 2023 14:52:26 +0000 (16:52 +0200)
committerMarc Poulhiès <poulhies@adacore.com>
Tue, 1 Aug 2023 08:06:44 +0000 (10:06 +0200)
Using -gnatRj to generate data representation in JSON format could
lead to an ill-formed output or an assertion failure. Now fixed.

gcc/ada/

* repinfo.adb (List_Common_Type_Info): Fix output when alignment
is not statically known, and fix assertion when expansion is not
enabled.

gcc/ada/repinfo.adb

index 6a30bc7898b9cf473afeb2931b5076eca0702b03..ba4b32b7027ec53520b0aac602be5d494181ede7 100644 (file)
@@ -428,12 +428,21 @@ package body Repinfo is
          end if;
 
       --  Alignment is not always set for task, protected, and class-wide
-      --  types. Representation aspects are not computed for types in a
-      --  generic unit.
+      --  types, or when doing semantic analysis only. Representation aspects
+      --  are not computed for types in a generic unit.
 
       else
+         --  Add unknown alignment entry in JSON format to ensure the format is
+         --  valid, as a comma is added by the caller before another field.
+
+         if List_Representation_Info_To_JSON then
+            Write_Str ("  ""Alignment"": ");
+            Write_Unknown_Val;
+         end if;
+
          pragma Assert
-           (Is_Concurrent_Type (Ent) or else
+           (not Expander_Active or else
+              Is_Concurrent_Type (Ent) or else
               Is_Class_Wide_Type (Ent) or else
               Sem_Util.In_Generic_Scope (Ent));
       end if;