From ccccdb8d9b339972382604e17d0e451fa590f1a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Schl=C3=BCter?= Date: Wed, 6 Apr 2005 20:03:09 +0200 Subject: [PATCH] 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 --- gcc/fortran/ChangeLog | 5 +++++ gcc/fortran/expr.c | 11 ++++++----- gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/gfortran.dg/pr15754.f90 | 4 ++-- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index fed9ec3d271..990eb18c289 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,8 @@ +2005-04-06 Tobias Schl"uter + + * expr.c (gfc_check_assign): Don't allow NULL as rhs in a + non-pointer assignment. + 2005-04-05 Feng Wang PR fortran/15959 diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c index f4a4b589b1f..d0c99e335a0 100644 --- a/gcc/fortran/expr.c +++ b/gcc/fortran/expr.c @@ -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 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 962e7e0059d..dc98fcd7d63 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2005-04-06 Tobias Schl"uter + + * gfortran.dg/pr15754.f90: Change annotations to dg-error. + 2005-04-06 Joseph S. Myers * gcc.dg/weak/weak-12.c, g++.dg/ext/weak2.C: New tests. diff --git a/gcc/testsuite/gfortran.dg/pr15754.f90 b/gcc/testsuite/gfortran.dg/pr15754.f90 index 6d8e34f28db..f595d6e2ac6 100644 --- a/gcc/testsuite/gfortran.dg/pr15754.f90 +++ b/gcc/testsuite/gfortran.dg/pr15754.f90 @@ -1,7 +1,7 @@ ! 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