summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/string_ctor_1.f90
diff options
context:
space:
mode:
authorpbrook <pbrook@138bc75d-0d04-0410-961f-82ee72b054a4>2004-08-25 16:50:13 +0000
committerpbrook <pbrook@138bc75d-0d04-0410-961f-82ee72b054a4>2004-08-25 16:50:13 +0000
commit7949cb072dfcc6abeb9dfbcafd9f1ab7d73669ef (patch)
tree894c624fd13417c22a3668caf4fef82e9246c6b6 /gcc/testsuite/gfortran.dg/string_ctor_1.f90
parented52ef8b296ce70cca9044e0292e5ece9ea0ac7b (diff)
downloadgcc-7949cb072dfcc6abeb9dfbcafd9f1ab7d73669ef.tar.gz
PR fortran/17144
* trans-array.c (gfc_trans_allocate_temp_array): Remove string_length argument. (gfc_trans_array_ctor_element): New function. (gfc_trans_array_constructor_subarray): Use it. (gfc_trans_array_constructor_value): Ditto. Handle constant character arrays. (get_array_ctor_var_strlen, get_array_ctor_strlen): New functions. (gfc_trans_array_constructor): Use them. (gfc_add_loop_ss_code): Update to new gfc_ss layout. (gfc_conv_ss_descriptor): Remember section string length. (gfc_conv_scalarized_array_ref): Ditto. Remove dead code. (gfc_conv_resolve_dependencies): Update to new gfc_ss layout. (gfc_conv_expr_descriptor): Ditto. (gfc_conv_loop_setup): Ditto. Spelling fixes. * trans-array.h (gfc_trans_allocate_temp_array): Update prototype. * trans-const.c (gfc_conv_constant): Update to new gfc_ss layout. * trans-expr.c (gfc_conv_component_ref): Turn error into ICE. (gfc_conv_variable): Set string_length from section. (gfc_conv_function_call): Remove extra argument. (gfc_conv_expr, gfc_conv_expr_reference): Update to new gfc_ss layout. * trans-types.c (gfc_get_character_type_len): New function. (gfc_get_character_type): Use it. (gfc_get_dtype): Return zero for internal types. * trans-types.h (gfc_get_character_type_len): Add prototype. * trans.h (struct gfc_ss): Move string_length out of union. testsuite/ * gfortran.dg/string_ctor_1.f90: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@86558 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite/gfortran.dg/string_ctor_1.f90')
-rw-r--r--gcc/testsuite/gfortran.dg/string_ctor_1.f9049
1 files changed, 49 insertions, 0 deletions
diff --git a/gcc/testsuite/gfortran.dg/string_ctor_1.f90 b/gcc/testsuite/gfortran.dg/string_ctor_1.f90
new file mode 100644
index 00000000000..3242ea8f9e3
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/string_ctor_1.f90
@@ -0,0 +1,49 @@
+! { dg-do run }
+! Program to test character array constructors.
+! PR17144
+subroutine test1 (n, t, u)
+ integer n
+ character(len=n) :: s(2)
+ character(len=*) :: t
+ character(len=*) :: u
+
+ ! A variable array constructor.
+ s = (/t, u/)
+ ! An array constructor as part of an expression.
+ if (any (s .ne. (/"Hell", "Worl"/))) call abort
+end subroutine
+
+subroutine test2
+ character*5 :: s(2)
+
+ ! A constant array constructor
+ s = (/"Hello", "World"/)
+ if ((s(1) .ne. "Hello") .or. (s(2) .ne. "World")) call abort
+end subroutine
+
+subroutine test3
+ character*1 s(26)
+ character*26 t
+ integer i
+
+ ! A large array constructor
+ s = (/'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', &
+ 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'/)
+ do i=1, 26
+ t(i:i) = s(i)
+ end do
+
+ ! Assignment with dependency
+ s = (/(s(27-i), i=1, 26)/)
+ do i=1, 26
+ t(i:i) = s(i)
+ end do
+ if (t .ne. "zyxwvutsrqponmlkjihgfedcba") call abort
+end subroutine
+
+program string_ctor_1
+ call test1 (4, "Hello", "World")
+ call test2
+ call test3
+end program
+