Re: testsuite under wine

2022-12-17 Thread Thomas Koenig via Fortran

On 17.12.22 01:26, NightStrike wrote:

On Fri, Dec 16, 2022 at 1:44 AM Thomas Koenig  wrote:


On 16.12.22 03:20, NightStrike via Fortran wrote:


When I run the testsuite under wine, I'm getting a lot of ANSI escape
sequences.  We had fixed this long ago, but it seems to be back.  Any
idea what I should change in my configuration to have this not happen?


This should probably be fixed properly in some *.exp file, but you can
try setting the GCC_COLORS environment variable to an empty string
before running the test.


That didn't help.  It looks like this is always escape 25h to start
the output and 25l to end it, which I think is turning the cursor on
and off (based on https://en.wikipedia.org/wiki/ANSI_escape_code).  I
apparently fixed this previously by building wine with
--without-curses
(https://www.mail-archive.com/gcc@gcc.gnu.org/msg86366.html), but that
option to wine was removed.  Is there a way to hack this on the Deja
side to ignore the escapes?  Or to tell it to run in a way that makes
wine not emit them?


Truth is, I don't know.

I have included the gcc mailing list in this reply, where more
knowledgeable people can be found :-)


[patch, fortran] PR107397 ICE in gfc_arith_plus, at fortran/arith.cc:654

2022-12-17 Thread Jerry D via Fortran

Hi all,

The attached patch fixes a regression and is a patch from Steve.  I have 
regression tested it and provided a test case.  It is fairly simple and 
I will commit under the "simple" rule in a little while.


Thanks Steve for Patch. Thanks Harald for helping me get back up to 
speed on the git magic.


Regards,

Jerry
diff --git a/gcc/fortran/decl.cc b/gcc/fortran/decl.cc
index 0f9b2ced4c2..1562dc22bc6 100644
--- a/gcc/fortran/decl.cc
+++ b/gcc/fortran/decl.cc
@@ -2221,6 +2221,14 @@ add_init_expr_to_sym (const char *name, gfc_expr **initp, locus *var_locus)
 	sym->ts.f90_type = init->ts.f90_type;
 	}
 
