]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[Ada] Arrange not to set DECL_ARTIFICIAL on elab procs
authorOlivier Hainque <hainque@adacore.com>
Mon, 8 Jul 2019 08:13:34 +0000 (08:13 +0000)
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>
Mon, 8 Jul 2019 08:13:34 +0000 (08:13 +0000)
Unlike, say, clones created internally by the compiler, elab procs
materialize specific user code and flagging them artificial now takes
elab code away from gcov's analysis, a regression compared to previous
releases.

On the testcase below:

package Gcov_Q is
   function F (X : Integer) return Integer is (X + 1);
end;

with Gcov_Q;
package Gcov_P is
   Y : Integer := Gcov_Q.F (X => 1);
end;

with Gcov_P;
procedure Gcov_Test is
begin
   if Gcov_P.Y /= 2 then
      raise Program_Error;
   end if;
end;

After compiling with:

  gnatmake -f -g gcov_test.adb \
    -cargs -ftest-coverage -fprofile-arcs \
    -largs -fprofile-generate

and executing with

  ./gcov_test

We expect

   gcov gcov_p

to produce a gcov_p.ads.gcov report.

2019-07-08  Olivier Hainque  <hainque@adacore.com>

gcc/ada/

* gcc-interface/trans.c (Compilation_Unit_to_gnu): Don't request
DECL_ARTIFICIAL_P on elab proc declarations.

From-SVN: r273207

gcc/ada/ChangeLog
gcc/ada/gcc-interface/trans.c

index 198db54e7a5f826f93e38ff318f5e61f9a9386e9..81ef99e4be57dc46b5ce10c34a2a81a34f9045bf 100644 (file)
@@ -1,3 +1,8 @@
+2019-07-08  Olivier Hainque  <hainque@adacore.com>
+
+       * gcc-interface/trans.c (Compilation_Unit_to_gnu): Don't request
+       DECL_ARTIFICIAL_P on elab proc declarations.
+
 2019-07-08  Eric Botcazou  <ebotcazou@adacore.com>
 
        * repinfo.adb (List_Record_Info): Declare Incomplete_Layout and
index 32dd132c3166edc0436e0a183bf95595c50b4b63..6cd37598d396240d743ca3235b201556987951a6 100644 (file)
@@ -6276,13 +6276,17 @@ Compilation_Unit_to_gnu (Node_Id gnat_node)
   Node_Id gnat_pragma;
   /* Make the decl for the elaboration procedure.  Emit debug info for it, so
      that users can break into their elaboration code in debuggers.  Kludge:
-     don't consider it as a definition so that we have a line map for its body,
-     but no subprogram description in debug info. */
+     don't consider it as a definition so that we have a line map for its
+     body, but no subprogram description in debug info.  In addition, don't
+     qualify it as artificial, even though it is not a user subprogram per se,
+     in particular for specs.  Unlike, say, clones created internally by the
+     compiler, this subprogram materializes specific user code and flagging it
+     artificial would take elab code away from gcov's analysis.  */
   tree gnu_elab_proc_decl
     = create_subprog_decl
       (create_concat_name (gnat_unit_entity, body_p ? "elabb" : "elabs"),
        NULL_TREE, void_ftype, NULL_TREE,
-       is_default, true, false, true, true, false, NULL, gnat_unit);
+       is_default, true, false, false, true, false, NULL, gnat_unit);
   struct elab_info *info;
 
   vec_safe_push (gnu_elab_proc_stack, gnu_elab_proc_decl);