diff options
author | Thomas Koenig <tkoenig@gcc.gnu.org> | 2011-01-22 17:30:22 +0000 |
---|---|---|
committer | Thomas Koenig <tkoenig@gcc.gnu.org> | 2011-01-22 17:30:22 +0000 |
commit | 8a9adf2c8fde74d9789b01f5c35c0e652dd69a8a (patch) | |
tree | 5edf68a225dc4d911ae38f40808a27923b4b6706 /gcc/fortran/resolve.c | |
parent | 9a7c205049669b3d1cbf597c416541a89cfe2289 (diff) | |
download | gcc-8a9adf2c8fde74d9789b01f5c35c0e652dd69a8a.zip gcc-8a9adf2c8fde74d9789b01f5c35c0e652dd69a8a.tar.gz gcc-8a9adf2c8fde74d9789b01f5c35c0e652dd69a8a.tar.bz2 |
re PR fortran/38536 (ICE with C_LOC in resolve.c due to not properly going through expr->ref)
2011-01-22 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/38536
* resolve.c (gfc_iso_c_func_interface): For C_LOC,
check for array sections followed by component references
which are illegal. Also check for coindexed arguments.
2011-01-22 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/38536
* gfortran.dg/c_loc_tests_16.f90: New test.
From-SVN: r169130
Diffstat (limited to 'gcc/fortran/resolve.c')
-rw-r--r-- | gcc/fortran/resolve.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index f2e7223..9f0d675 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -2699,6 +2699,9 @@ gfc_iso_c_func_interface (gfc_symbol *sym, gfc_actual_arglist *args, } else if (sym->intmod_sym_id == ISOCBINDING_LOC) { + gfc_ref *ref; + bool seen_section; + /* Make sure we have either the target or pointer attribute. */ if (!arg_attr.target && !arg_attr.pointer) { @@ -2709,6 +2712,45 @@ gfc_iso_c_func_interface (gfc_symbol *sym, gfc_actual_arglist *args, retval = FAILURE; } + if (gfc_is_coindexed (args->expr)) + { + gfc_error_now ("Coindexed argument not permitted" + " in '%s' call at %L", name, + &(args->expr->where)); + retval = FAILURE; + } + + /* Follow references to make sure there are no array + sections. */ + seen_section = false; + + for (ref=args->expr->ref; ref; ref = ref->next) + { + if (ref->type == REF_ARRAY) + { + if (ref->u.ar.type == AR_SECTION) + seen_section = true; + + if (ref->u.ar.type != AR_ELEMENT) + { + gfc_ref *r; + for (r = ref->next; r; r=r->next) + if (r->type == REF_COMPONENT) + { + gfc_error_now ("Array section not permitted" + " in '%s' call at %L", name, + &(args->expr->where)); + retval = FAILURE; + break; + } + } + } + } + + if (seen_section && retval == SUCCESS) + gfc_warning ("Array section in '%s' call at %L", name, + &(args->expr->where)); + /* See if we have interoperable type and type param. */ if (verify_c_interop (arg_ts) == SUCCESS || gfc_check_any_c_kind (arg_ts) == SUCCESS) |