[Ada] Fix missing error messages when returning limited type
authorGhjuvan Lacambre <lacambre@adacore.com>
Fri, 30 Apr 2021 08:11:25 +0000 (10:11 +0200)
committerPierre-Marie de Rodat <derodat@adacore.com>
Mon, 5 Jul 2021 13:09:15 +0000 (13:09 +0000)
gcc/ada/

* sem_ch6.adb (Check_Limited_Return): Replace Comes_From_Source
with Comes_From_Extended_Return_Statement.

gcc/ada/sem_ch6.adb

index ffab332..3697aba 100644 (file)
@@ -7008,7 +7008,8 @@ package body Sem_Ch6 is
 
       elsif Is_Limited_Type (R_Type)
         and then not Is_Interface (R_Type)
-        and then Comes_From_Source (N)
+        and then not (Nkind (N) = N_Simple_Return_Statement
+                      and then Comes_From_Extended_Return_Statement (N))
         and then not In_Instance_Body
         and then not OK_For_Limited_Init_In_05 (R_Type, Expr)
       then