PR fortran/33760
* symbol.c (gen_special_c_interop_ptr): Remove code to create
constructor for c_null_ptr and c_null_funptr with value of 0.
* expr.c (check_init_expr): Prevent check on constructors for
iso_c_binding derived types.
* resolve.c (resolve_structure_cons): Verify that the user isn't
trying to invoke a structure constructor for one of the
iso_c_binding derived types.
2007-10-17 Christopher D. Rickett <crickett@lanl.gov>
PR fortran/33760
* gfortran.dg/c_ptr_tests_13.f03: New test case.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@129402
138bc75d-0d04-0410-961f-
82ee72b054a4
+2007-10-17 Christopher D. Rickett <crickett@lanl.gov>
+
+ PR fortran/33760
+ * symbol.c (gen_special_c_interop_ptr): Remove code to create
+ constructor for c_null_ptr and c_null_funptr with value of 0.
+ * expr.c (check_init_expr): Prevent check on constructors for
+ iso_c_binding derived types.
+ * resolve.c (resolve_structure_cons): Verify that the user isn't
+ trying to invoke a structure constructor for one of the
+ iso_c_binding derived types.
+
2007-10-15 Christopher D. Rickett <crickett@lanl.gov>
PR fortran/32600
break;
case EXPR_STRUCTURE:
- t = gfc_check_constructor (e, check_init_expr);
+ if (e->ts.is_iso_c)
+ t = SUCCESS;
+ else
+ t = gfc_check_constructor (e, check_init_expr);
break;
case EXPR_ARRAY:
else
comp = expr->ts.derived->components;
+ /* See if the user is trying to invoke a structure constructor for one of
+ the iso_c_binding derived types. */
+ if (expr->ts.derived && expr->ts.derived->ts.is_iso_c && cons
+ && cons->expr != NULL)
+ {
+ gfc_error ("Components of structure constructor '%s' at %L are PRIVATE",
+ expr->ts.derived->name, &(expr->where));
+ return FAILURE;
+ }
+
for (; comp; comp = comp->next, cons = cons->next)
{
if (!cons->expr)
tmp_sym->value->expr_type = EXPR_STRUCTURE;
tmp_sym->value->ts.type = BT_DERIVED;
tmp_sym->value->ts.derived = tmp_sym->ts.derived;
+ /* Create a constructor with no expr, that way we can recognize if the user
+ tries to call the structure constructor for one of the iso_c_binding
+ derived types during resolution (resolve_structure_cons). */
tmp_sym->value->value.constructor = gfc_get_constructor ();
- /* This line will initialize the c_null_ptr/c_null_funptr
- c_address field to NULL. */
- tmp_sym->value->value.constructor->expr = gfc_int_expr (0);
/* Must declare c_null_ptr and c_null_funptr as having the
PARAMETER attribute so they can be used in init expressions. */
tmp_sym->attr.flavor = FL_PARAMETER;
+2007-10-17 Christopher D. Rickett <crickett@lanl.gov>
+
+ PR fortran/33760
+ * gfortran.dg/c_ptr_tests_13.f03: New test case.
+
2007-10-16 Paolo Carlini <pcarlini@suse.de>
PR c++/28639
--- /dev/null
+! { dg-do compile }
+! Ensure that the user cannot call the structure constructor for one of
+! the iso_c_binding derived types.
+!
+! PR fortran/33760
+!
+program main
+ use ISO_C_BINDING
+ implicit none
+ integer(C_INTPTR_T) p
+ type(C_PTR) cptr
+ p = 0
+ cptr = C_PTR(p+1) ! { dg-error "Components of structure constructor" }
+ cptr = C_PTR(1) ! { dg-error "Components of structure constructor" }
+end program main