diff options
author | Thomas Koenig <tkoenig@gcc.gnu.org> | 2011-12-05 20:11:44 +0000 |
---|---|---|
committer | Thomas Koenig <tkoenig@gcc.gnu.org> | 2011-12-05 20:11:44 +0000 |
commit | 671b487dc35fcde6a5f611e0714b419953c4c3ed (patch) | |
tree | c5b6e6f68359e2c8fa107517990e42bcb8657d51 /gcc | |
parent | dfa51991efb62e04c7b41d9825d0cff12061e2e4 (diff) | |
download | gcc-671b487dc35fcde6a5f611e0714b419953c4c3ed.zip gcc-671b487dc35fcde6a5f611e0714b419953c4c3ed.tar.gz gcc-671b487dc35fcde6a5f611e0714b419953c4c3ed.tar.bz2 |
re PR fortran/51338 (seg fault in gfc_dep_compare_expr with -O2)
2011-12-05 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/51338
* dependency.c (are_identical_variables): Handle case where
end fields of substring references are NULL.
2011-12-05 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/51338
* gfortran.dg/assumed_charlen_substring_1.f90: New test.
From-SVN: r182024
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/fortran/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/fortran/dependency.c | 14 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/assumed_charlen_substring_1.f90 | 10 |
4 files changed, 34 insertions, 3 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 4b553db..4b23c58 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2011-12-05 Thomas Koenig <tkoenig@gcc.gnu.org> + + PR fortran/51338 + * dependency.c (are_identical_variables): Handle case where + end fields of substring references are NULL. + 2011-12-04 Tobias Burnus <burnus@net-b.de> PR fortran/51383 @@ -12,7 +18,7 @@ * class.c (gfc_build_class_symbol): Handle attr.select_type_temporary. -2011-12-03 Tobias Burnus <burnus@net-b.de> +2011-12-03 Tobias Burnus <burnus@net-b.de> PR fortran/50684 * check.c (variable_check): Fix intent(in) check. diff --git a/gcc/fortran/dependency.c b/gcc/fortran/dependency.c index fd7fa73..96c4e5f 100644 --- a/gcc/fortran/dependency.c +++ b/gcc/fortran/dependency.c @@ -173,9 +173,19 @@ are_identical_variables (gfc_expr *e1, gfc_expr *e2) break; case REF_SUBSTRING: - if (gfc_dep_compare_expr (r1->u.ss.start, r2->u.ss.start) != 0 - || gfc_dep_compare_expr (r1->u.ss.end, r2->u.ss.end) != 0) + if (gfc_dep_compare_expr (r1->u.ss.start, r2->u.ss.start) != 0) return false; + + /* If both are NULL, the end length compares equal, because we + are looking at the same variable. This can only happen for + assumed- or deferred-length character arguments. */ + + if (r1->u.ss.end == NULL && r2->u.ss.end == NULL) + break; + + if (gfc_dep_compare_expr (r1->u.ss.end, r2->u.ss.end) != 0) + return false; + break; default: diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 180c8c3..bf505ce 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2011-12-05 Thomas Koenig <tkoenig@gcc.gnu.org> + + PR fortran/51338 + * gfortran.dg/assumed_charlen_substring_1.f90: New test. + 2011-12-05 Richard Sandiford <rdsandiford@googlemail.com> * g++.dg/debug/pr46338.C: Add dg-require-profiling. diff --git a/gcc/testsuite/gfortran.dg/assumed_charlen_substring_1.f90 b/gcc/testsuite/gfortran.dg/assumed_charlen_substring_1.f90 new file mode 100644 index 0000000..b4697dc --- /dev/null +++ b/gcc/testsuite/gfortran.dg/assumed_charlen_substring_1.f90 @@ -0,0 +1,10 @@ +! { dg-do compile } +! { dg-options "-O -fdump-tree-original" } +! PR 51338 - this used to ICE. +! Original test case by Bud Davis. +subroutine foo(a,b) + character(len=*) :: a + if (a(1:) /= a(1:)) call do_not_use +end subroutine foo +! { dg-final { scan-tree-dump-times "do_not_use" 0 "original" } } +! { dg-final { cleanup-tree-dump "original" } } |