This patch fixes a bug where GNAT fails to detect an error on an aspect that must be applied to a library-level entity.
The following test must give an error: tls.adb:2:26: entity for aspect "Thread_Local_Storage" must be library level entity procedure Tls is V : Natural := 0 with Thread_Local_Storage; begin null; end Tls; Tested on x86_64-pc-linux-gnu, committed on trunk 2015-11-12 Bob Duff <d...@adacore.com> * sem_prag.adb (Check_Arg_Is_Library_Level_Local_Name): A pragma that comes from an aspect does not "come from source", so we need to test whether it comes from an aspect.
Index: sem_prag.adb =================================================================== --- sem_prag.adb (revision 230242) +++ sem_prag.adb (working copy) @@ -4328,8 +4328,12 @@ begin Check_Arg_Is_Local_Name (Arg); + -- If it came from an aspect, we want to give the error just as if it + -- came from source. + if not Is_Library_Level_Entity (Entity (Get_Pragma_Arg (Arg))) - and then Comes_From_Source (N) + and then (Comes_From_Source (N) + or else Present (Corresponding_Aspect (Parent (Arg)))) then Error_Pragma_Arg ("argument for pragma% must be library level entity", Arg);