public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [COMMITTED] ada: Fix generation of JSON output for data representation
@ 2023-08-01  8:08 Marc Poulhiès
  0 siblings, 0 replies; only message in thread
From: Marc Poulhiès @ 2023-08-01  8:08 UTC (permalink / raw)
  To: gcc-patches; +Cc: Yannick Moy

From: Yannick Moy <moy@adacore.com>

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.

Tested on x86_64-pc-linux-gnu, committed on master.

---
 gcc/ada/repinfo.adb | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/gcc/ada/repinfo.adb b/gcc/ada/repinfo.adb
index 6a30bc7898b..ba4b32b7027 100644
--- a/gcc/ada/repinfo.adb
+++ b/gcc/ada/repinfo.adb
@@ -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;
-- 
2.40.0


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-08-01  8:08 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-01  8:08 [COMMITTED] ada: Fix generation of JSON output for data representation Marc Poulhiès

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).