2011-08-29 Arnaud Charlet <charlet@adacore.com>
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 29 Aug 2011 08:55:18 +0000 (08:55 +0000)
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 29 Aug 2011 08:55:18 +0000 (08:55 +0000)
* gnat_rm.texi: Add doc for 'Elab_Subp_Body.
* bindgen.adb: Add comments.
* snames.adb-tmpl (Is_Attribute_Name): Only recognize 'Elab_Subp_Body
in CodePeer mode.

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

gcc/ada/ChangeLog
gcc/ada/bindgen.adb
gcc/ada/gnat_rm.texi
gcc/ada/snames.adb-tmpl

index 7e04f40..a9551c7 100644 (file)
@@ -1,3 +1,10 @@
+2011-08-29  Arnaud Charlet  <charlet@adacore.com>
+
+       * gnat_rm.texi: Add doc for 'Elab_Subp_Body.
+       * bindgen.adb: Add comments.
+       * snames.adb-tmpl (Is_Attribute_Name): Only recognize 'Elab_Subp_Body
+       in CodePeer mode.
+
 2011-08-29  Robert Dewar  <dewar@adacore.com>
 
        * exp_attr.adb: Minor reformatting.
index 6e0d5bd..8d40273 100644 (file)
@@ -984,11 +984,15 @@ package body Bindgen is
 
             --  Case of no elaboration code
 
+            --  In CodePeer mode, we special case subprogram bodies which
+            --  are handled in the 'else' part below, and lead to a call to
+            --  <subp>'Elab_Subp_Body.
+
             elsif U.No_Elab
               and then (not CodePeer_Mode
-                        or else U.Utype = Is_Spec
-                        or else U.Utype = Is_Spec_Only
-                        or else U.Unit_Kind /= 's')
+                         or else U.Utype = Is_Spec
+                         or else U.Utype = Is_Spec_Only
+                         or else U.Unit_Kind /= 's')
             then
 
                --  The only case in which we have to do something is if this
@@ -1024,6 +1028,9 @@ package body Bindgen is
             --  The uname_E increment is skipped if this is a separate spec,
             --  since it will be done when we process the body.
 
+            --  In CodePeer mode, we do not generate any reference to xxx_E
+            --  variables, only calls to 'Elab* subprograms.
+
             else
                Check_Elab_Flag :=
                  not CodePeer_Mode
@@ -1059,6 +1066,10 @@ package body Bindgen is
                        "'elab_spec";
                      Name_Len := Name_Len + 8;
 
+                  --  Special case in CodePeer mode for subprogram bodies
+                  --  which correspond to CodePeer 'Elab_Subp_Body special
+                  --  init procedure.
+
                   elsif U.Unit_Kind = 's' and CodePeer_Mode then
                      Name_Buffer (Name_Len - 1 .. Name_Len + 13) :=
                        "'elab_subp_body";
index a7f13a1..803f210 100644 (file)
@@ -239,6 +239,7 @@ Implementation Defined Attributes
 * Elaborated::
 * Elab_Body::
 * Elab_Spec::
+* Elab_Subp_Body::
 * Emax::
 * Enabled::
 * Enum_Rep::
@@ -5719,6 +5720,7 @@ consideration, you should minimize the use of these attributes.
 * Elaborated::
 * Elab_Body::
 * Elab_Spec::
+* Elab_Subp_Body::
 * Emax::
 * Enabled::
 * Enum_Rep::
@@ -5966,6 +5968,17 @@ which it is useful to be able to call this elaboration procedure from
 Ada code, e.g.@: if it is necessary to do selective re-elaboration to fix
 some error.
 
+@node Elab_Subp_Body
+@unnumberedsec Elab_Subp_Body
+@findex Elab_Subp_Body
+@noindent
+This attribute can only be applied to a library level subprogram
+name and is only allowed in CodePeer mode. It returns the entity
+for the corresponding elaboration procedure for elaborating the body
+of the referenced subprogram unit. This is used in the main generated
+elaboration procedure by the binder in CodePeer mode only and is unrecognized
+otherwise.
+
 @node Emax
 @unnumberedsec Emax
 @cindex Ada 83 attributes
index defe949..92b258d 100644 (file)
@@ -306,7 +306,8 @@ package body Snames is
 
    function Is_Attribute_Name (N : Name_Id) return Boolean is
    begin
-      return N in First_Attribute_Name .. Last_Attribute_Name;
+      return N in First_Attribute_Name .. Last_Attribute_Name
+        and then (CodePeer_Mode or else N /= Name_Elab_Subp_Body);
    end Is_Attribute_Name;
 
    ----------------------------------