This patch fixes an issue whereby the compiler incorrectly marked use clauses
as effective due to code generated for verification referencing certain types
leading to missing use clause warnings.

No reasonably small testcase available.

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

2018-05-24  Justin Squirek  <squi...@adacore.com>

gcc/ada/

        * sem_res.adb (Resolve_Entity_Name): Add guard to protect against
        marking use clauses as effective when the reference appears within
        generated code.
--- gcc/ada/sem_res.adb
+++ gcc/ada/sem_res.adb
@@ -7293,7 +7293,13 @@ package body Sem_Res is
          end if;
       end if;
 
-      Mark_Use_Clauses (E);
+      --  We may be resolving an entity within expanded code, so a reference
+      --  to an entity should be ignored when calculating effective use clauses
+      --  to avoid inappropriate marking.
+
+      if Comes_From_Source (N) then
+         Mark_Use_Clauses (E);
+      end if;
    end Resolve_Entity_Name;
 
    -------------------

Reply via email to