Commit 7d76d73a by Tobias Schlüter Committed by Tobias Schlüter

expr.c (gfc_check_pointer_assign): Verify that rank of the LHS and RHS match.

* expr.c (gfc_check_pointer_assign): Verify that rank of the LHS
and RHS match. Return early if the RHS is NULL().

From-SVN: r84458
parent 290e757a
2004-07-10 Tobias Schlueter <tobias.schlueter@physik.uni-muenchen.de> 2004-07-10 Tobias Schlueter <tobias.schlueter@physik.uni-muenchen.de>
* expr.c (gfc_check_pointer_assign): Verify that rank of the LHS
and RHS match. Return early if the RHS is NULL().
2004-07-10 Tobias Schlueter <tobias.schlueter@physik.uni-muenchen.de>
* trans-common.c: Fix whitespace issues, make variable names * trans-common.c: Fix whitespace issues, make variable names
more readable. more readable.
(create_common): Additionally, make loop logic more obvious. (create_common): Additionally, make loop logic more obvious.
......
...@@ -1807,8 +1807,8 @@ gfc_check_pointer_assign (gfc_expr * lvalue, gfc_expr * rvalue) ...@@ -1807,8 +1807,8 @@ gfc_check_pointer_assign (gfc_expr * lvalue, gfc_expr * rvalue)
/* If rvalue is a NULL() or NULLIFY, we're done. Otherwise the type, /* 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 kind, etc for lvalue and rvalue must match, and rvalue must be a
pure variable if we're in a pure function. */ pure variable if we're in a pure function. */
if (rvalue->expr_type != EXPR_NULL) if (rvalue->expr_type == EXPR_NULL)
{ return SUCCESS;
if (!gfc_compare_types (&lvalue->ts, &rvalue->ts)) if (!gfc_compare_types (&lvalue->ts, &rvalue->ts))
{ {
...@@ -1819,27 +1819,30 @@ gfc_check_pointer_assign (gfc_expr * lvalue, gfc_expr * rvalue) ...@@ -1819,27 +1819,30 @@ gfc_check_pointer_assign (gfc_expr * lvalue, gfc_expr * rvalue)
if (lvalue->ts.kind != rvalue->ts.kind) if (lvalue->ts.kind != rvalue->ts.kind)
{ {
gfc_error gfc_error ("Different kind type parameters in pointer "
("Different kind type parameters in pointer assignment at %L", "assignment at %L", &lvalue->where);
&lvalue->where);
return FAILURE; return FAILURE;
} }
attr = gfc_expr_attr (rvalue); attr = gfc_expr_attr (rvalue);
if (!attr.target && !attr.pointer) if (!attr.target && !attr.pointer)
{ {
gfc_error gfc_error ("Pointer assignment target is neither TARGET "
("Pointer assignment target is neither TARGET nor POINTER at " "nor POINTER at %L", &rvalue->where);
"%L", &rvalue->where);
return FAILURE; return FAILURE;
} }
if (is_pure && gfc_impure_variable (rvalue->symtree->n.sym)) if (is_pure && gfc_impure_variable (rvalue->symtree->n.sym))
{ {
gfc_error gfc_error ("Bad target in pointer assignment in PURE "
("Bad target in pointer assignment in PURE procedure at %L", "procedure at %L", &rvalue->where);
&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;
} }
return SUCCESS; return SUCCESS;
......
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