Re: [PATCH] PR fortrsn/101564 - ICE in resolve_allocate_deallocate, at fortran/resolve.c:8169

2021-07-28 Thread Tobias Burnus

Hi Harald,

On 27.07.21 23:42, Harald Anlauf wrote:

This almost worked, needing only a restriction to %KIND and %LEN.
Note that %RE and %IM are usually definable.

Well spotted :-)

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

LGTM - except [...] feel free add them and commit without further review.
[...]

I have added the updated "final" version of the patch to give
everybody another 24h to have a look, and will commit if nobody
complains.

LGTM - thanks again.


[...] with fixing a few issues on the way before Gerhard finds them...


:-)

Tobias


Fortran: ICE in resolve_allocate_deallocate for invalid STAT argument

gcc/fortran/ChangeLog:

  PR fortran/101564
  * expr.c (gfc_check_vardef_context): Add check for KIND and LEN
  parameter inquiries.
  * match.c (gfc_match): Fix comment for %v code.
  (gfc_match_allocate, gfc_match_deallocate): Replace use of %v code
  by %e in gfc_match to allow for function references as STAT and
  ERRMSG arguments.
  * resolve.c (resolve_allocate_deallocate): Avoid NULL pointer
  dereferences and shortcut for bad STAT and ERRMSG argument to
  (DE)ALLOCATE.  Remove bogus parts of checks for STAT and ERRMSG.

gcc/testsuite/ChangeLog:

  PR fortran/101564
  * gfortran.dg/allocate_stat_3.f90: New test.
  * gfortran.dg/allocate_stat.f90: Adjust error messages.
  * gfortran.dg/implicit_11.f90: Likewise.
  * gfortran.dg/inquiry_type_ref_3.f90: Likewise.

-
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 
München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas 
Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht 
München, HRB 106955


[Patch] gfortran.dg/dg.exp: Add libgfortran as -I flag for ISO*.h [PR101305] (was: [PATCH 3/3] [PR libfortran/101305] Fix ISO_Fortran_binding.h paths in gfortran testsuite)

2021-07-28 Thread Tobias Burnus

Hi Sandra, hi all,

On 28.07.21 06:36, Sandra Loosemore wrote:

On 7/26/21 2:13 PM, Sandra Loosemore wrote:

On 7/26/21 3:45 AM, Tobias Burnus wrote:

PS: Still, it would be nice if the proper multi-lib ISO*.h could be
found;


(Example for x86-64-gnu-linux with 32bit and 64bit support)

Namely,
  x86_64-pc-linux-gnu/libgfortran/ISO_Fortran_binding.h
  x86_64-pc-linux-gnu/32/libgfortran/ISO_Fortran_binding.h
exist and they are different.

GCC finds the correct header, when running:
  make check-fortran RUNTESTFLAGS="--target_board=unix\{-m32\}"
which runs gfortran with:
  -B.../x86_64-pc-linux-gnu/32/libgfortran/

Likewise, with "-m32" replaced by "-m64" or "",
it works and gfortran is run with
  -B.../x86_64-pc-linux-gnu/./libgfortran/


But when running both at the same time, i.e.
  make check-fortran RUNTESTFLAGS="--target_board=unix\{,-m32\}"
(note the ',' before '-m32'), gfortran is run for
both "" (= -m64) and "-m32" with:
  -B.../x86_64-pc-linux-gnu/./libgfortran/
That's fine for -m64 but for -m32 it finds the wrong
ISO_Fortran_binding.h  file.


Solution:
Add a "-I" with the proper path to find the right *.h file.
'strace' confirms that the -I include path is searched before the
path provided by "-B".

[Note: I only did in-tree testing with that patch so far.]

Comments to the attached patch? Does it look OK?


 * * *


Unfortunately, I could not get this to work.


I think the attached version does work :-)


For installed-tree testing, this resulted in diagnostics about a
nonexistent directory on the include path.  In my i686-pc-linux-gnu
build I was having other problems when I tried build-tree testing using

