[Ada] Spurious warning when using 'Type_Key on generic formal

Message ID 20211201102542.GA1635301@adacore.com
State Committed
Commit b940999de44208a0659d9441393fa3f62be24f28
Headers
Series [Ada] Spurious warning when using 'Type_Key on generic formal |

Commit Message

Pierre-Marie de Rodat Dec. 1, 2021, 10:25 a.m. UTC
  This patch corrects an issue in the compiler whereby spurious
compile-time warnings get raised when the attribute 'Type_Key is applied
to a generic formal type.

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

gcc/ada/

	* sem_attr.adb (Type_Key): Avoid premature use warnings when the
	prefix is a generic actual.
  

Patch

diff --git a/gcc/ada/sem_attr.adb b/gcc/ada/sem_attr.adb
--- a/gcc/ada/sem_attr.adb
+++ b/gcc/ada/sem_attr.adb
@@ -6664,6 +6664,7 @@  package body Sem_Attr is
 
          if not Is_Frozen (Entity (P))
            and then not Is_Generic_Type (Entity (P))
+           and then not Is_Generic_Actual_Type (Entity (P))
          then
             Error_Msg_N ("premature usage of Type_Key?", N);
          end if;