public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/30922]  New: IMPORT fails for same symbol in multiple interface bodies of same interface block
@ 2007-02-22  9:10 burnus at gcc dot gnu dot org
  2007-03-02 16:14 ` [Bug fortran/30922] " burnus at gcc dot gnu dot org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-02-22  9:10 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug fortran/30922] IMPORT fails for same symbol in multiple interface bodies of same interface block
  2007-02-22  9:10 [Bug fortran/30922] New: IMPORT fails for same symbol in multiple interface bodies of same interface block burnus at gcc dot gnu dot org
@ 2007-03-02 16:14 ` burnus at gcc dot gnu dot org
  2007-03-02 16:16 ` burnus at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-03-02 16:14 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from burnus at gcc dot gnu dot org  2007-03-02 16:14 -------
Another thing which currently fails in gfortran (and g95) is:
------------------------------------
module x
  implicit none
  integer, parameter :: d=8
  interface
    real(d) function y()
      import
    end function
  end interface
end module x
------------------------------------

    real(d) function y()
        1
Error: Parameter 'd' at (1) has not been declared or is a variable, which does
not reduce to a constant expression


-- 

burnus at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2007-03-02 16:14:27
               date|                            |


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


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug fortran/30922] IMPORT fails for same symbol in multiple interface bodies of same interface block
  2007-02-22  9:10 [Bug fortran/30922] New: IMPORT fails for same symbol in multiple interface bodies of same interface block burnus at gcc dot gnu dot org
  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
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-03-02 16:16 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from burnus at gcc dot gnu dot org  2007-03-02 16:16 -------
(Example for the latter is: http://users.erols.com/dnagle/pub/pthread.f03,
which also needs ISO_C_BINDING)


-- 


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


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug fortran/30922] IMPORT fails for same symbol in multiple interface bodies of same interface block
  2007-02-22  9:10 [Bug fortran/30922] New: IMPORT fails for same symbol in multiple interface bodies of same interface block burnus at gcc dot gnu dot org
  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
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-03-12  8:51 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from burnus at gcc dot gnu dot org  2007-03-12 08:50 -------
Created an attachment (id=13193)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=13193&action=view)
Patch draft (by Paul Thomas)

Notes by Paul:
----------------
(i) gfc_find_symbol searches via proc_name->ns to overcome standard
problem with interfaces in enclosed procedures.
(ii) Add field imported to gfc_symtree
(iii) Set it when a symbol is imported
(iv)resolve.c 5658 to use imported to stop false error for individually
imported symbols.
----------------

Note, it does not fix the problem of comment 1 (which was found later).

It causes some regressions (filelist below) with such errors:
gfortran.fortran-torture/execute/der_io.f90:55.20:
    subroutine foo(t)
                   1
gfortran.fortran-torture/execute/der_io.f90:5.15:

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

Files:
gfortran.dg/automatic_default_init_1.f90
gfortran.dg/char_result_11.f90
gfortran.dg/char_result_5.f90
gfortran.dg/char_result_6.f90
gfortran.dg/default_initialization_2.f90
gfortran.dg/dependency_19.f90
gfortran.dg/der_charlen_1.f90
gfortran.dg/der_io_2.f90
gfortran.dg/der_io_3.f90
gfortran.dg/der_pointer_3.f90
[...]


-- 


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


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug fortran/30922] IMPORT fails for same symbol in multiple interface bodies of same interface block
  2007-02-22  9:10 [Bug fortran/30922] New: IMPORT fails for same symbol in multiple interface bodies of same interface block burnus at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  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
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: patchapp at dberlin dot org @ 2007-03-12 14:51 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from patchapp at dberlin dot org  2007-03-12 14:50 -------
Subject: Bug number PR30922

A patch for this bug has been added to the patch tracker.
The mailing list url for the patch is
http://gcc.gnu.org/ml/gcc-patches/2007-03/msg00728.html


-- 


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


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug fortran/30922] IMPORT fails for same symbol in multiple interface bodies of same interface block
  2007-02-22  9:10 [Bug fortran/30922] New: IMPORT fails for same symbol in multiple interface bodies of same interface block burnus at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  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
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pault at gcc dot gnu dot org @ 2007-03-12 15:25 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from pault at gcc dot gnu dot org  2007-03-12 15:24 -------
The testcase in comment 1 should be lifted and deposited in another PR; it is
going to be quite difficult to fix because the type and kind of an interface
function is established before the specification statements that inlude the
IMPORT statement.  This problem is related to that of implicit type definition
within interfaces that I just fixed (PR30883).

Paul 


-- 

pault at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |pault at gcc dot gnu dot org
                   |dot org                     |
             Status|NEW                         |ASSIGNED
   Last reconfirmed|2007-03-02 16:14:27         |2007-03-12 15:24:48
               date|                            |


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


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug fortran/30922] IMPORT fails for same symbol in multiple interface bodies of same interface block
  2007-02-22  9:10 [Bug fortran/30922] New: IMPORT fails for same symbol in multiple interface bodies of same interface block burnus at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  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
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: brooks at gcc dot gnu dot org @ 2007-03-14  4:37 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from brooks at gcc dot gnu dot org  2007-03-14 04:37 -------
Subject: Bug 30922

Author: brooks
Date: Wed Mar 14 04:37:15 2007
New Revision: 122904

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=122904
Log:
PR fortran/30922
PR fortran/30948
PR fortran/30953
* intrinsics.texi (CHDIR): Fix argument names, note
that STATUS must be a default integer.
(CTIME): Fix argument names, note that RESULT must
be a default integer.
(EXIT): Note that STATUS must be a default integer.

Modified:
    branches/gcc-4_2-branch/gcc/fortran/ChangeLog
    branches/gcc-4_2-branch/gcc/fortran/intrinsic.texi


-- 


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


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug fortran/30922] IMPORT fails for same symbol in multiple interface bodies of same interface block
  2007-02-22  9:10 [Bug fortran/30922] New: IMPORT fails for same symbol in multiple interface bodies of same interface block burnus at gcc dot gnu dot org
                   ` (5 preceding siblings ...)
  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
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: brooks at gcc dot gnu dot org @ 2007-03-14  4:39 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from brooks at gcc dot gnu dot org  2007-03-14 04:39 -------
Subject: Bug 30922

