From: Thomas Koenig Date: Tue, 6 Jan 2009 23:03:18 +0000 (+0000) Subject: re PR fortran/38220 (C_LOC intrinsic non-pure and without explicit interface) X-Git-Tag: releases/gcc-4.4.0~991 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a9c5fe7e7219e1ec949e8c1b29ec7fc2e8bfd6cb;p=thirdparty%2Fgcc.git re PR fortran/38220 (C_LOC intrinsic non-pure and without explicit interface) 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. From-SVN: r143140 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index ed66a73cc233..84b81e2111f6 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 f779dfa04de9..d6ff240caa0f 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 b74318c51f36..2c4ce3670f0a 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 62f0f7865b2e..dd39cc1a1d36 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 000000000000..911f5429d4c6 --- /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