public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "burnus at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/30922]  New: IMPORT fails for same symbol in multiple interface bodies of same interface block
Date: Thu, 22 Feb 2007 09:10:00 -0000	[thread overview]
Message-ID: <bug-30922-13404@http.gcc.gnu.org/bugzilla/> (raw)

IMPORT fails, if one imports the same symbol in multiple interface bodies of
same interface block.

Found by Christopher D. Rickett,
http://gcc.gnu.org/ml/fortran/2007-02/msg00466.html

Test case:
--------------------------------------------
module test_import
  implicit none

  type :: my_type
     integer :: data
  end type my_type

  interface
     integer function func1(param)
       import :: my_type
       type(my_type) :: param
     end function func1

     integer function func2(param)
       import :: my_type
       type(my_type), value :: param
     end function func2
  end interface
end module test_import
--------------------------------------------

Error message:

     integer function func1(param)
                                1
test_import.f03:4.17:

  type :: my_type
                2
Error: The type my_type cannot be host associated at (1) because it is
blocked by an incompatible object of the same name at (2)


Simple fix:
------------------------------
Index: resolve.c
===================================================================
--- resolve.c   (revision 122189)
+++ resolve.c   (working copy)
@@ -5656,7 +5656,8 @@
   /* Check to see if a derived type is blocked from being host associated
      by the presence of another class I symbol in the same namespace.
      14.6.1.3 of the standard and the discussion on comp.lang.fortran.  */
-  if (sym->ts.type == BT_DERIVED && sym->ns != sym->ts.derived->ns)
+  if (sym->ts.type == BT_DERIVED && sym->ns != sym->ts.derived->ns
+      && sym->ns->proc_name->attr.if_source != IFSRC_IFBODY)
     {
       gfc_symbol *s;
       gfc_find_symbol (sym->ts.derived->name, sym->ns, 0, &s);
------------------------------

Currently, "IMPORT :: symbol" copies the symbol like follows (simplified code;
decl.c, gfc_match_import):
-------------------
          gfc_find_symbol (name, gfc_current_ns->parent, 1, &sym)

          st = gfc_new_symtree (&gfc_current_ns->sym_root, name);
          st->n.sym = sym;
          sym->refs++;
          sym->ns = gfc_current_ns;
-------------------

Possible implementation alternative, suggested by Paul Thomas,
http://gcc.gnu.org/ml/fortran/2007-02/msg00484.html

> alternatively, I have wondered for a long time if
> int ambiguous; in gfc_symtree is not out-of-order extravigant?
> A bit-field, like symbol_attribute might be very useful. Needless to say,
> imported could be added to ambiguous.

If we change the implementation, we could re-add
http://gcc.gnu.org/viewcvs/trunk/gcc/fortran/trans-decl.c?r1=119412&r2=119651&pathrev=119651&diff_format=h
cf. PR 27546.


-- 
           Summary: IMPORT fails for same symbol in multiple interface
                    bodies of same interface block
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Keywords: rejects-valid
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: burnus at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30922


             reply	other threads:[~2007-02-22  9:10 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-22  9:10 burnus at gcc dot gnu dot org [this message]
2007-03-02 16:14 ` [Bug fortran/30922] " burnus at gcc dot gnu dot org
2007-03-02 16:16 ` burnus at gcc dot gnu dot org
2007-03-12  8:51 ` burnus at gcc dot gnu dot org
2007-03-12 14:51 ` patchapp at dberlin dot org
2007-03-12 15:25 ` pault at gcc dot gnu dot org
2007-03-14  4:37 ` brooks at gcc dot gnu dot org
2007-03-14  4:39 ` brooks at gcc dot gnu dot org
2007-03-14  4:48 ` brooks at gcc dot gnu dot org
2007-03-15  6:45 ` pault at gcc dot gnu dot org
2007-03-15  6:55 ` burnus at gcc dot gnu dot 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-30922-13404@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).