]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Compiler hangs on invalid postcondition
authorSteve Baird <baird@adacore.com>
Thu, 10 Aug 2023 23:21:34 +0000 (16:21 -0700)
committerMarc Poulhiès <poulhies@adacore.com>
Tue, 5 Sep 2023 11:05:13 +0000 (13:05 +0200)
In some cases involving an illegal reference to F'Result in
the postcondition for a function not named F, the compiler would
hang instead of correctly diagnosing the error.

gcc/ada/

* sem_attr.adb (Denote_Same_Function): Handle the case where
Has_Homonym (Pref_Id) returns True but Homonym (Pref_Id) returns
an empty result.

gcc/ada/sem_attr.adb

index e00addd0152f90cc889c90a31db4c2a286f1a5e3..d03761b1e30e3fd71b55072debc4bb3079e54709 100644 (file)
@@ -5921,7 +5921,9 @@ package body Sem_Attr is
             --  When a qualified name is used for the prefix, homonyms may come
             --  before the current function in the homonym chain.
 
-            elsif Has_Homonym (Pref_Id) then
+            elsif Has_Homonym (Pref_Id)
+              and then Present (Homonym (Pref_Id))
+            then
                return Denote_Same_Function (Homonym (Pref_Id), Spec_Id);
             end if;