diff options
author | Christopher D. Rickett <crickett@lanl.gov> | 2007-07-12 19:52:03 +0000 |
---|---|---|
committer | Tobias Burnus <burnus@gcc.gnu.org> | 2007-07-12 21:52:03 +0200 |
commit | aa5e22f00044aff47df0997d9f5d794e91cba2dd (patch) | |
tree | ad18ce5b4ba81913b817ca8211398ca81949308b /gcc/fortran/decl.c | |
parent | 26a9718401a4987165af4451cfda69be08613640 (diff) | |
download | gcc-aa5e22f00044aff47df0997d9f5d794e91cba2dd.zip gcc-aa5e22f00044aff47df0997d9f5d794e91cba2dd.tar.gz gcc-aa5e22f00044aff47df0997d9f5d794e91cba2dd.tar.bz2 |
re PR fortran/32599 ([ISO C Binding] Accepts character with len /= 1)
2007-07-12 Christopher D. Rickett <crickett@lanl.gov>
PR fortran/32599
* decl.c (verify_c_interop_param): Require character string dummy
args to BIND(C) procedures to have length 1.
* resolve.c (resolve_fl_procedure): Modify parameter checking for
BIND(C) procedures.
PR fortran/32601
* resolve.c (gfc_iso_c_func_interface): Verify that a valid
expression is given as an argument to C_LOC and C_ASSOCIATED.
* trans-io.c (transfer_expr): Add argument for code block. Add
standards check to determine if an error message should be
reported for printing C_PTR or C_FUNPTR.
(transfer_array_component): Update arguments to transfer_expr.
(gfc_trans_transfer): Ditto.
* symbol.c (gen_cptr_param): Fix whitespace.
2007-07-12 Christopher D. Rickett <crickett@lanl.gov>
PR fortran/32599
* gfortran.dg/32599.f03: New test case.
PR fortran/32601
* gfortran.dg/32601.f03: New test case.
* gfortran.dg/32601_1.f03: Ditto.
* gfortran.dg/c_ptr_tests_9.f03: Updated dg-options.
* gfortran.dg/c_ptr_tests_10.f03: Ditto.
From-SVN: r126598
Diffstat (limited to 'gcc/fortran/decl.c')
-rw-r--r-- | gcc/fortran/decl.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c index 67e8ef7..00241b8 100644 --- a/gcc/fortran/decl.c +++ b/gcc/fortran/decl.c @@ -838,7 +838,24 @@ verify_c_interop_param (gfc_symbol *sym) sym->name, &(sym->declared_at), sym->ns->proc_name->name); } - + + /* Character strings are only C interoperable if they have a + length of 1. */ + if (sym->ts.type == BT_CHARACTER) + { + gfc_charlen *cl = sym->ts.cl; + if (!cl || !cl->length || cl->length->expr_type != EXPR_CONSTANT + || mpz_cmp_si (cl->length->value.integer, 1) != 0) + { + gfc_error ("Character argument '%s' at %L " + "must be length 1 because " + "procedure '%s' is BIND(C)", + sym->name, &sym->declared_at, + sym->ns->proc_name->name); + retval = FAILURE; + } + } + /* We have to make sure that any param to a bind(c) routine does not have the allocatable, pointer, or optional attributes, according to J3/04-007, section 5.1. */ |