diff mbox series

[Ada] Fix detection of deferred constants for freezing error

Message ID 20220602090855.GA1010649@adacore.com
State New
Headers show
Series [Ada] Fix detection of deferred constants for freezing error | expand

Commit Message

Pierre-Marie de Rodat June 2, 2022, 9:08 a.m. UTC
Testing Is_Frozen is not robust enough, so instead test that the full view
has been seen and that the Has_Completion flag is set on it.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

	* freeze.adb (Check_Expression_Function.Find_Constant): Make test
	for deferred constants more robust.
diff mbox series

Patch

diff --git a/gcc/ada/freeze.adb b/gcc/ada/freeze.adb
--- a/gcc/ada/freeze.adb
+++ b/gcc/ada/freeze.adb
@@ -1458,7 +1458,8 @@  package body Freeze is
                                                          N_Object_Declaration
            and then not Is_Imported (Entity (Nod))
            and then not Has_Completion (Entity (Nod))
-           and then not Is_Frozen (Entity (Nod))
+           and then not (Present (Full_View (Entity (Nod)))
+                          and then Has_Completion (Full_View (Entity (Nod))))
          then
             Error_Msg_NE
               ("premature use of& in call or instance", N, Entity (Nod));