[gcc/devel/c++-modules] [Ada] Assert failure on invalid Variable_Indexing

Nathan Sidwell nathan@gcc.gnu.org
Wed Jul 8 18:59:56 GMT 2020


https://gcc.gnu.org/g:a21df0b6a46a7807534c2096bba1642e74e1fbd3

commit a21df0b6a46a7807534c2096bba1642e74e1fbd3
Author: Arnaud Charlet <charlet@adacore.com>
Date:   Fri May 15 05:41:10 2020 -0400

    [Ada] Assert failure on invalid Variable_Indexing
    
    gcc/ada/
    
            * sem_ch4.adb (Try_Container_Indexing): Add ??? comment. Protect
            against malformed tree in case of errors.

Diff:
---
 gcc/ada/sem_ch4.adb | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/gcc/ada/sem_ch4.adb b/gcc/ada/sem_ch4.adb
index 58e8058ee02..3559a15c152 100644
--- a/gcc/ada/sem_ch4.adb
+++ b/gcc/ada/sem_ch4.adb
@@ -286,6 +286,7 @@ package body Sem_Ch4 is
       Prefix : Node_Id;
       Exprs  : List_Id) return Boolean;
    --  AI05-0139: Generalized indexing to support iterators over containers
+   --  ??? Need to provide a more detailed spec of what this function does
 
    function Try_Indexed_Call
      (N          : Node_Id;
@@ -8469,6 +8470,12 @@ package body Sem_Ch4 is
       if not Is_Overloaded (Func_Name) then
          Func := Entity (Func_Name);
 
+         --  Can happen in case of e.g. cascaded errors
+
+         if No (Func) then
+            return False;
+         end if;
+
          Indexing :=
            Make_Function_Call (Loc,
              Name                   => New_Occurrence_Of (Func, Loc),


More information about the Gcc-cvs mailing list