aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran
diff options
context:
space:
mode:
authorChristopher D. Rickett <crickett@lanl.gov>2007-07-21 23:45:44 +0000
committerSteven G. Kargl <kargl@gcc.gnu.org>2007-07-21 23:45:44 +0000
commit6ad5cf725fa39fbc8569e99af088441bfb92f0db (patch)
treea0c66745a59e2ad6d40022ec11f867e11ccaa8fb /gcc/fortran
parent8e4c6d8802234d9b885d1f3286b5363484bee1f5 (diff)
downloadgcc-6ad5cf725fa39fbc8569e99af088441bfb92f0db.zip
gcc-6ad5cf725fa39fbc8569e99af088441bfb92f0db.tar.gz
gcc-6ad5cf725fa39fbc8569e99af088441bfb92f0db.tar.bz2
re PR fortran/32627 ([ISO Bind C] Accept c_f_pointer for TYPE)
2007-07-21 Christopher D. Rickett <crickett@lanl.gov> PR fortran/32627 * resolve.c (set_name_and_label): Set kind number for character version of c_f_pointer. (gfc_iso_c_sub_interface): Set the kind of the SHAPE formal arg to that of the actual SHAPE arg. * symbol.c (gen_shape_param): Initialize kind for SHAPE arg. 2007-07-21 Christopher D. Rickett <crickett@lanl.gov> PR fortran/32627 * libgfortran/intrinsics/iso_c_generated_procs.c: Add c_f_pointer for character/string arguments. * libgfortran/intrinsic/iso_c_binding.c (c_f_pointer_u0): Allow the optional SHAPE arg to be any valid integer kind. * libgfortran/gfortran.map: Add c_f_pointer_s0. * libgfortran/mk-kinds-h.sh: Save smallest integer kind as default character kind. * libgfortran/intrinsics/iso_c_generated_procs.c: Add versions of c_f_pointer for complex and logical types. * libgfortran/gfortran.map: Add c_f_pointer versions for logical and complex types. 2007-07-21 Christopher D. Rickett <crickett@lanl.gov> PR fortran/32627 * gfortran.dg/pr32627_driver.c: Driver for pr32627. * gfortran.dg/pr32627.f03: New test case. * gfortran.dg/c_f_pointer_logical.f03: New test case. * gfortran.dg/c_f_pointer_logical_driver.c: Driver for c_f_pointer_logical. * gfortran.dg/c_f_pointer_complex_driver.c: Driver for c_f_pointer_complex. * gfortran.dg/c_f_pointer_complex.f03: New test case. * gfortran.dg/c_f_pointer_shape_tests_2_driver.c: Driver for c_f_pointer_shape_tests_2. * gfortran.dg/c_f_pointer_shape_tests_2.f03: New test case. From-SVN: r126817
Diffstat (limited to 'gcc/fortran')
-rw-r--r--gcc/fortran/ChangeLog9
-rw-r--r--gcc/fortran/resolve.c12
-rw-r--r--gcc/fortran/symbol.c3
3 files changed, 24 insertions, 0 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 87e5c6a..2e627da 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,5 +1,14 @@
2007-07-21 Christopher D. Rickett <crickett@lanl.gov>
+ PR fortran/32627
+ * resolve.c (set_name_and_label): Set kind number for character
+ version of c_f_pointer.
+ (gfc_iso_c_sub_interface): Set the kind of the SHAPE formal arg to
+ that of the actual SHAPE arg.
+ * symbol.c (gen_shape_param): Initialize kind for SHAPE arg.
+
+2007-07-21 Christopher D. Rickett <crickett@lanl.gov>
+
PR fortran/32801
* symbol.c (generate_isocbinding_symbol): Remove unnecessary
conditional.
diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index f50da8c..45a49e2 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -2282,6 +2282,11 @@ set_name_and_label (gfc_code *c, gfc_symbol *sym,
type = gfc_type_letter (arg->ts.type);
kind = arg->ts.kind;
}
+
+ if (arg->ts.type == BT_CHARACTER)
+ /* Kind info for character strings not needed. */
+ kind = 0;
+
sprintf (name, "%s_%c%d", sym->name, type, kind);
/* Set up the binding label as the given symbol's label plus
the type and kind. */
@@ -2356,6 +2361,13 @@ gfc_iso_c_sub_interface (gfc_code *c, gfc_symbol *sym)
/* the 1 means to add the optional arg to formal list */
new_sym = get_iso_c_sym (sym, name, binding_label, 1);
+ /* Set the kind for the SHAPE array to that of the actual
+ (if given). */
+ if (c->ext.actual != NULL && c->ext.actual->next != NULL
+ && c->ext.actual->next->expr->rank != 0)
+ new_sym->formal->next->next->sym->ts.kind =
+ c->ext.actual->next->next->expr->ts.kind;
+
/* for error reporting, say it's declared where the original was */
new_sym->declared_at = sym->declared_at;
}
diff --git a/gcc/fortran/symbol.c b/gcc/fortran/symbol.c
index f8ca9b3..474de8e 100644
--- a/gcc/fortran/symbol.c
+++ b/gcc/fortran/symbol.c
@@ -3421,6 +3421,9 @@ gen_shape_param (gfc_formal_arglist **head,
/* Integer array, rank 1, describing the shape of the object. */
param_sym->ts.type = BT_INTEGER;
+ /* Initialize the kind to default integer. However, it will be overriden
+ during resolution to match the kind of the SHAPE parameter given as
+ the actual argument (to allow for any valid integer kind). */
param_sym->ts.kind = gfc_default_integer_kind;
param_sym->as = gfc_get_array_spec ();