diff options
author | tobi <tobi@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-07-10 12:45:33 +0000 |
---|---|---|
committer | tobi <tobi@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-07-10 12:45:33 +0000 |
commit | d7c1b30ededec856bab66952d73ac4efb001dd3f (patch) | |
tree | 57ec2cbe9f8f2290ec632f170cb3cbc49d276643 /gcc/fortran/expr.c | |
parent | 3d834d2c51eae464da9e7e832de88f883d82cc90 (diff) | |
download | gcc-d7c1b30ededec856bab66952d73ac4efb001dd3f.tar.gz |
* expr.c (gfc_check_pointer_assign): Verify that rank of the LHS
and RHS match. Return early if the RHS is NULL().
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@84458 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/fortran/expr.c')
-rw-r--r-- | gcc/fortran/expr.c | 59 |
1 files changed, 31 insertions, 28 deletions
diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c index e9ed27040ee..ad9f42a3f7c 100644 --- a/gcc/fortran/expr.c +++ b/gcc/fortran/expr.c @@ -1807,39 +1807,42 @@ 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) + return SUCCESS; + + if (!gfc_compare_types (&lvalue->ts, &rvalue->ts)) { + gfc_error ("Different types in pointer assignment at %L", + &lvalue->where); + return FAILURE; + } - if (!gfc_compare_types (&lvalue->ts, &rvalue->ts)) - { - gfc_error ("Different types in pointer assignment at %L", - &lvalue->where); - return FAILURE; - } + if (lvalue->ts.kind != rvalue->ts.kind) + { + gfc_error ("Different kind type parameters in pointer " + "assignment at %L", &lvalue->where); + return FAILURE; + } - if (lvalue->ts.kind != rvalue->ts.kind) - { - gfc_error - ("Different kind type parameters in pointer assignment at %L", - &lvalue->where); - return FAILURE; - } + attr = gfc_expr_attr (rvalue); + if (!attr.target && !attr.pointer) + { + gfc_error ("Pointer assignment target is neither TARGET " + "nor POINTER at %L", &rvalue->where); + return FAILURE; + } - attr = gfc_expr_attr (rvalue); - if (!attr.target && !attr.pointer) - { - gfc_error - ("Pointer assignment target is neither TARGET nor POINTER at " - "%L", &rvalue->where); - return FAILURE; - } + if (is_pure && gfc_impure_variable (rvalue->symtree->n.sym)) + { + gfc_error ("Bad target in pointer assignment in PURE " + "procedure at %L", &rvalue->where); + } - if (is_pure && gfc_impure_variable (rvalue->symtree->n.sym)) - { - gfc_error - ("Bad target in pointer assignment in PURE 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; } return SUCCESS; |