From fa06900405a051b23855e24aa9d2d3b0504c51e9 Mon Sep 17 00:00:00 2001 From: tobi Date: Wed, 25 Aug 2004 22:07:32 +0000 Subject: fortran/ * expr.c (gfc_check_assign): Add comment. Add new warning. * trans-expr.c (gfc_conv_function_call): Correctly dereference result of pointer valued function when not in pointer assignment. testsuite/ * gfortran.dg/assignment_1.f90: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@86585 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/fortran/expr.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'gcc/fortran/expr.c') diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c index 99db76d908c..0539b6568ac 100644 --- a/gcc/fortran/expr.c +++ b/gcc/fortran/expr.c @@ -1797,10 +1797,19 @@ gfc_check_assign (gfc_expr * lvalue, gfc_expr * rvalue, int conform) return FAILURE; } + /* This is a guaranteed segfault and possibly a typo: p = NULL() + instead of p => NULL() */ if (rvalue->expr_type == EXPR_NULL) gfc_warning ("NULL appears on right-hand side in assignment at %L", &rvalue->where); + /* This is possibly a typo: x = f() instead of x => f() */ + if (gfc_option.warn_surprising + && rvalue->expr_type == EXPR_FUNCTION + && rvalue->symtree->n.sym->attr.pointer) + gfc_warning ("POINTER valued function appears on right-hand side of " + "assignment at %L", &rvalue->where); + /* Check size of array assignments. */ if (lvalue->rank != 0 && rvalue->rank != 0 && gfc_check_conformance ("Array assignment", lvalue, rvalue) != SUCCESS) -- cgit v1.2.3