make check-gfortran RUNTESTFLAGS="--target-board=localhost/m64"


I have an x86-64-gnu-linux build and there I use
"--target_board=unix\{,-m32\}",
which seems to work fine and runs it first with "" (= -m64) and then
with -m32.
(See above.)

I also do not see any issues with xfailing.


BTW, I can't find any documentation for what get_multilibs is supposed
to do.  It seems to be part of Dejagnu itself rather than the gcc test
support?


Yes, but the documentation is, well, short:
https://www.gnu.org/software/dejagnu/manual/get_005fmultilibs-procedure.html

In the DejaGNU source code, there is a better description (comment before the 
function):
Cf. 
https://git.savannah.gnu.org/gitweb/?p=dejagnu.git;a=blob;f=lib/libgloss.exp;;hb=HEAD#l389

Tobias

-
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 
München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas 
Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht 
München, HRB 106955
gfortran.dg/dg.exp: Add libgfortran as -I flag for ISO*.h [PR101305]

gcc/testsuite/
	PR libfortran/101305
	* gfortran.dg/dg.exp: Add '-I /libgfortran'
	compile flag.

diff --git a/gcc/testsuite/gfortran.dg/dg.exp b/gcc/testsuite/gfortran.dg/dg.exp
index 06689813d07..cb48ed3e7fb 100644
--- a/gcc/testsuite/gfortran.dg/dg.exp
+++ b/gcc/testsuite/gfortran.dg/dg.exp
@@ -28,6 +28,17 @@ if ![info exists DEFAULT_FFLAGS] then {
 # Initialize `dg'.
 dg-init
 
+# Flags for finding libgfortran ISO*.h files.
+if [info exists TOOL_OPTIONS] {
+   set specpath [get_multilibs ${TOOL_OPTIONS}]
+} else {
+   set specpath [get_multilibs]
+}
+set include_options "-I$specpath/libgfortran"
+if [file exists $specpath/libgfortran ] {
+set include_options "-I$specpath/libgfortran" 
+}
+
 global gfortran_test_path
 global gfortran_aux_module_flags
 set gfortran_test_path $srcdir/$subdir
@@ -55,10 +66,10 @@ proc dg-compile-aux-modules { args } {
 
 # Main loop.
 gfortran-dg-runtest [lsort \
-   [glob -nocomplain $srcdir/$subdir/*.\[fF\]{,90,95,03,08} ] ] "" $DEFAULT_FFLAGS
+   [glob -nocomplain $srcdir/$subdir/*.\[fF\]{,90,95,03,08} ] ] "" "$include_options $DEFAULT_FFLAGS"
 
 gfortran-dg-runtest [lsort \
-   [glob -nocomplain $srcdir/$subdir/g77/*.\[fF\] ] ] "" $DEFAULT_FFLAGS
+   [glob -nocomplain $srcdir/$subdir/g77/*.\[fF\] ] ] "" "$include_options $DEFAULT_FFLAGS"
 
 
 # All done.


Re: [Patch] gfortran.dg/dg.exp: Add libgfortran as -I flag for ISO*.h [PR101305] (was: [PATCH 3/3] [PR libfortran/101305] Fix ISO_Fortran_binding.h paths in gfortran testsuite)

2021-07-28 Thread Jakub Jelinek via Fortran
On Wed, Jul 28, 2021 at 01:22:53PM +0200, Tobias Burnus wrote:
> gfortran.dg/dg.exp: Add libgfortran as -I flag for ISO*.h [PR101305]
> 
> gcc/testsuite/
>   PR libfortran/101305
>   * gfortran.dg/dg.exp: Add '-I /libgfortran'
>   compile flag.

Wouldn't it be better to do that in gcc/testsuite/lib/gfortran.exp
to GFORTRAN_UNDER_TEST there next to
-B$specpath/libgfortran/ ?
So that we don't add it for the installed gfortran testing - there
we want to test what installed gfortran will do,
and will affect also libgomp testing.

Jakub