public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Ada] 'Switches (others) not recognized as a valid attribute reference
@ 2010-08-10 13:48 Arnaud Charlet
  0 siblings, 0 replies; only message in thread
From: Arnaud Charlet @ 2010-08-10 13:48 UTC (permalink / raw)
  To: gcc-patches; +Cc: Vincent Celier

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

For associative array attributes where 'others' is allowed as the index
(such as Builder'Switches), an attribute reference with 'others' was not
recognized. This patch corrects this.

The test for this is to build the project prj.gpr below:

project Shared is
   for Source_Files use ();
   package Builder is
      for Switches (others) use ("-q");
   end Builder;
end Shared;

with "shared.gpr";
project Prj is
   for Main use ("main.adb");
   package Builder is
      for Switches (others) use Shared.Builder'Switches (others);
   end Builder;
end Prj;

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

2010-08-10  Vincent Celier  <celier@adacore.com>

	* prj-proc.adb (Get_Attribute_Index): If Index is All_Other_Names,
	returns Index.
	* prj-strt.adb (Attribute_Reference): Recognize 'others' as a valid
	index for an associative array where it is allowed.


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

Index: prj-proc.adb
===================================================================
--- prj-proc.adb	(revision 163054)
+++ prj-proc.adb	(working copy)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---          Copyright (C) 2001-2009, Free Software Foundation, Inc.         --
+--          Copyright (C) 2001-2010, Free Software Foundation, Inc.         --
 --                                                                          --
 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -460,6 +460,10 @@ package body Prj.Proc is
       Lower : Boolean;
 
    begin
+      if Index = All_Other_Names then
+         return Index;
+      end if;
+
       Get_Name_String (Index);
       Lower := Case_Insensitive (Attr, Tree);
 
Index: prj-strt.adb
===================================================================
--- prj-strt.adb	(revision 163054)
+++ prj-strt.adb	(working copy)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---          Copyright (C) 2001-2009, Free Software Foundation, Inc.         --
+--          Copyright (C) 2001-2010, Free Software Foundation, Inc.         --
 --                                                                          --
 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -230,19 +230,35 @@ package body Prj.Strt is
 
                if Token = Tok_Left_Paren then
                   Scan (In_Tree);
-                  Expect (Tok_String_Literal, "literal string");
 
-                  if Token = Tok_String_Literal then
+                  if Others_Allowed_For (Current_Attribute)
+                    and then Token = Tok_Others
+                  then
                      Set_Associative_Array_Index_Of
-                       (Reference, In_Tree, To => Token_Name);
+                       (Reference, In_Tree, To => All_Other_Names);
                      Scan (In_Tree);
-                     Expect (Tok_Right_Paren, "`)`");
 
-                     if Token = Tok_Right_Paren then
+                  else
+                     if Others_Allowed_For (Current_Attribute) then
+                        Expect
+                          (Tok_String_Literal, "literal string or others");
+                     else
+                        Expect (Tok_String_Literal, "literal string");
+                     end if;
+
+                     if Token = Tok_String_Literal then
+                        Set_Associative_Array_Index_Of
+                          (Reference, In_Tree, To => Token_Name);
                         Scan (In_Tree);
                      end if;
                   end if;
                end if;
+
+               Expect (Tok_Right_Paren, "`)`");
+
+               if Token = Tok_Right_Paren then
+                  Scan (In_Tree);
+               end if;
             end if;
          end if;
 

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

only message in thread, other threads:[~2010-08-10 13:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-10 13:48 [Ada] 'Switches (others) not recognized as a valid attribute reference 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).