re PR fortran/20858 (NULL doesn't get its argument type (kind))
2006-02-05 Steven G. Kargl <kargls@comcast.net> PR fortran/20858 *decl.c (variable_decl): Improve error message. Remove initialization typespec. Wrap long line. *expr.c (gfc_check_pointer_assign): Permit checking of type, kind type, and rank. *simplify.c (gfc_simplify_null): Ensure type, kind type, and rank are set. gfortran.dg/null_1.f90: New test. From-SVN: r110845
This commit is contained in:
parent
6f4d3d8656
commit
def6613406
|
@ -1,3 +1,14 @@
|
|||
2006-02-10 Steven G. Kargl <kargls@comcast.net>
|
||||
|
||||
PR fortran/20858
|
||||
*decl.c (variable_decl): Improve error message. Remove initialization
|
||||
typespec. Wrap long line.
|
||||
*expr.c (gfc_check_pointer_assign): Permit checking of type, kind type,
|
||||
and rank.
|
||||
*simplify.c (gfc_simplify_null): Ensure type, kind type, and rank
|
||||
are set.
|
||||
|
||||
|
||||
2006-02-10 Tobias Schl<68>üter <tobias.schlueter@physik.uni-muenchen.de>
|
||||
|
||||
PR fortran/14771
|
||||
|
|
|
@ -1203,7 +1203,7 @@ variable_decl (int elem)
|
|||
m = gfc_match_null (&initializer);
|
||||
if (m == MATCH_NO)
|
||||
{
|
||||
gfc_error ("Pointer initialization requires a NULL at %C");
|
||||
gfc_error ("Pointer initialization requires a NULL() at %C");
|
||||
m = MATCH_ERROR;
|
||||
}
|
||||
|
||||
|
@ -1218,8 +1218,6 @@ variable_decl (int elem)
|
|||
if (m != MATCH_YES)
|
||||
goto cleanup;
|
||||
|
||||
initializer->ts = current_ts;
|
||||
|
||||
}
|
||||
else if (gfc_match_char ('=') == MATCH_YES)
|
||||
{
|
||||
|
@ -1282,7 +1280,8 @@ variable_decl (int elem)
|
|||
t = add_init_expr_to_sym (name, &initializer, &var_locus);
|
||||
else
|
||||
{
|
||||
if (current_ts.type == BT_DERIVED && !current_attr.pointer && !initializer)
|
||||
if (current_ts.type == BT_DERIVED && !current_attr.pointer
|
||||
&& !initializer)
|
||||
initializer = gfc_default_initializer (¤t_ts);
|
||||
t = build_struct (name, cl, &initializer, &as);
|
||||
}
|
||||
|
|
|
@ -1984,7 +1984,7 @@ gfc_check_pointer_assign (gfc_expr * lvalue, gfc_expr * rvalue)
|
|||
/* If rvalue is a NULL() or NULLIFY, we're done. Otherwise the type,
|
||||
kind, etc for lvalue and rvalue must match, and rvalue must be a
|
||||
pure variable if we're in a pure function. */
|
||||
if (rvalue->expr_type == EXPR_NULL)
|
||||
if (rvalue->expr_type == EXPR_NULL && rvalue->ts.type == BT_UNKNOWN)
|
||||
return SUCCESS;
|
||||
|
||||
if (!gfc_compare_types (&lvalue->ts, &rvalue->ts))
|
||||
|
@ -2001,6 +2001,17 @@ gfc_check_pointer_assign (gfc_expr * lvalue, gfc_expr * rvalue)
|
|||
return FAILURE;
|
||||
}
|
||||
|
||||
if (lvalue->rank != rvalue->rank)
|
||||
{
|
||||
gfc_error ("Different ranks in pointer assignment at %L",
|
||||
&lvalue->where);
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
/* Now punt if we are dealing with a NULLIFY(X) or X = NULL(X). */
|
||||
if (rvalue->expr_type == EXPR_NULL)
|
||||
return SUCCESS;
|
||||
|
||||
if (lvalue->ts.type == BT_CHARACTER
|
||||
&& lvalue->ts.cl->length && rvalue->ts.cl->length
|
||||
&& abs (gfc_dep_compare_expr (lvalue->ts.cl->length,
|
||||
|
@ -2025,13 +2036,6 @@ gfc_check_pointer_assign (gfc_expr * lvalue, gfc_expr * rvalue)
|
|||
"procedure at %L", &rvalue->where);
|
||||
}
|
||||
|
||||
if (lvalue->rank != rvalue->rank)
|
||||
{
|
||||
gfc_error ("Unequal ranks %d and %d in pointer assignment at %L",
|
||||
lvalue->rank, rvalue->rank, &rvalue->where);
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
if (gfc_has_vector_index (rvalue))
|
||||
{
|
||||
gfc_error ("Pointer assignment with vector subscript "
|
||||
|
|
|
@ -2528,16 +2528,14 @@ gfc_simplify_null (gfc_expr * mold)
|
|||
{
|
||||
gfc_expr *result;
|
||||
|
||||
result = gfc_get_expr ();
|
||||
result->expr_type = EXPR_NULL;
|
||||
|
||||
if (mold == NULL)
|
||||
result->ts.type = BT_UNKNOWN;
|
||||
else
|
||||
{
|
||||
result->ts = mold->ts;
|
||||
result->where = mold->where;
|
||||
result = gfc_get_expr ();
|
||||
result->ts.type = BT_UNKNOWN;
|
||||
}
|
||||
else
|
||||
result = gfc_copy_expr (mold);
|
||||
result->expr_type = EXPR_NULL;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
2006-02-10 Steven G. Kargl <kargls@comcast.net>
|
||||
|
||||
gfortran.dg/null_1.f90: New test.
|
||||
|
||||
2006-02-10 Tobias Schlüter <tobias.schlueter@physik.uni-muenchen.de>
|
||||
|
||||
PR fortran/14771
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
! { dg-do compile }
|
||||
! PR fortran/20858
|
||||
! If we have "x = null(i)", then "null()" acquires the type, kind type,
|
||||
! and rank of i and these need to match those of x.
|
||||
program null_1
|
||||
integer, parameter :: sp = kind(1.e0), dp = kind(1.d0)
|
||||
integer, pointer :: i => null()
|
||||
real(sp), pointer :: x => null()
|
||||
real(dp), pointer :: y => null()
|
||||
real(sp), pointer :: z(:) => null()
|
||||
x => null(i) ! { dg-error "types in pointer assignment" }
|
||||
x => null(y) ! { dg-error "types in pointer assignment" }
|
||||
z => null(i) ! { dg-error "types in pointer assignment" }
|
||||
z => null(y) ! { dg-error "types in pointer assignment" }
|
||||
x => null(z) ! { dg-error "ranks in pointer assignment" }
|
||||
z => null(x) ! { dg-error "ranks in pointer assignment" }
|
||||
z => null(z)
|
||||
nullify(i, x, y, z)
|
||||
end program null_1
|
Loading…
Reference in New Issue