2012-06-12 Robert Dewar <dewar@adacore.com>
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 12 Jun 2012 10:14:44 +0000 (10:14 +0000)
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 12 Jun 2012 10:14:44 +0000 (10:14 +0000)
* xref_lib.adb, sem_ch13.adb, lib-xref.adb: Minor reformatting.

2012-06-12  Javier Miranda  <miranda@adacore.com>

* lib-xref.ads Adding missing documentation.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@188439 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ada/ChangeLog
gcc/ada/lib-xref.adb
gcc/ada/lib-xref.ads
gcc/ada/sem_ch13.adb
gcc/ada/xref_lib.adb

index 8ffc81c..42f3653 100644 (file)
@@ -1,3 +1,11 @@
+2012-06-12  Robert Dewar  <dewar@adacore.com>
+
+       * xref_lib.adb, sem_ch13.adb, lib-xref.adb: Minor reformatting.
+
+2012-06-12  Javier Miranda  <miranda@adacore.com>
+
+       * lib-xref.ads Adding missing documentation.
+
 2012-06-12  Hristian Kirtchev  <kirtchev@adacore.com>
 
        * exp_ch7.adb (Create_Finalizer): Add the
index 6927529..bbf1a3d 100644 (file)
@@ -2443,7 +2443,7 @@ package body Lib.Xref is
 
                      if Is_Overloadable (XE.Key.Ent) then
                         if (Is_Imported (XE.Key.Ent) and then XE.Key.Typ = 'b')
-                          or else
+                             or else
                            (Is_Exported (XE.Key.Ent) and then XE.Key.Typ = 'i')
                         then
                            Output_Import_Export_Info (XE.Key.Ent);
index 7bdc158..c0fd316 100644 (file)
@@ -565,22 +565,35 @@ package Lib.Xref is
    --    y     abstract function               entry or entry family
    --    z     generic formal parameter        (unused)
 
-   --------------------------------------
-   -- Handling of Imported Subprograms --
-   --------------------------------------
+   ---------------------------------------------------
+   -- Handling of Imported and Exported Subprograms --
+   ---------------------------------------------------
 
    --  If a pragma Import or Interface applies to a subprogram, the pragma is
    --  the completion of the subprogram. This is noted in the ALI file by
    --  making the occurrence of the subprogram in the pragma into a body
    --  reference ('b') and by including the external name of the subprogram and
    --  its language, bracketed by '<' and '>' in that reference. For example:
-   --
-   --     3U13*elsewhere 4b<c,there>21
-   --
-   --  indicates that procedure elsewhere, declared at line 3, has a pragma
+
+   --     3U13*imported_proc 4b<c,there>21
+
+   --  indicates that procedure imported_proc, declared at line 3, has a pragma
    --  Import at line 4, that its body is in C, and that the link name as given
    --  in the pragma is "there".
 
+   --  If a pragma Export applies to a subprogram exported to a foreign
+   --  language (ie. the pragma has convention different from Ada), then the
+   --  pragma is annotated in the ALI file by making the occurrence of the
+   --  subprogram in the pragma into an implicit reference ('i') and by
+   --  including the external name of the subprogram and its language,
+   --  bracketed by '<' and '>' in that reference. For example:
+
+   --     3U13*exported_proc 4i<c,here>21
+
+   --  indicates that procedure exported_proc, declared at line 3, has a pragma
+   --  Export at line 4, that its body is exported to C, and that the link name
+   --  as given in the pragma is "here".
+
    ----------------------
    -- Alfa Information --
    ----------------------
index 1d8e268..9acce0f 100644 (file)
@@ -950,14 +950,11 @@ package body Sem_Ch13 is
 
                      goto Continue;
 
-                  elsif A_Id = Aspect_Import
-                    or else A_Id = Aspect_Export
-                  then
-
-                     --  Verify that there is an aspect Convention that will
-                     --  incorporate the Import/Export aspect, and eventual
-                     --  Link/External names.
+                  --  For Import/Export, Verify that there is an aspect
+                  --  Convention that will incorporate the Import/Export
+                  --  aspect, and eventual Link/External names.
 
+                  elsif A_Id = Aspect_Import or else A_Id = Aspect_Export then
                      declare
                         A : Node_Id;
 
@@ -1218,36 +1215,56 @@ package body Sem_Ch13 is
                      L_Assoc  := Empty;
                      E_Assoc  := Empty;
 
+                     --  Loop to look for Import/Export/Link_Name/External_Name
+
                      A := First (L);
                      while Present (A) loop
                         A_Name := Chars (Identifier (A));
 
+                        --  Import/Export
+
                         if A_Name = Name_Import
-                          or else A_Name = Name_Export
+                             or else
+                           A_Name = Name_Export
                         then
+                           --  Forbid duplicates, at most one can appear
+
                            if Found then
-                              Error_Msg_N ("conflicting", A);
+                              Error_Msg_Name_1 := A_Name;
+                              Error_Msg_Name_2 := P_Name;
+                              Error_Msg_N
+                                ("% aspect conflicts with previous % aspect",
+                                 A);
                            else
                               Found := True;
                            end if;
 
+                           --  Record name of pragma to generate
+
                            P_Name := A_Name;
 
+                        --  Capture Link_Name
+
                         elsif A_Name = Name_Link_Name then
                            L_Assoc := Make_Pragma_Argument_Association (Loc,
-                              Chars => A_Name,
+                              Chars      => A_Name,
                               Expression => Relocate_Node (Expression (A)));
 
+                        --  Capture External_Name
+
                         elsif A_Name = Name_External_Name then
                            E_Assoc := Make_Pragma_Argument_Association (Loc,
-                              Chars => A_Name,
+                              Chars      => A_Name,
                               Expression => Relocate_Node (Expression (A)));
                         end if;
 
                         Next (A);
                      end loop;
 
+                     --  Construct pragma
+
                      Arg_List := New_List (Relocate_Node (Expr), Ent);
+
                      if Present (L_Assoc) then
                         Append_To (Arg_List, L_Assoc);
                      end if;
index 4ff1cdc..30180af 100644 (file)
@@ -1103,8 +1103,8 @@ package body Xref_Lib is
                Ptr := Ptr + 1;
             end if;
 
-            --  Imported entities might special indication as to their external
-            --  name:
+            --  Imported entities may have an indication specifying information
+            --  about the corresponding external name:
             --    5U14*Foo2 5>20 6b<c,myfoo2>22   # Imported entity
             --    5U14*Foo2 5>20 6i<c,myfoo2>22   # Exported entity