diff mbox

[Ada] 'Switches (others) not recognized as a valid attribute reference

Message ID 20100810134315.GA19547@adacore.com
State New
Headers show

Commit Message

Arnaud Charlet Aug. 10, 2010, 1:43 p.m. UTC
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.
diff mbox

Patch

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;