Author: brooks
Date: Wed Mar 14 04:38:47 2007
New Revision: 122905

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=122905
Log:
PR fortran/30922
PR fortran/30948
PR fortran/30953
* intrinsics.texi (CHDIR): Fix argument names, note
that STATUS must be a default integer.
(CTIME): Fix argument names, note that RESULT must
be a default integer.
(EXIT): Note that STATUS must be a default integer.

Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/intrinsic.texi


-- 


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


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug fortran/30922] IMPORT fails for same symbol in multiple interface bodies of same interface block
  2007-02-22  9:10 [Bug fortran/30922] New: IMPORT fails for same symbol in multiple interface bodies of same interface block burnus at gcc dot gnu dot org
                   ` (6 preceding siblings ...)
  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
  9 siblings, 0 replies; 11+ messages in thread
From: brooks at gcc dot gnu dot org @ 2007-03-14  4:48 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from brooks at gcc dot gnu dot org  2007-03-14 04:47 -------
Those last two commits should have gone to PR 30933.  Sorry.


-- 


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


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug fortran/30922] IMPORT fails for same symbol in multiple interface bodies of same interface block
  2007-02-22  9:10 [Bug fortran/30922] New: IMPORT fails for same symbol in multiple interface bodies of same interface block burnus at gcc dot gnu dot org
                   ` (7 preceding siblings ...)
  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
  9 siblings, 0 replies; 11+ messages in thread
From: pault at gcc dot gnu dot org @ 2007-03-15  6:45 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from pault at gcc dot gnu dot org  2007-03-15 06:44 -------
Subject: Bug 30922

Author: pault
Date: Thu Mar 15 06:44:25 2007
New Revision: 122944

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=122944
Log:
2007-03-15  Tobias Burnus  <burnus@gcc.gnu.org>
            Paul Thomas  <pault@gcc.gnu.org>

        PR fortran/30922
        * decl.c (gfc_match_import): If the parent of the current name-
        space is null, try looking for an imported symbol in the parent
        of the proc_name interface.
        * resolve.c (resolve_fl_variable): Do not check for blocking of
        host association by a same symbol, if the symbol is in an
        interface body.

2007-03-15  Paul Thomas  <pault@gcc.gnu.org>

        PR fortran/30879
        * decl.c (match_data_constant): Before going on to try to match
        a name, try to match a structure component.


        PR fortran/30870
        * resolve.c (resolve_actual_arglist): Do not reject a generic
        actual argument if it has a same name specific interface.

        PR fortran/31163
        * trans-array.c (parse_interface): Do not nullify allocatable
        components if the symbol has the saved attribute.


2007-03-15  Paul Thomas  <pault@gcc.gnu.org>

        PR fortran/30922
        * gfortran.dg/import5.f90.f90: New test.


        PR fortran/30879
        * gfortran.dg/data_components_1.f90: New test.


        PR fortran/30870
        * gfortran.dg/generic_13.f90: New test.

        PR fortran/31163
        * gfortran.dg/alloc_comp_basics_5.f90: New test.


Added:
    trunk/gcc/testsuite/gfortran.dg/alloc_comp_basics_5.f90
    trunk/gcc/testsuite/gfortran.dg/data_components_1.f90
    trunk/gcc/testsuite/gfortran.dg/generic_13.f90
    trunk/gcc/testsuite/gfortran.dg/import5.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/decl.c
    trunk/gcc/fortran/resolve.c
    trunk/gcc/fortran/trans-array.c
    trunk/gcc/testsuite/ChangeLog


-- 


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


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug fortran/30922] IMPORT fails for same symbol in multiple interface bodies of same interface block
  2007-02-22  9:10 [Bug fortran/30922] New: IMPORT fails for same symbol in multiple interface bodies of same interface block burnus at gcc dot gnu dot org
                   ` (8 preceding siblings ...)
  2007-03-15  6:45 ` pault at gcc dot gnu dot org
@ 2007-03-15  6:55 ` burnus at gcc dot gnu dot org
  9 siblings, 0 replies; 11+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-03-15  6:55 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #10 from burnus at gcc dot gnu dot org  2007-03-15 06:55 -------
Fixed.


-- 

burnus at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED


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


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2007-03-15  6:55 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-22  9:10 [Bug fortran/30922] New: IMPORT fails for same symbol in multiple interface bodies of same interface block burnus at gcc dot gnu dot org
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

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).