[Ada] Avoid crash on node extension

Message ID 20200707092736.GA41711@adacore.com
State New
Headers show
  • [Ada] Avoid crash on node extension
Related show

Commit Message

Pierre-Marie de Rodat July 7, 2020, 9:27 a.m.
If a Node_Id points to a node extension, rather than an actual node,
avoid crashing in the various debugging printouts, but just print an
indication that it's an extension.

Tested on x86_64-pc-linux-gnu, committed on trunk


	* treepr.adb (Print_Node): Add code to test Is_Extension.


diff --git a/gcc/ada/treepr.adb b/gcc/ada/treepr.adb
--- a/gcc/ada/treepr.adb
+++ b/gcc/ada/treepr.adb
@@ -1006,6 +1006,15 @@  package body Treepr is
       end if;
+      --  Similarly, if N points to an extension, avoid crashing
+      if Atree_Private_Part.Nodes.Table (N).Is_Extension then
+         Print_Int (Int (N));
+         Print_Str (" is an extension, not a node");
+         Print_Eol;
+         return;
+      end if;
       Prefix_Str_Char (Prefix_Str'Range)    := Prefix_Str;
       Prefix_Str_Char (Prefix_Str'Last + 1) := Prefix_Char;