]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Improve protection against wrong use from GDB
authorPiotr Trojanek <trojanek@adacore.com>
Thu, 19 Dec 2024 23:09:15 +0000 (00:09 +0100)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Tue, 7 Jan 2025 12:33:35 +0000 (13:33 +0100)
A code cleanup in routine intended to be used from DGB, suggested by running
GNATcheck rule Boolean_Negations. However, this code can be tuned to protect
against more illegal uses.

gcc/ada/ChangeLog:

* exp_disp.adb (Write_DT): Add guards that prevent crashes on illegal
node numbers.

gcc/ada/exp_disp.adb

index f45c32356a9057d1653f8712ff483ee251527d1d..6d0f2c87017a28e2b494d6408bcf73b041baa755 100644 (file)
@@ -8674,9 +8674,10 @@ package body Exp_Disp is
 
    begin
       --  Protect this procedure against wrong usage. Required because it will
-      --  be used directly from GDB
+      --  be used directly from GDB.
 
-      if not (Typ <= Last_Node_Id)
+      if Typ not in First_Node_Id .. Last_Node_Id
+        or else Nkind (Typ) not in N_Entity
         or else not Is_Tagged_Type (Typ)
       then
          Write_Str ("wrong usage: Write_DT must be used with tagged types");