From: Viljar Indus <in...@adacore.com>

Expressions within a declare expression were simply bound to
locally defined constants. However they were never marked as
referenced. This would trigger an unreferenced constant warning
if -gnatwu was used.

gcc/ada/ChangeLog:

        * sem_res.adb (Resolve_Declare_Expression): Mark used
        local variables inside a declare expression as referenced.

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

---
 gcc/ada/sem_res.adb | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb
index bbf7bb95ed8..865f967a5b9 100644
--- a/gcc/ada/sem_res.adb
+++ b/gcc/ada/sem_res.adb
@@ -7806,6 +7806,7 @@ package body Sem_Res is
          then
             Set_Entity (N, Local);
             Set_Etype (N, Etype (Local));
+            Generate_Reference (Local, N);
          end if;
 
          return OK;
-- 
2.43.0

Reply via email to