Commit 36dcec91 by Christopher D. Rickett Committed by Tobias Burnus

re PR fortran/33760 (Bind(C): Using C_PTR as structure constructor gives an ICE)

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-17 Christopher D. Rickett <crickett@lanl.gov>

        PR fortran/33760
        * gfortran.dg/c_ptr_tests_13.f03: New test case.

From-SVN: r129402
parent aa46c8a3
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
......
......@@ -2249,7 +2249,10 @@ check_init_expr (gfc_expr *e)
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:
......
......@@ -728,6 +728,16 @@ resolve_structure_cons (gfc_expr *expr)
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)
......
......@@ -3354,10 +3354,10 @@ gen_special_c_interop_ptr (int ptr_id, const char *ptr_name,
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
! { 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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment