public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "demoonlit at panathenaia dot halfmoon.jp" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug ada/65524] New: gnatbind generates decrementing the unexisting elab-counter into finalize_library
Date: Mon, 23 Mar 2015 14:43:00 -0000	[thread overview]
Message-ID: <bug-65524-4@http.gcc.gnu.org/bugzilla/> (raw)

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65524

            Bug ID: 65524
           Summary: gnatbind generates decrementing the unexisting
                    elab-counter into finalize_library
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: ada
          Assignee: unassigned at gcc dot gnu.org
          Reporter: demoonlit at panathenaia dot halfmoon.jp

I found some cases that gnatbind generates decrementing the unexisting
elaboration counter of each package Exxx.

   E142 : Short_Integer; pragma Import (Ada, E142, "system__exn_lli_E");
   ... some Exxx are declared ...

   procedure finalize_library is
   begin
      ...
      E132 := E132 - 1; -- * E132 is not declared in above *
      ...
   end finalize_library;

A cause is a package having _finalize_spec/_finalize_body without
_elabs/_elabb.
I still have not been able to make the minimal example, but have made a patch.

In bindgen.adb, Gen_Elab_Externals refers U.Set_Elab_Entity to generate Exxx.
However, Gen_Finalize_Library does not refer it.

--- a/gcc/ada/bindgen.adb
+++ b/gcc/ada/bindgen.adb
@@ -1434,7 +1434,9 @@ package body Bindgen is
             --  has a finalizer. In that case, this is where we decrement
             --  the elaboration entity.

-            if U.Utype = Is_Body and then Uspec.Has_Finalizer then
+            if U.Utype = Is_Body and then Uspec.Has_Finalizer
+               and then Uspec.Set_Elab_Entity
+            then
                if not Lib_Final_Built then
                   Gen_Header;
                   Lib_Final_Built := True;
@@ -1548,7 +1550,9 @@ package body Bindgen is

             WBI ("      begin");

-            if U.Utype /= Is_Spec then
+            if U.Utype /= Is_Spec
+               and then Uspec.Set_Elab_Entity
+            then
                Set_String ("         E");
                Set_Unit_Number (Unum);
                Set_String (" := E");


             reply	other threads:[~2015-03-23 14:21 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-23 14:43 demoonlit at panathenaia dot halfmoon.jp [this message]
2015-03-23 15:00 ` [Bug ada/65524] " charlet at gcc dot gnu.org
2015-03-23 17:56 ` demoonlit at panathenaia dot halfmoon.jp
2015-03-24  9:49 ` charlet at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-65524-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).