]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
expr.c (gfc_check_assign): Don't allow NULL as rhs in a non-pointer assignment.
authorTobias Schlüter <tobias.schlueter@physik.uni-muenchen.de>
Wed, 6 Apr 2005 18:03:09 +0000 (20:03 +0200)
committerTobias Schlüter <tobi@gcc.gnu.org>
Wed, 6 Apr 2005 18:03:09 +0000 (20:03 +0200)
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
gcc/fortran/expr.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/pr15754.f90

index fed9ec3d27191f93e23cffa68d88d1d6dd737e1f..990eb18c2893aa338514c812565246506b29bb1b 100644 (file)
@@ -1,3 +1,8 @@
+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
index f4a4b589b1fe29f62cae77f71b627a4ff7883387..d0c99e335a0a89095373bec33537d0038c818be5 100644 (file)
@@ -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 
index 962e7e0059d86d1a05b759998cce9d2e71277afe..dc98fcd7d632bbcc2d05b3ff28f064be4629eba4 100644 (file)
@@ -1,3 +1,7 @@
+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.
index 6d8e34f28db77c7edf19d89e480935219dbca52f..f595d6e2ac62e19696c502dd11d000e1322b7970 100644 (file)
@@ -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