diff options
author | Tobias Burnus <burnus@net-b.de> | 2007-07-03 10:02:08 +0200 |
---|---|---|
committer | Tobias Burnus <burnus@gcc.gnu.org> | 2007-07-03 10:02:08 +0200 |
commit | bb9e683e797818425ed3c7bf372455e6aa70c021 (patch) | |
tree | 133835c5805778595f910d23a753df1e8ef7791c /gcc | |
parent | 30b74385c72f339a6bcdc9bf8c7fcfeacfdbb1cf (diff) | |
download | gcc-bb9e683e797818425ed3c7bf372455e6aa70c021.zip gcc-bb9e683e797818425ed3c7bf372455e6aa70c021.tar.gz gcc-bb9e683e797818425ed3c7bf372455e6aa70c021.tar.bz2 |
re PR fortran/20888 (dereferencing NULL still accepted)
2007-07-03 Tobias Burnus <burnus@net-b.de>
PR fortran/20888
* resolve.c (resolve_operator): Check for NULL as operand.
2007-07-03 Tobias Burnus <burnus@net-b.de>
PR fortran/20888
* gfortran.dg/null_2.f90: New.
From-SVN: r126247
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/fortran/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/fortran/resolve.c | 7 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/null_2.f90 | 15 |
4 files changed, 32 insertions, 0 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 6f0747e..80f1e3c 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,8 @@ +2007-07-03 Tobias Burnus <burnus@net-b.de> + + PR fortran/20888 + * resolve.c (resolve_operator): Check for NULL as operand. + 2007-07-02 Tobias Burnus <burnus@net-b.de> * gfortran.texi (Fortran 2003): Add ISO Bind C. diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index fde5043..b249f30 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -2583,6 +2583,13 @@ resolve_operator (gfc_expr *e) op2 = e->value.op.op2; dual_locus_error = false; + if ((op1 && op1->expr_type == EXPR_NULL) + || (op2 && op2->expr_type == EXPR_NULL)) + { + sprintf (msg, _("Invalid context for NULL() pointer at %%L")); + goto bad_op; + } + switch (e->value.op.operator) { case INTRINSIC_UPLUS: diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 4c8dadf..1d3db36 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2007-07-03 Tobias Burnus <burnus@net-b.de> + + PR fortran/20888 + * gfortran.dg/null_2.f90: New. + 2007-07-03 Uros Bizjak <ubizjak@gmail.com> Francois-Xavier Coudert <fxcoudert@gcc.gnu.org> diff --git a/gcc/testsuite/gfortran.dg/null_2.f90 b/gcc/testsuite/gfortran.dg/null_2.f90 new file mode 100644 index 0000000..3102aad --- /dev/null +++ b/gcc/testsuite/gfortran.dg/null_2.f90 @@ -0,0 +1,15 @@ +! { dg-do compile } +! +! NULL(...) pointer is not allowed as operand +! PR fortran/20888 +! +! Contributed by Joost VandeVondele +! +PROGRAM main + IMPLICIT NONE + REAL, POINTER :: TEST + NULLIFY(TEST) + TEST => -NULL(TEST) ! { dg-error "Invalid context for NULL" } + IF (TEST .EQ. NULL(TEST)) TEST=>NULL() ! { dg-error "Invalid context for NULL" } + IF (NULL(TEST) .EQ. TEST) TEST=>NULL() ! { dg-error "Invalid context for NULL" } +END PROGRAM main |