aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorHarald Anlauf <anlauf@gmx.de>2020-11-29 23:23:16 +0100
committerHarald Anlauf <anlauf@gmx.de>2020-11-29 23:24:45 +0100
commitbb67ad5cff58a707aaae645d4f45a913d8511c86 (patch)
tree67613d953caf08a30597942a357984b6f9a22bfc /gcc
parentccea13715b2ae55d4a784c2031553461ebf13eba (diff)
downloadgcc-bb67ad5cff58a707aaae645d4f45a913d8511c86.zip
gcc-bb67ad5cff58a707aaae645d4f45a913d8511c86.tar.gz
gcc-bb67ad5cff58a707aaae645d4f45a913d8511c86.tar.bz2
PR fortran/98017 - Suspected regression using PACK
When substituting a parameter variable of type character, the character length was reset to 1. Fix this by copying the length. gcc/fortran/ChangeLog: * expr.c (simplify_parameter_variable): Fix up character length after copying an array-valued expression. gcc/testsuite/ChangeLog: * gfortran.dg/pr98017.f90: New test.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/fortran/expr.c3
-rw-r--r--gcc/testsuite/gfortran.dg/pr98017.f9014
2 files changed, 17 insertions, 0 deletions
diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c
index 32d905a..ae9b0a7 100644
--- a/gcc/fortran/expr.c
+++ b/gcc/fortran/expr.c
@@ -2096,6 +2096,9 @@ simplify_parameter_variable (gfc_expr *p, int type)
return false;
e->rank = p->rank;
+
+ if (e->ts.type == BT_CHARACTER && p->ts.u.cl)
+ e->ts = p->ts;
}
if (e->ts.type == BT_CHARACTER && e->ts.u.cl == NULL)
diff --git a/gcc/testsuite/gfortran.dg/pr98017.f90 b/gcc/testsuite/gfortran.dg/pr98017.f90
new file mode 100644
index 0000000..ab60407
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr98017.f90
@@ -0,0 +1,14 @@
+! { dg-do run }
+! PR98017 - [8/9/10/11 Regression] Suspected regression using PACK
+
+program p
+ implicit none
+ character(*), parameter :: s(1) = ['abc()']
+ character(*), parameter :: t(*) = s(:)(:1)
+ if (len (pack (s, s(:)(:1) == 'a')) /= len (s)) stop 1
+ if (any (pack (s, s(:)(:1) == 'a') /= s)) stop 2
+ if (len (pack (s, t == 'a')) /= len (s)) stop 3
+ if (any (pack (s, t == 'a') /= s)) stop 4
+ if (len (pack (s(:)(1:5), t == 'a')) /= len (s)) stop 5
+ if (any (pack (s(:)(1:5), t == 'a') /= s)) stop 6
+end