===================================================================
@@ -5535,7 +5535,7 @@ match_attr_spec (void)
break;
case DECL_IS_BIND_C:
- t = gfc_add_is_bind_c(¤t_attr, NULL, &seen_at[d], 0);
+ t = gfc_add_is_bind_c (¤t_attr, NULL, &seen_at[d], 0);
break;
case DECL_VALUE:
@@ -7224,7 +7224,7 @@ gfc_match_function_decl (void)
/* Make sure that it isn't already declared as BIND(C). If it is, it
must have been marked BIND(C) with a BIND(C) attribute and that is
not allowed for procedures. */
- if (sym->attr.is_bind_c == 1)
+ if (sym->attr.is_bind_c == 1 && sym->attr.used_in_submodule == 0)
{
sym->attr.is_bind_c = 0;
if (sym->old_symbol != NULL)
@@ -7483,7 +7483,7 @@ gfc_match_entry (void)
/* Make sure that it isn't already declared as BIND(C). If it is, it
must have been marked BIND(C) with a BIND(C) attribute and that is
not allowed for procedures. */
- if (entry->attr.is_bind_c == 1)
+ if (entry->attr.is_bind_c == 1 && entry->attr.used_in_submodule == 0)
{
entry->attr.is_bind_c = 0;
if (entry->old_symbol != NULL)
@@ -7690,7 +7690,7 @@ gfc_match_subroutine (void)
/* Make sure that it isn't already declared as BIND(C). If it is, it
must have been marked BIND(C) with a BIND(C) attribute and that is
not allowed for procedures. */
- if (sym->attr.is_bind_c == 1)
+ if (sym->attr.is_bind_c == 1 && sym->attr.used_in_submodule == 0)
{
sym->attr.is_bind_c = 0;
if (sym->old_symbol != NULL)
===================================================================
@@ -1902,7 +1902,7 @@ gfc_add_is_bind_c (symbol_attribute *attr, const char
if (is_proc_lang_bind_spec == 0 && attr->flavor == FL_PROCEDURE)
gfc_error_now ("BIND(C) attribute at %L can only be used for "
"variables or common blocks", where);
- else if (attr->is_bind_c)
+ else if (attr->is_bind_c && attr->used_in_submodule == 0)
gfc_error_now ("Duplicate BIND attribute specified at %L", where);
else
attr->is_bind_c = 1;
===================================================================
@@ -0,0 +1,28 @@
+! { dg-do compile}
+! Original code submitted by Alberto Luaces <aluaces at udc dot es>
+module Foo_mod
+
+ implicit none
+
+ interface
+ module subroutine runFoo4C(ndim) bind(C, name="runFoo")
+ use, intrinsic :: iso_c_binding
+ implicit none
+ integer(c_int32_t) , intent(in) :: ndim
+ end subroutine runFoo4C
+ end interface
+
+ contains
+end module Foo_mod
+
+submodule (Foo_mod) Foo_smod
+
+contains
+
+ module subroutine runFoo4C(ndim) bind(C, name="runFoo")
+ use, intrinsic :: iso_c_binding
+ implicit none
+ integer(c_int32_t) , intent(in) :: ndim
+ end subroutine runFoo4C
+
+end submodule Foo_smod