]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Fix internal error on protected type with -gnatc -gnatR
authorEric Botcazou <ebotcazou@adacore.com>
Tue, 28 May 2024 11:03:19 +0000 (13:03 +0200)
committerMarc Poulhiès <poulhies@adacore.com>
Fri, 21 Jun 2024 08:34:23 +0000 (10:34 +0200)
It occurs when the body of a protected subprogram is processed, because the
references to the components of the type have not been properly expanded.

gcc/ada/

* gcc-interface/trans.cc (Subprogram_Body_to_gnu): Also return early
for a protected subprogram in -gnatc mode.

gcc/ada/gcc-interface/trans.cc

index 83ed17bff8422503a2fb30db98fae2a06a2977ba..3f2eadd7b2bc42e1a4d2c1ba6a53b74bcddf8c56 100644 (file)
@@ -3934,6 +3934,12 @@ Subprogram_Body_to_gnu (Node_Id gnat_node)
   if (Is_Generic_Subprogram (gnat_subprog) || Is_Eliminated (gnat_subprog))
     return;
 
+  /* Likewise if this is a protected subprogram and we are only annotating
+     types, as the required expansion of references did not take place.  */
+  if (Convention (gnat_subprog) == Convention_Protected
+      && type_annotate_only)
+    return;
+
   /* If this subprogram acts as its own spec, define it.  Otherwise, just get
      the already-elaborated tree node.  However, if this subprogram had its
      elaboration deferred, we will already have made a tree node for it.  So