From f23a14d4907f558d8f2a68298200cc4659ec0c23 Mon Sep 17 00:00:00 2001 From: tkoenig Date: Tue, 6 Jan 2009 23:03:18 +0000 Subject: [PATCH] 2009-01-06 Thomas Koenig PR fortran/38220 * interface.c (gfc_procedure_use): Don't warn about functions from ISO_C_BINDING. * symbol.c (generate_isocbinding_symbol): Mark c_loc and c_funloc as pure. 2009-01-06 Thomas Koenig PR fortran/38220 * gfortran.dg/c_loc_pure_1.f90: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@143140 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/fortran/ChangeLog | 8 ++++++++ gcc/fortran/interface.c | 7 +++++-- gcc/fortran/symbol.c | 1 + gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/c_loc_pure_1.f90 | 11 +++++++++++ 5 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/c_loc_pure_1.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index ed66a73..84b81e2 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,11 @@ +2009-01-06 Thomas Koenig + + PR fortran/38220 + * interface.c (gfc_procedure_use): Don't warn about functions + from ISO_C_BINDING. + * symbol.c (generate_isocbinding_symbol): Mark c_loc and + c_funloc as pure. + 2009-01-05 Paul Thomas PR fortran/38657 diff --git a/gcc/fortran/interface.c b/gcc/fortran/interface.c index f779dfa..d6ff240 100644 --- a/gcc/fortran/interface.c +++ b/gcc/fortran/interface.c @@ -2411,9 +2411,12 @@ void gfc_procedure_use (gfc_symbol *sym, gfc_actual_arglist **ap, locus *where) { - /* Warn about calls with an implicit interface. */ + /* Warn about calls with an implicit interface. Special case + for calling a ISO_C_BINDING becase c_loc and c_funloc + are pseudo-unknown. */ if (gfc_option.warn_implicit_interface - && sym->attr.if_source == IFSRC_UNKNOWN) + && sym->attr.if_source == IFSRC_UNKNOWN + && ! sym->attr.is_iso_c) gfc_warning ("Procedure '%s' called with an implicit interface at %L", sym->name, where); diff --git a/gcc/fortran/symbol.c b/gcc/fortran/symbol.c index b74318c..2c4ce36 100644 --- a/gcc/fortran/symbol.c +++ b/gcc/fortran/symbol.c @@ -4169,6 +4169,7 @@ generate_isocbinding_symbol (const char *mod_name, iso_c_binding_symbol s, tmp_sym->result = tmp_sym; tmp_sym->attr.external = 1; tmp_sym->attr.use_assoc = 0; + tmp_sym->attr.pure = 1; tmp_sym->attr.if_source = IFSRC_UNKNOWN; tmp_sym->attr.proc = PROC_UNKNOWN; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 62f0f78..dd39cc1 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2009-01-06 Thomas Koenig + + PR fortran/38220 + * gfortran.dg/c_loc_pure_1.f90: New test. + 2009-01-06 Mikael Morin PR fortran/38669 diff --git a/gcc/testsuite/gfortran.dg/c_loc_pure_1.f90 b/gcc/testsuite/gfortran.dg/c_loc_pure_1.f90 new file mode 100644 index 0000000..911f542 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/c_loc_pure_1.f90 @@ -0,0 +1,11 @@ +! { dg-do compile } +! { dg-options "-Wimplicit-interface" } +! PR 38220 - c_loc is pure and has an explicit interface +USE ISO_C_BINDING, ONLY: C_PTR, C_LOC +CONTAINS + PURE SUBROUTINE F(x) + INTEGER, INTENT(in), TARGET :: x + TYPE(C_PTR) :: px + px = C_LOC(x) + END SUBROUTINE +END -- 2.7.4