This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Patch, Fortran] PR37076 - fix kind=4 string concatenation


Dear all,

due to an oversight, the result of concatenating two kind=4 strings was
a kind=1 string.

Build and regtested (almost finished) on x86-64-linux.
OK for the trunk (unless regtesting fails)?

Tobias
2008-08-23  Tobias Burnus  <burnus@net-b.de>

	PR fortran/37076
	* arith.c (gfc_arith_concat): Fix concat of kind=4 strings.

2008-08-23  Tobias Burnus  <burnus@net-b.de>

	PR fortran/37076
	* gfortran.dg/widechar_9.f90: New.

Index: gcc/fortran/arith.c
===================================================================
--- gcc/fortran/arith.c	(Revision 139506)
+++ gcc/fortran/arith.c	(Arbeitskopie)
@@ -1069,7 +1069,8 @@ gfc_arith_concat (gfc_expr *op1, gfc_exp
   gfc_expr *result;
   int len;
 
-  result = gfc_constant_result (BT_CHARACTER, gfc_default_character_kind,
+  gcc_assert (op1->ts.kind == op2->ts.kind);
+  result = gfc_constant_result (BT_CHARACTER, op1->ts.kind,
 				&op1->where);
 
   len = op1->value.character.length + op2->value.character.length;
Index: gcc/testsuite/gfortran.dg/widechar_9.f90
===================================================================
--- gcc/testsuite/gfortran.dg/widechar_9.f90	(Revision 0)
+++ gcc/testsuite/gfortran.dg/widechar_9.f90	(Revision 0)
@@ -0,0 +1,14 @@
+! { dg-do compile }
+!
+! PR fortran/37076
+!
+! Before the result of concatenations was always a kind=1 string
+!
+program test3
+  integer,parameter :: u = 4
+  character(1,u),parameter :: nen=char(int(z'5e74'),u) !year
+  character(25,u) :: string
+  string = u_"2008"//nen
+  print *, u_"2008"//nen ! Compiles OK
+  print *, u_"2008"//nen//u_"8" ! Rejects this.
+end program test3

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]