From: Thomas Koenig Date: Fri, 11 Aug 2017 17:45:36 +0000 (+0000) Subject: re PR fortran/60355 ([F08] constraint C519 for BIND attribute not enforced) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c4fa898440e0b5eb540253e67c7ada61af0d52a2;p=gcc.git re PR fortran/60355 ([F08] constraint C519 for BIND attribute not enforced) 2017-08-11 Thomas Koenig 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 PR fortran/60355 * gfortran.dg (bind_c_usage_30): New test. From-SVN: r251054 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 50f2f044908..5c4ad74b785 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,11 @@ +2017-08-11 Thomas Koenig + + 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 * options.c (set_dec_flags): Only set legacy standards when value diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index 5caf76761ee..30928a2ac2d 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -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 - do this for something that was implicitly typed because that is handled - in gfc_set_default_type. Handle dummy arguments and procedure - definitions separately. Also, anything that is use associated is not - handled here but instead is handled in the module it is declared in. - Finally, derived type definitions are allowed to be BIND(C) since that - only implies that they're interoperable, and they are checked fully for - interoperability when a variable is declared of that type. */ - if (sym->attr.is_bind_c && sym->attr.implicit_type == 0 && - sym->attr.use_assoc == 0 && sym->attr.dummy == 0 && - sym->attr.flavor != FL_PROCEDURE && sym->attr.flavor != FL_DERIVED) + /* If the symbol is marked as bind(c), that it is declared at module level + scope and verify its type and kind. Do not do the latter for symbols + that are implicitly typed because that is handled in + gfc_set_default_type. Handle dummy arguments and procedure definitions + separately. Also, anything that is use associated is not handled here + but instead is handled in the module it is declared in. Finally, derived + type definitions are allowed to be BIND(C) since that only implies that + they're interoperable, and they are checked fully for interoperability + when a variable is declared of that type. */ + if (sym->attr.is_bind_c && sym->attr.use_assoc == 0 + && sym->attr.dummy == 0 && sym->attr.flavor != FL_PROCEDURE + && sym->attr.flavor != FL_DERIVED) { bool t = true; @@ -14421,11 +14422,11 @@ resolve_symbol (gfc_symbol *sym) "module level scope", sym->name, &(sym->declared_at)); 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); } - else + else if (sym->attr.implicit_type == 0) { /* If type() declaration, we need to verify that the components of the given type are all C interoperable, etc. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 80ee13eaaa0..71b7c626980 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-08-11 Thomas Koenig + + PR fortran/60355 + * gfortran.dg (bind_c_usage_30): New test. + 2017-08-11 Martin Liska PR tree-opt/79987 diff --git a/gcc/testsuite/gfortran.dg/bind_c_usage_30.f90 b/gcc/testsuite/gfortran.dg/bind_c_usage_30.f90 new file mode 100644 index 00000000000..932d38edd30 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/bind_c_usage_30.f90 @@ -0,0 +1,6 @@ +! { 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