public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Ada] Library-level error on aspects
@ 2015-11-12 13:25 Arnaud Charlet
  0 siblings, 0 replies; only message in thread
From: Arnaud Charlet @ 2015-11-12 13:25 UTC (permalink / raw)
  To: gcc-patches; +Cc: Bob Duff

[-- Attachment #1: Type: text/plain, Size: 603 bytes --]

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  <duff@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.


[-- Attachment #2: difs --]
[-- Type: text/plain, Size: 708 bytes --]

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);

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2015-11-12 13:25 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-12 13:25 [Ada] Library-level error on aspects Arnaud Charlet

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).