Commit c4fa8984 by Thomas Koenig

re PR fortran/60355 ([F08] constraint C519 for BIND attribute not enforced)

2017-08-11  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR fortran/60355
	* resolve.c (resolve_symbol): Adjust (and reformat)
	comment.  Perform check if a BIND(C) is declared
	at module level regardless of whether it is typed
	implicitly or not.

2017-08-11  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR fortran/60355
	* gfortran.dg (bind_c_usage_30): New test.

From-SVN: r251054
parent 0a29142d
2017-08-11 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/60355
* resolve.c (resolve_symbol): Adjust (and reformat)
comment. Perform check if a BIND(C) is declared
at module level regardless of whether it is typed
implicitly or not.
2017-08-10 Fritz Reese <fritzoreese@gmail.com> 2017-08-10 Fritz Reese <fritzoreese@gmail.com>
* options.c (set_dec_flags): Only set legacy standards when value * options.c (set_dec_flags): Only set legacy standards when value
......
...@@ -14397,17 +14397,18 @@ resolve_symbol (gfc_symbol *sym) ...@@ -14397,17 +14397,18 @@ resolve_symbol (gfc_symbol *sym)
} }
} }
/* If the symbol is marked as bind(c), verify it's type and kind. Do not /* If the symbol is marked as bind(c), that it is declared at module level
do this for something that was implicitly typed because that is handled scope and verify its type and kind. Do not do the latter for symbols
in gfc_set_default_type. Handle dummy arguments and procedure that are implicitly typed because that is handled in
definitions separately. Also, anything that is use associated is not gfc_set_default_type. Handle dummy arguments and procedure definitions
handled here but instead is handled in the module it is declared in. separately. Also, anything that is use associated is not handled here
Finally, derived type definitions are allowed to be BIND(C) since that but instead is handled in the module it is declared in. Finally, derived
only implies that they're interoperable, and they are checked fully for type definitions are allowed to be BIND(C) since that only implies that
interoperability when a variable is declared of that type. */ they're interoperable, and they are checked fully for interoperability
if (sym->attr.is_bind_c && sym->attr.implicit_type == 0 && when a variable is declared of that type. */
sym->attr.use_assoc == 0 && sym->attr.dummy == 0 && if (sym->attr.is_bind_c && sym->attr.use_assoc == 0
sym->attr.flavor != FL_PROCEDURE && sym->attr.flavor != FL_DERIVED) && sym->attr.dummy == 0 && sym->attr.flavor != FL_PROCEDURE
&& sym->attr.flavor != FL_DERIVED)
{ {
bool t = true; bool t = true;
...@@ -14421,11 +14422,11 @@ resolve_symbol (gfc_symbol *sym) ...@@ -14421,11 +14422,11 @@ resolve_symbol (gfc_symbol *sym)
"module level scope", sym->name, &(sym->declared_at)); "module level scope", sym->name, &(sym->declared_at));
t = false; t = false;
} }
else if (sym->common_head != NULL) else if (sym->common_head != NULL && sym->attr.implicit_type == 0)
{ {
t = verify_com_block_vars_c_interop (sym->common_head); t = verify_com_block_vars_c_interop (sym->common_head);
} }
else else if (sym->attr.implicit_type == 0)
{ {
/* If type() declaration, we need to verify that the components /* If type() declaration, we need to verify that the components
of the given type are all C interoperable, etc. */ of the given type are all C interoperable, etc. */
......
2017-08-11 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/60355
* gfortran.dg (bind_c_usage_30): New test.
2017-08-11 Martin Liska <mliska@suse.cz> 2017-08-11 Martin Liska <mliska@suse.cz>
PR tree-opt/79987 PR tree-opt/79987
......
! { dg-do compile }
! PR 60355 - there was no error message for implicitly typed variables
! Test case contributed by Vladimir Fuka
program main
bind(c) test_BIND ! { dg-error "cannot be BIND" }
END
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment