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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@110845
138bc75d-0d04-0410-961f-
82ee72b054a4
+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\81üter <tobias.schlueter@physik.uni-muenchen.de>
PR fortran/14771
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;
}
if (m != MATCH_YES)
goto cleanup;
- initializer->ts = current_ts;
-
}
else if (gfc_match_char ('=') == MATCH_YES)
{
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);
}
/* 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))
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,
"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 "
{
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;
}
+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
--- /dev/null
+! { 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