[Ada] Avoid crash when traversing units with -gnatd.WW debug switch
authorPiotr Trojanek <trojanek@adacore.com>
Mon, 16 Jul 2018 14:11:37 +0000 (14:11 +0000)
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>
Mon, 16 Jul 2018 14:11:37 +0000 (14:11 +0000)
The debug switch -gnatd.WW enables extra info when traversing library units
with Walk_Library_Items, which is used in the CodePeer and GNATprove. This
routine was crashing when trying to print info about a unit with configuration
pragmas (typically an .adc file). Now fixed.

No test, as the crash only happens when a GNATprove backend is manually called
with -gnatd.WW switch. Frontend is not affected.

2018-07-16  Piotr Trojanek  <trojanek@adacore.com>

gcc/ada/

* sem.adb (Walk_Library_Items): Skip units with configuration pragmas
when printing debug info.

From-SVN: r262720

gcc/ada/ChangeLog
gcc/ada/sem.adb

index 02bb4228c17c1bbeec76c58362c9cf88b8efaf19..f3c32e125ef2839f4c9888dd39da325f285db10c 100644 (file)
@@ -1,3 +1,8 @@
+2018-07-16  Piotr Trojanek  <trojanek@adacore.com>
+
+       * sem.adb (Walk_Library_Items): Skip units with configuration pragmas
+       when printing debug info.
+
 2018-07-16  Piotr Trojanek  <trojanek@adacore.com>
 
        * sem.adb (Walk_Library_Items): Reuse local constant.
index 2f2f846c2a896006dff1fca46e4e13aace5478d9..b80dfcfdef697ccfe9e0568a160f22bd834c2cc9 100644 (file)
@@ -2242,8 +2242,14 @@ package body Sem is
 
             for Unit_Num in Done'Range loop
                if not Done (Unit_Num) then
-                  Write_Unit_Info
-                    (Unit_Num, Unit (Cunit (Unit_Num)), Withs => True);
+
+                  --  Units with configuration pragmas (.ads files) have empty
+                  --  compilation-unit nodes; skip printing info about them.
+
+                  if Present (Cunit (Unit_Num)) then
+                     Write_Unit_Info
+                       (Unit_Num, Unit (Cunit (Unit_Num)), Withs => True);
+                  end if;
                end if;
             end loop;