aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/dependency.c
diff options
context:
space:
mode:
authorThomas Koenig <tkoenig@gcc.gnu.org>2016-10-22 14:04:46 +0000
committerThomas Koenig <tkoenig@gcc.gnu.org>2016-10-22 14:04:46 +0000
commit15876ceeb1cfb8a8280eb05f15f01ce945fcad15 (patch)
treec64a2201d2dffde8ad03b2abe42eb98b1b5735fb /gcc/fortran/dependency.c
parent574284e9c49687d8bcc039165964602311decd2b (diff)
downloadgcc-15876ceeb1cfb8a8280eb05f15f01ce945fcad15.zip
gcc-15876ceeb1cfb8a8280eb05f15f01ce945fcad15.tar.gz
gcc-15876ceeb1cfb8a8280eb05f15f01ce945fcad15.tar.bz2
re PR fortran/78021 (Wrong result with optimization on character constant)
2016-10-22 Thomas Koenig <tkoenig@gcc.gnu.org> PR fortran/78021 * gfc_compare_functions: Strings with different lengths in argument lists compare unequal. 2016-10-22 Thomas Koenig <tkoenig@gcc.gnu.org> PR fortran/78021 * gfortran.dg/string_length_3.f90: New test. From-SVN: r241440
Diffstat (limited to 'gcc/fortran/dependency.c')
-rw-r--r--gcc/fortran/dependency.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/gcc/fortran/dependency.c b/gcc/fortran/dependency.c
index 8e78e43..82c5e6b 100644
--- a/gcc/fortran/dependency.c
+++ b/gcc/fortran/dependency.c
@@ -226,9 +226,26 @@ gfc_dep_compare_functions (gfc_expr *e1, gfc_expr *e2, bool impure_ok)
if ((args1->expr == NULL) ^ (args2->expr == NULL))
return -2;
- if (args1->expr != NULL && args2->expr != NULL
- && gfc_dep_compare_expr (args1->expr, args2->expr) != 0)
- return -2;
+ if (args1->expr != NULL && args2->expr != NULL)
+ {
+ gfc_expr *e1, *e2;
+ e1 = args1->expr;
+ e2 = args2->expr;
+
+ if (gfc_dep_compare_expr (e1, e2) != 0)
+ return -2;
+
+ /* Special case: String arguments which compare equal can have
+ different lengths, which makes them different in calls to
+ procedures. */
+
+ if (e1->expr_type == EXPR_CONSTANT
+ && e1->ts.type == BT_CHARACTER
+ && e2->expr_type == EXPR_CONSTANT
+ && e2->ts.type == BT_CHARACTER
+ && e1->value.character.length != e2->value.character.length)
+ return -2;
+ }
args1 = args1->next;
args2 = args2->next;