]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Missing error on expression function returning incomplete type
authorJavier Miranda <miranda@adacore.com>
Tue, 4 Feb 2025 19:41:53 +0000 (19:41 +0000)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Thu, 5 Jun 2025 08:18:37 +0000 (10:18 +0200)
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.

gcc/ada/sem_ch6.adb

index 0cfcc1cb263b65330c2395cce96e517eeab67417..d4e6d1693263591c4daaafcc169a7930c4131d95 100644 (file)
@@ -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