This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [gfortran] Fix PR 19543: Type mismatch when building logicalconstants
Paul Brook wrote:
> Yes. Patch approved (assuming it passes testing).
Thanks, a patch which resolves the issue, but leaves us with a logical type
that is essentially the same as the integer type of the same width, is below;
it avoids setting TYPE_PRECISION(type) = 1 for logical types.
Bubblestrapped and tested on i686-pc-linux. Is this together with the
attached testcase ok, or shold we hope that the backend gets fixed?
- Tobi
2005-01-22 Tobias Schl"uter <tobias.schlueter@physik.uni-muenchen.de>
PR fortran/19543
* trans-types.c (gfc_build_logical_type): #if 0 setting TYPE_PRECISION
to 1 to avoid wrong constant merging.
Index: trans-types.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fortran/trans-types.c,v
retrieving revision 1.36
diff -u -p -r1.36 trans-types.c
--- trans-types.c 16 Jan 2005 16:48:16 -0000 1.36
+++ trans-types.c 22 Jan 2005 00:48:18 -0000
@@ -420,7 +420,14 @@ gfc_build_logical_type (gfc_logical_info
new_type = make_unsigned_type (bit_size);
TREE_SET_CODE (new_type, BOOLEAN_TYPE);
TYPE_MAX_VALUE (new_type) = build_int_cst (new_type, 1);
+#if 0
+ /* FIXME: Unfortunately this breaks assumptions in the backend when
+ dealing with constants. More precisely,
+ LOGICAL(8), PARAMETER :: .TRUE.
+ will only be translated to a byte-sized constant in the
+ assembly. See PR 19543. */
TYPE_PRECISION (new_type) = 1;
+#endif
return new_type;
}
! { dg-do run }
program test
implicit none
logical(1), parameter :: t1 = .TRUE., f1 = .FALSE.
logical(2), parameter :: t2 = .TRUE., f2 = .FALSE.
logical(4), parameter :: t4 = .TRUE., f4 = .FALSE.
logical(8), parameter :: t8 = .TRUE., f8 = .FALSE.
character*2 :: t(4), f(4)
write(t(1),*) t1
write(f(1),*) f1
write(t(2),*) t2
write(f(2),*) f2
write(t(3),*) t4
write(f(3),*) f4
write(t(4),*) t8
write(f(4),*) f8
if (any(t .ne. " T")) call abort
if (any(f .ne. " F")) call abort
end