[gcc r11-5526] PR fortran/98017 - Suspected regression using PACK
Harald Anlauf
anlauf@gcc.gnu.org
Sun Nov 29 22:25:01 GMT 2020
https://gcc.gnu.org/g:bb67ad5cff58a707aaae645d4f45a913d8511c86
commit r11-5526-gbb67ad5cff58a707aaae645d4f45a913d8511c86
Author: Harald Anlauf <anlauf@gmx.de>
Date: Sun Nov 29 23:23:16 2020 +0100
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.
Diff:
---
gcc/fortran/expr.c | 3 +++
gcc/testsuite/gfortran.dg/pr98017.f90 | 14 ++++++++++++++
2 files changed, 17 insertions(+)
diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c
index 32d905ad179..ae9b0a79474 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 00000000000..ab60407bf1d
--- /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
More information about the Gcc-cvs
mailing list