Bug 32797 - [ISO C Binding] Internal Error: gfc_basic_typename(): Undefined type
Summary: [ISO C Binding] Internal Error: gfc_basic_typename(): Undefined type
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.3.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks: ISO_C_Binding
  Show dependency treegraph
 
Reported: 2007-07-17 18:08 UTC by Tobias Burnus
Modified: 2007-07-23 17:51 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tobias Burnus 2007-07-17 18:08:53 UTC
The following - valid? - program produces an ICE in gfortran.

Full program: http://atom.princeton.edu/donev/Fortran/DLL/dlfcn.f90
(Should be checked after the problem in the snippet below has been fixed.)


END MODULE ISO_C_UTILITIES
                         1
Internal Error at (1):
gfc_basic_typename(): Undefined type

(This snippet compiles with g95 and NAG f95, however, the generated C code of NAG f95 does not compile with gcc ["In function 'iso_c_utilities_MP_c_f_string': conflicting types for 'strlen'"].)


MODULE ISO_C_UTILITIES
   USE ISO_C_BINDING
   implicit none
   CHARACTER(C_CHAR), DIMENSION(1), SAVE, TARGET, PRIVATE :: dummy_string="?"
CONTAINS
   FUNCTION C_F_STRING(CPTR) RESULT(FPTR)
      TYPE(C_PTR), INTENT(IN) :: CPTR ! The C address
      CHARACTER(KIND=C_CHAR), DIMENSION(:), POINTER :: FPTR
      INTERFACE
         FUNCTION strlen(string) RESULT(len) BIND(C,NAME="strlen")
            USE ISO_C_BINDING
            TYPE(C_PTR), VALUE :: string ! A C pointer
         END FUNCTION
      END INTERFACE
      CALL C_F_POINTER(FPTR=FPTR, CPTR=CPTR, SHAPE=[strlen(CPTR)])
   END FUNCTION
END MODULE ISO_C_UTILITIES
Comment 1 Tobias Burnus 2007-07-23 09:32:24 UTC
Patch:
http://gcc.gnu.org/ml/gcc-patches/2007-07/msg01543.html

Cf. also PR 32800.
Comment 2 Tobias Burnus 2007-07-23 17:47:29 UTC
Subject: Bug 32797

Author: burnus
Date: Mon Jul 23 17:47:16 2007
New Revision: 126856

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=126856
Log:
2007-07-23  Christopher D. Rickett  <crickett@lanl.gov>

        PR fortran/32797
        PR fortran/32800
        * decl.c (verify_bind_c_sym): Use the result symbol for functions
        with a result clause.  Warn if implicitly typed.  Verify the type
        and rank of the SHAPE argument, if given.
        * resolve.c (gfc_iso_c_sub_interface): Use gfc_procedure_use to
        check the actual args against the formal, sorting them if
        necessary.
        * symbol.c (gen_shape_param): Initialize type of SHAPE param to
        BT_VOID.

2007-07-23  Christopher D. Rickett  <crickett@lanl.gov>

        PR fortran/32797
        PR fortran/32800
        * gfortran.dg/bind_c_usage_8.f03: New test case.
        * gfortran.dg/c_f_pointer_tests_2.f03: Ditto.
        * gfortran.dg/c_ptr_tests_5.f03: Updated expected error message.


Added:
    trunk/gcc/testsuite/gfortran.dg/bind_c_usage_8.f03
    trunk/gcc/testsuite/gfortran.dg/c_f_pointer_tests_2.f03
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/decl.c
    trunk/gcc/fortran/resolve.c
    trunk/gcc/fortran/symbol.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gfortran.dg/c_ptr_tests_5.f03

Comment 3 Tobias Burnus 2007-07-23 17:51:56 UTC
FIXED.