+  /* Catch the case:  type(t), parameter :: x = z'1'.  */
+  if (sym->ts.type == BT_DERIVED && init->ts.type == BT_BOZ)
+	{
+	  gfc_error ("Entity %qs at %L is incompatible with a BOZ "
+		 "literal constant", name, &sym->declared_at);
+	  return false;
+	}
+
   /* Add initializer.  Make sure we keep the ranks sane.  */
   if (sym->attr.dimension && init->rank == 0)
 	{
diff --git a/gcc/testsuite/gfortran.dg/pr107397.f90 b/gcc/testsuite/gfortran.dg/pr107397.f90
new file mode 100644
index 000..4592a275e70
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr107397.f90
@@ -0,0 +1,9 @@
+!{ dg-do compile }
+!
+program p
+  type t
+real :: a = 1.0
+  end type
+  type(t), parameter :: x = z'1' ! { dg-error "incompatible with BOZ" }
+  x%a = x%a + 2 ! { dg-error "has no IMPLICIT type"}
+end


[PATCH] Fortran: incorrect array bounds when bound intrinsic used in decl [PR108131]

2022-12-17 Thread Harald Anlauf via Fortran
Dear all,

the previous fix for pr103505 introduced a regression that could lead
to wrong array bounds when LBOUND/UBOUND were used in the array spec
of a declaration.  The reason was that we tried to simplify too early
the array element spec, which appears to have interfered with the
subtle semantics of the bound intrinsics.

The solution is to undo the fix for pr103505.  It turns out that
there are other code changes in place that were put in place to
fix related ICEs, and which handle that one, too, and only lead
to a change of the emitted error diagnostics.

Regtested on x86_64-pc-linux-gnu.  OK for mainline?

As this is a 10/11/12/13 regression, I would like to backport
as seems fit.

Thanks,
Harald

From 531be0753352ec30c4b1e24591ec3e0c33cd4409 Mon Sep 17 00:00:00 2001
From: Harald Anlauf 
Date: Sat, 17 Dec 2022 22:04:32 +0100
Subject: [PATCH] Fortran: incorrect array bounds when bound intrinsic used in
 decl [PR108131]

gcc/fortran/ChangeLog:

	PR fortran/108131
	* array.cc (match_array_element_spec): Avoid too early simplification
	of matched array element specs that can lead to a misinterpretation
	when used as array bounds in array declarations.

gcc/testsuite/ChangeLog:

	PR fortran/108131
	* gfortran.dg/pr103505.f90: Adjust expected patterns.
	* gfortran.dg/pr108131.f90: New test.
---
 gcc/fortran/array.cc   |  4 
 gcc/testsuite/gfortran.dg/pr103505.f90 |  8 +---
 gcc/testsuite/gfortran.dg/pr108131.f90 | 25 +
 3 files changed, 30 insertions(+), 7 deletions(-)
 create mode 100644 gcc/testsuite/gfortran.dg/pr108131.f90

diff --git a/gcc/fortran/array.cc b/gcc/fortran/array.cc
index 10d9e0c5354..7457c03e6cd 100644
--- a/gcc/fortran/array.cc
+++ b/gcc/fortran/array.cc
@@ -512,8 +512,6 @@ match_array_element_spec (gfc_array_spec *as)
   if (!gfc_expr_check_typed (*upper, gfc_current_ns, false))
 return AS_UNKNOWN;

-  gfc_try_simplify_expr (*upper, 0);
-
   if (((*upper)->expr_type == EXPR_CONSTANT
 	&& (*upper)->ts.type != BT_INTEGER) ||
   ((*upper)->expr_type == EXPR_FUNCTION
@@ -546,8 +544,6 @@ match_array_element_spec (gfc_array_spec *as)
   if (!gfc_expr_check_typed (*upper, gfc_current_ns, false))
 return AS_UNKNOWN;

-  gfc_try_simplify_expr (*upper, 0);
-
   if (((*upper)->expr_type == EXPR_CONSTANT
 	&& (*upper)->ts.type != BT_INTEGER) ||
   ((*upper)->expr_type == EXPR_FUNCTION
diff --git a/gcc/testsuite/gfortran.dg/pr103505.f90 b/gcc/testsuite/gfortran.dg/pr103505.f90
index 522e53efcb2..01308019b2c 100644
--- a/gcc/testsuite/gfortran.dg/pr103505.f90
+++ b/gcc/testsuite/gfortran.dg/pr103505.f90
@@ -3,7 +3,9 @@
 ! Testcase by G.Steinmetz

 program p
-  integer, parameter :: a((2.))   = [4,8] ! { dg-error "scalar INTEGER" }
-  integer, parameter :: z(1:(2.)) = [4,8] ! { dg-error "scalar INTEGER" }
-  print *, a(1:1) ! { dg-error "Syntax error" }
+  integer, parameter :: a((2.))   = [4,8] ! { dg-error "INTEGER type" }
+  integer, parameter :: z(1:(2.)) = [4,8] ! { dg-error "INTEGER type" }
+  print *, a(1:1)
 end
+
+! { dg-prune-output "Parameter array" }
diff --git a/gcc/testsuite/gfortran.dg/pr108131.f90 b/gcc/testsuite/gfortran.dg/pr108131.f90
new file mode 100644
index 000..4a3c467f73a
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr108131.f90
@@ -0,0 +1,25 @@
+! { dg-do run }
+! { dg-additional-options "-fdump-tree-original" }
+! PR fortran/108131
+!
+! Incorrect array bounds when bound intrinsic used in declaration
+
+program test
+  implicit none
+  integer, parameter :: mg(7:10) = 0
+  integer, parameter :: u =   ubound(mg, dim=1)
+  integer, parameter :: cx(-1:ubound(mg, dim=1)) = 1
+  integer, parameter :: dx(lbound(mg, dim=1):ubound(mg, dim=1)) = 2
+
+  write(*,*) ubound(mg, dim=1)
+  write(*,*) ubound(cx, dim=1)
+  if (u /= 10) stop 1
+  if (ubound(mg, dim=1) /= 10) stop 2
+  if (ubound(cx, dim=1) /= 10) stop 3
+  if (ubound(dx, dim=1) /= 10) stop 4
+  if (lbound(mg, dim=1) /=  7) stop 5
+  if (lbound(cx, dim=1) /= -1) stop 6
+  if (lbound(dx, dim=1) /=  7) stop 7
+end program test
+
+! { dg-final { scan-tree-dump-not "_gfortran_stop_numeric" "original" } }
--
2.35.3