From: Javier Miranda <mira...@adacore.com>

When the type of the expression of an expression function is
an incomplete type, the frontend does not report the expected
error.

gcc/ada/ChangeLog:

        * sem_ch6.adb (Analyze_Expression_Function): Add missing check
        on premature use of incomplete type.

Tested on x86_64-pc-linux-gnu, committed on master.

---
 gcc/ada/sem_ch6.adb | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/gcc/ada/sem_ch6.adb b/gcc/ada/sem_ch6.adb
index 0cfcc1cb263..d4e6d169326 100644
--- a/gcc/ada/sem_ch6.adb
+++ b/gcc/ada/sem_ch6.adb
@@ -591,6 +591,11 @@ package body Sem_Ch6 is
             End_Scope;
          end if;
 
+         if Is_Incomplete_Type (Typ) then
+            Error_Msg_NE
+              ("premature usage of incomplete}", Expr, First_Subtype (Typ));
+         end if;
+
          --  In the case of an expression function marked with the aspect
          --  Static, we need to check the requirement that the function's
          --  expression is a potentially static expression. This is done
-- 
2.43.0

Reply via email to