Commit ccccdb8d by Tobias Schlüter Committed by Tobias Schlüter

expr.c (gfc_check_assign): Don't allow NULL as rhs in a non-pointer assignment.

fortran/
* expr.c (gfc_check_assign): Don't allow NULL as rhs in a
non-pointer assignment.

testsuite/
* gfortran.dg/pr15754.f90: Change annotations to dg-error.

From-SVN: r97740
parent e3eff25a
2005-04-06 Tobias Schl"uter <tobias.schlueter@physik.uni-muenchen.de>
* expr.c (gfc_check_assign): Don't allow NULL as rhs in a
non-pointer assignment.
2005-04-05 Feng Wang <fengwang@nudt.edu.cn>
PR fortran/15959
......
......@@ -1789,11 +1789,12 @@ 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);
if (rvalue->expr_type == EXPR_NULL)
{
gfc_error ("NULL appears on right-hand side in assignment at %L",
&rvalue->where);
return FAILURE;
}
/* This is possibly a typo: x = f() instead of x => f() */
if (gfc_option.warn_surprising
......
2005-04-06 Tobias Schl"uter <tobias.schlueter@physik.uni-muenchen.de>
* gfortran.dg/pr15754.f90: Change annotations to dg-error.
2005-04-06 Joseph S. Myers <joseph@codesourcery.com>
* gcc.dg/weak/weak-12.c, g++.dg/ext/weak2.C: New tests.
......
! we didn't give a warning if the RHS of an assignment was NULL
! { dg-do-compile }
INTEGER, POINTER :: P
I = NULL() ! { dg-warning "NULL appears" "Assignment non-pointer = NULL" }
P = NULL() ! { dg-warning "NULL appears" "Assignment pointer = NULL" }
I = NULL() ! { dg-error "NULL appears" "Assignment non-pointer = NULL" }
P = NULL() ! { dg-error "NULL appears" "Assignment pointer = NULL" }
P => NULL()
END
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