From: Piotr Trojanek Date: Thu, 19 Dec 2024 23:09:15 +0000 (+0100) Subject: ada: Improve protection against wrong use from GDB X-Git-Tag: basepoints/gcc-16~2912 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0a71f5b5ca5bac57c660f563940b8baeb3552870;p=thirdparty%2Fgcc.git ada: Improve protection against wrong use from GDB 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. --- diff --git a/gcc/ada/exp_disp.adb b/gcc/ada/exp_disp.adb index f45c32356a90..6d0f2c87017a 100644 --- a/gcc/ada/exp_disp.adb +++ b/gcc/ada/exp_disp.adb @@ -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");