[COMMITTED 1/2] testsuite: fix comment-only directive typos

2024-09-26 Thread Sam James
Doing this to avoid FPs from grepping but also to avoid the potential
for people learning bad habits.

gcc/testsuite/ChangeLog:

* gfortran.dg/coarray/caf.exp: Fix 'dg-do-run' typo.
* lib/gfortran-dg.exp: Ditto.
* lib/gm2-dg.exp: Ditto.
* lib/go-dg.exp: Ditto.
---
Committed as obvious.

 gcc/testsuite/gfortran.dg/coarray/caf.exp | 2 +-
 gcc/testsuite/lib/gfortran-dg.exp | 2 +-
 gcc/testsuite/lib/gm2-dg.exp  | 2 +-
 gcc/testsuite/lib/go-dg.exp   | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/gcc/testsuite/gfortran.dg/coarray/caf.exp 
b/gcc/testsuite/gfortran.dg/coarray/caf.exp
index 31c13cd34e5e..9e608ecf83d0 100644
--- a/gcc/testsuite/gfortran.dg/coarray/caf.exp
+++ b/gcc/testsuite/gfortran.dg/coarray/caf.exp
@@ -78,7 +78,7 @@ foreach test [lsort [glob -nocomplain 
$srcdir/$subdir/*.\[fF\]{,90,95,03,08} ]]
 }
 
 # Enable if you want to test several options:
-## look if this is dg-do-run test, in which case
+## look if this is dg-do run test, in which case
 ## we cycle through the option list, otherwise we don't
 #if [expr [search_for $test "dg-do run"]] {
 #  set option_list $torture_with_loops
diff --git a/gcc/testsuite/lib/gfortran-dg.exp 
b/gcc/testsuite/lib/gfortran-dg.exp
index fcba95dc3961..0c578b52684d 100644
--- a/gcc/testsuite/lib/gfortran-dg.exp
+++ b/gcc/testsuite/lib/gfortran-dg.exp
@@ -146,7 +146,7 @@ proc gfortran-dg-runtest { testcases flags 
default-extra-flags } {
continue
 }
 
-   # look if this is dg-do-run test, in which case
+   # look if this is dg-do run test, in which case
# we cycle through the option list, otherwise we don't
if [expr [search_for $test "dg-do run"]] {
set option_list $torture_with_loops
diff --git a/gcc/testsuite/lib/gm2-dg.exp b/gcc/testsuite/lib/gm2-dg.exp
index 7230143f80e8..0fa26846df84 100644
--- a/gcc/testsuite/lib/gm2-dg.exp
+++ b/gcc/testsuite/lib/gm2-dg.exp
@@ -59,7 +59,7 @@ proc gm2-dg-runtest { testcases flags default-extra-flags } {
continue
 }
 
-   # look if this is dg-do-run test, in which case
+   # look if this is dg-do run test, in which case
# we cycle through the option list, otherwise we don't
if [expr [search_for $test "dg-do run"]] {
set option_list $TORTURE_OPTIONS
diff --git a/gcc/testsuite/lib/go-dg.exp b/gcc/testsuite/lib/go-dg.exp
index d22835066252..bbc70a2301fd 100644
--- a/gcc/testsuite/lib/go-dg.exp
+++ b/gcc/testsuite/lib/go-dg.exp
@@ -47,7 +47,7 @@ proc go-dg-runtest { testcases flags default-extra-flags } {
continue
 }
 
-   # look if this is dg-do-run test, in which case
+   # look if this is dg-do run test, in which case
# we cycle through the option list, otherwise we don't
if [expr [search_for $test "dg-do run"]] {
set option_list $TORTURE_OPTIONS
-- 
2.46.2



[COMMITTED 2/2] testsuite: fix hyphen typos

2024-09-26 Thread Sam James
gcc/testsuite/ChangeLog:

* g++.dg/modules/reparent-1_c.C: Fix whitespace around '-' in dg 
directive.
* gfortran.dg/initialization_25.f90: Ditto.
---
Committed as obvious.

 gcc/testsuite/g++.dg/modules/reparent-1_c.C | 2 +-
 gcc/testsuite/gfortran.dg/initialization_25.f90 | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/gcc/testsuite/g++.dg/modules/reparent-1_c.C 
b/gcc/testsuite/g++.dg/modules/reparent-1_c.C
index e4e984c87a9d..d3f7f51e335b 100644
--- a/gcc/testsuite/g++.dg/modules/reparent-1_c.C
+++ b/gcc/testsuite/g++.dg/modules/reparent-1_c.C
@@ -6,4 +6,4 @@ int main ()
   v (0); // { dg-error "too many arguments" }
 }
 
-// { dg -regexp {In module foo, imported at [^\n]*/reparent-1_b.C:14,\nof 
module bar, imported at [^\n]*/reparent-1_c.C:2:\n[^\n]*/reparent-1_a.C:6:13: 
note: declared here\n} }
+// { dg-regexp {In module foo, imported at [^\n]*/reparent-1_b.C:14,\nof 
module bar, imported at [^\n]*/reparent-1_c.C:2:\n[^\n]*/reparent-1_a.C:6:13: 
note: declared here\n} }
diff --git a/gcc/testsuite/gfortran.dg/initialization_25.f90 
b/gcc/testsuite/gfortran.dg/initialization_25.f90
index 66c447e2f1cb..c8edb163be04 100644
--- a/gcc/testsuite/gfortran.dg/initialization_25.f90
+++ b/gcc/testsuite/gfortran.dg/initialization_25.f90
@@ -1,12 +1,12 @@
 ! { dg-do compile }
 !
 ! PR fortran/35779 - unrelated error message
-! Tescase contributed by
+! Testcase contributed by
 ! Dick Hendrickson 
 !
 ! Initial patch was reverted as it broke nested loops (see 
initialization_26.f90).
 !
 
 !   INTEGER :: J1
-!   INTEGER,PARAMETER :: I2(10) = (/(J1,J1=its_bad,1,-1)/) ! { dg - error 
"does not reduce" }
+!   INTEGER,PARAMETER :: I2(10) = (/(J1,J1=its_bad,1,-1)/) ! { dg-error "does 
not reduce" }
 END
-- 
2.46.2



[pushed] doc: Remove index reference to removed documentation in, fortran manual

2024-09-26 Thread Mikael Morin

Checked with make html pdf. Pushed.From e9f341426567442a70747f89b6b954a005ca287a Mon Sep 17 00:00:00 2001
From: Mikael Morin 
Date: Thu, 26 Sep 2024 14:23:06 +0200
Subject: [PATCH] doc: Remove index reference to removed documentation in
 fortran manual

Fortran option -M used to be an alias for -J.  After some deprecation time,
it was reused for another purpose at revision
r0-100725-gd8ddea4044ee8212d5fe305e8e2a547700cd7b8f.
That revision removed the documentation parts of -J mentioning -M, but left
a reference to -M in the index.

This change removes the remaining reference.

gcc/fortran/ChangeLog:

	* invoke.texi (-M): Remove index reference to removed documentation.
---
 gcc/fortran/invoke.texi | 1 -
 1 file changed, 1 deletion(-)

diff --git a/gcc/fortran/invoke.texi b/gcc/fortran/invoke.texi
index fbb5a0efa10..a9ac87d3a32 100644
--- a/gcc/fortran/invoke.texi
+++ b/gcc/fortran/invoke.texi
@@ -1414,7 +1414,6 @@ gcc,Using the GNU Compiler Collection (GCC)}, for information on the
 @option{-I} option.
 
 @opindex J@var{dir}
-@opindex M@var{dir}
 @cindex paths, search
 @cindex module search path
 @item -J@var{dir}
-- 
2.45.2



[COMMITTED] testsuite: XFAIL gfortran.dg/initialization_25.f90 properly

2024-09-26 Thread Sam James
The test was disabled/XFAIL'd informally in r0-100012-gcdc6637d7c78ec,
but r15-3890-g34bf6aa41ba539 didn't realize this, causing a FAIL.

Fix that by marking it as XFAIL per the original intent.

gcc/testsuite/ChangeLog:
PR fortran/35779
PR fortran/116858

* gfortran.dg/initialization_25.f90: Mark as XFAIL.
---
 gcc/testsuite/gfortran.dg/initialization_25.f90 | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/testsuite/gfortran.dg/initialization_25.f90 
b/gcc/testsuite/gfortran.dg/initialization_25.f90
index c8edb163be04..cae3bbd27d53 100644
--- a/gcc/testsuite/gfortran.dg/initialization_25.f90
+++ b/gcc/testsuite/gfortran.dg/initialization_25.f90
@@ -5,8 +5,8 @@
 ! Dick Hendrickson 
 !
 ! Initial patch was reverted as it broke nested loops (see 
initialization_26.f90).
-!
+! XFAIL is for PR35779
 
 !   INTEGER :: J1
-!   INTEGER,PARAMETER :: I2(10) = (/(J1,J1=its_bad,1,-1)/) ! { dg-error "does 
not reduce" }
+!   INTEGER,PARAMETER :: I2(10) = (/(J1,J1=its_bad,1,-1)/) ! { dg-error "does 
not reduce" { xfail *-*-* } }
 END
-- 
2.46.2



[Fortran, Patch, PR93158, v1] Fix ICE with coarrays on submodules

2024-09-26 Thread Andre Vehreschild
Hi all,

attached patch fixes an ICE when a derived type was used as a coarray in a
submodule. The fix is to not allow caf-token creation for vtypes. Again this,
like the previous patch on pr80235, feels like fixing the symptom and not the
cause. But I can't find where it goes wrong. So if some one has more insight,
let me know, please.

Besides that regtests ok on x86_64-pc-linux-gnu / Fedora 39. Ok for mainline?

Regards,
Andre
--
Andre Vehreschild * Email: vehre ad gmx dot de
From c1af1da343098de3d2b972ef680d3f99fc70f67a Mon Sep 17 00:00:00 2001
From: Andre Vehreschild 
Date: Wed, 25 Sep 2024 14:19:38 +0200
Subject: [PATCH] [Fortran] Fix ICE when extended coarray is used in submodule
 [PR93158]

gcc/fortran/ChangeLog:

	PR fortran/93158

	* trans-types.cc: Prevent adding caf-tokens to vtypes.

gcc/testsuite/ChangeLog:

	* gfortran.dg/coarray/add_sources/submodule_2_mod.f90: New test.
	* gfortran.dg/coarray/submodule_2.f90: New test.
---
 gcc/fortran/trans-types.cc| 36 +--
 .../coarray/add_sources/submodule_2_mod.f90   | 14 
 .../gfortran.dg/coarray/submodule_2.f90   | 14 
 3 files changed, 46 insertions(+), 18 deletions(-)
 create mode 100644 gcc/testsuite/gfortran.dg/coarray/add_sources/submodule_2_mod.f90
 create mode 100644 gcc/testsuite/gfortran.dg/coarray/submodule_2.f90

diff --git a/gcc/fortran/trans-types.cc b/gcc/fortran/trans-types.cc
index 96ef8b49fbe..9e8142b2872 100644
--- a/gcc/fortran/trans-types.cc
+++ b/gcc/fortran/trans-types.cc
@@ -3097,24 +3097,24 @@ gfc_get_derived_type (gfc_symbol * derived, int codimen)

 copy_derived_types:

-  for (c = derived->components; c; c = c->next)
-{
-  /* Do not add a caf_token field for class container components.  */
-  if ((codimen || coarray_flag)
-	  && !c->attr.dimension && !c->attr.codimension
-	  && (c->attr.allocatable || c->attr.pointer)
-	  && !derived->attr.is_class)
-	{
-	  /* Provide sufficient space to hold "_caf_symbol".  */
-	  char caf_name[GFC_MAX_SYMBOL_LEN + 6];
-	  gfc_component *token;
-	  snprintf (caf_name, sizeof (caf_name), "_caf_%s", c->name);
-	  token = gfc_find_component (derived, caf_name, true, true, NULL);
-	  gcc_assert (token);
-	  c->caf_token = token->backend_decl;
-	  suppress_warning (c->caf_token);
-	}
-}
+  if (!derived->attr.vtype)
+for (c = derived->components; c; c = c->next)
+  {
+	/* Do not add a caf_token field for class container components.  */
+	if ((codimen || coarray_flag) && !c->attr.dimension
+	&& !c->attr.codimension && (c->attr.allocatable || c->attr.pointer)
+	&& !derived->attr.is_class)
+	  {
+	/* Provide sufficient space to hold "_caf_symbol".  */
+	char caf_name[GFC_MAX_SYMBOL_LEN + 6];
+	gfc_component *token;
+	snprintf (caf_name, sizeof (caf_name), "_caf_%s", c->name);
+	token = gfc_find_component (derived, caf_name, true, true, NULL);
+	gcc_assert (token);
+	c->caf_token = token->backend_decl;
+	suppress_warning (c->caf_token);
+	  }
+  }

   for (gfc_symbol *dt = gfc_derived_types; dt; dt = dt->dt_next)
 {
diff --git a/gcc/testsuite/gfortran.dg/coarray/add_sources/submodule_2_mod.f90 b/gcc/testsuite/gfortran.dg/coarray/add_sources/submodule_2_mod.f90
new file mode 100644
index 000..b0d79565fe5
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/coarray/add_sources/submodule_2_mod.f90
@@ -0,0 +1,14 @@
+module surfaces_interface
+  type package
+  end type
+
+  type surfaces
+class(package), allocatable  :: halo_data
+  end type
+
+  interface
+module subroutine set_halo_data()
+end subroutine
+  end interface
+end module
+
diff --git a/gcc/testsuite/gfortran.dg/coarray/submodule_2.f90 b/gcc/testsuite/gfortran.dg/coarray/submodule_2.f90
new file mode 100644
index 000..663dac67d67
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/coarray/submodule_2.f90
@@ -0,0 +1,14 @@
+!{ dg-do compile }
+!{ dg-compile-aux-modules add_sources/submodule_2_mod.f90 }
+
+! Contributed by Damian Rouson  
+! Check PR93158 is fixed.
+
+submodule(surfaces_interface) surfaces_implementation
+  type(surfaces) singleton[*]
+contains
+  module procedure set_halo_data
+stop 0
+  end procedure
+end submodule
+
--
2.46.1



[PATCH] doc: Remove variables from fortran options in index

2024-09-26 Thread Mikael Morin
From: Mikael Morin 

With this change, -ffixed-line-length-n and -ffree-line-length-n are the
only remaining options with variables appearing in the index.  But I
think they are better left as-is.

I refrained from adding the missing syntactic variant in the
documentation of options allowing both separate and joined argument
(like -I foo and -Ifoo), as that would have been less consistent.

Checked with make html pdf, and visually checking the affected options,
both in the index and on the options pages.
OK for master?

-- >8 --

Remove variables from the fortran option index to improve consistency
and URL recognition by the regenerate-opt-urls.py script.

For options matching -foo=arg, only keep foo in the index.  About half of
the options were already this way, the other half having the argument
appearing in the index.  Always keeping the =arg suffix in the index was
another possibility, but the user benefit doesn't seem high, it would be
worse regarding URL recognition, and the rest of the compiler documentation
prefers stripping the suffix.

For single-letter joined options (-Sfoo with S in A, D, U, I), only keep the
single letter.  The pros and cons of keeping or dropping the suffix are the
same as in the previous case.  For the user, the benefit of keeping the
variable would be slightly higher maybe, but as there is no other option
starting with the single letter, there is no risk of confusion if the
variable is stripped).
Keeping only the single letter has the side effect of forcing the removal
of the separate indexing for options where there is some, namely
-Afoo=bar vs -A-foo=bar for A, and -Dfoo vs -Dfoo=bar for D.

gcc/fortran/ChangeLog:

* invoke.texi (-fmax-identifier-length, -std, -fmax-errors,
-ffpe-trap, -ffpe-summary, -fconvert, -frecord-marker,
-fmax-subrecord-length): Drop the =variable suffix in the index.
(-A, -D, -U, -I): Drop the variable suffix in the index.
(-A): Remove the separate indexing of assertion cancelation.
(-D): Remove the separate indexing of macros with definitions.
---
 gcc/fortran/invoke.texi | 28 
 1 file changed, 12 insertions(+), 16 deletions(-)

diff --git a/gcc/fortran/invoke.texi b/gcc/fortran/invoke.texi
index a9ac87d3a32..784d6115bfb 100644
--- a/gcc/fortran/invoke.texi
+++ b/gcc/fortran/invoke.texi
@@ -405,7 +405,7 @@ lines in the source file. The default value is 132.
 @option{-ffree-line-length-0} means the same thing as
 @option{-ffree-line-length-none}.
 
-@opindex fmax-identifier-length=@var{n}
+@opindex fmax-identifier-length
 @item -fmax-identifier-length=@var{n}
 Specify the maximum allowed identifier length. Typical values are
 31 (Fortran 95) and 63 (Fortran 2003 and later).
@@ -588,7 +588,7 @@ when passing a value to the @code{kind=} dummy argument.  
Inspection of the
 intermediate representation of the translated Fortran code, produced by
 @option{-fdump-fortran-original} or @option{-fdump-tree-original}, is 
suggested.
 
-@opindex std=@var{std}
+@opindex std
 @item -std=@var{std}
 Specify the standard to which the program is expected to conform,
 which may be one of @samp{f95}, @samp{f2003}, @samp{f2008}, @samp{f2018},
@@ -803,15 +803,13 @@ directory of the current file, if appropriate) are 
searched.
 Do not predefine any system-specific or GCC-specific macros.
 The standard predefined macros remain defined.
 
-@opindex A@var{predicate}=@var{answer}
+@opindex A
 @cindex preprocessing, assertion
 @item -A@var{predicate}=@var{answer}
 Make an assertion with the predicate @var{predicate} and answer @var{answer}.
 This form is preferred to the older form -A predicate(answer), which is still
 supported, because it does not use shell special characters.
 
-@opindex A-@var{predicate}=@var{answer}
-@cindex preprocessing, assertion
 @item -A-@var{predicate}=@var{answer}
 Cancel an assertion with the predicate @var{predicate} and answer @var{answer}.
 
@@ -847,13 +845,11 @@ is generally used to support lint comments.
 Warning: this currently handles C- and C++-Style comments only. The
 preprocessor does not yet recognize Fortran-style comments.
 
-@opindex D@var{name}
+@opindex D
 @cindex preprocessing, define macros
 @item -D@var{name}
 Predefine name as a macro, with definition @code{1}.
 
-@opindex D@var{name}=@var{definition}
-@cindex preprocessing, define macros
 @item -D@var{name}=@var{definition}
 The contents of @var{definition} are tokenized and processed as if they
 appeared during translation phase three in a @code{'#define'} directive.
@@ -888,7 +884,7 @@ This might be useful when running the preprocessor on 
something that
 is not C code, and will be sent to a program which might be confused
 by the linemarkers.
 
-@opindex U@var{name}
+@opindex U
 @cindex preprocessing, undefine macros
 @item -U@var{name}
 Cancel any previous definition of @var{name}, either built in or provided
@@ -926,7 +922,7 @@ These options control the amount and kinds of errors and 
warnings 

Re: [PATCH] gfortran testsuite: Remove unit-files in files having open-statements, PR116701

2024-09-26 Thread rep . dot . nop
On 25 September 2024 22:08:15 CEST, rep.dot@gmail.com wrote:
>
>>Your interpretation of my typo is correct.  Along with Andre I like auto 
>>cleanup. On new test cases we try to have them self delete whether they pass 
>>or fail.
>>
>
>so why don't we issue the cleanup then, regardless?



>
>>So your changes are ok with me.




Fwd: [patch, fortran] Matmul and dot_product for unsigned

2024-09-26 Thread Thomas Koenig

[I just saw I hit the wrong reply button on this]

Hi Andre,


thanks for your answers. I am ok with the patch.


I have committed all four patches.

Thanks a lot for the reviews!

Now for the remaining intrinsics (FINDLOC, MAXLOC,
MINLOC, MAXVAL, MINVAL, CSHIFT and EOSHIFT still missing).

And after that, C interop, one of the main reasons this
was requested.

I have also committed, right now, a fix for the failure of
unsigned_25.f90 on 32-bit systems as obvious.

Best regards

Thomas

Author: Thomas Koenig 
Date:   Wed Sep 25 18:51:48 2024 +0200

Fix testsuite failure on 32-bit targets.

gcc/testsuite/ChangeLog:

* gfortran.dg/unsigned_25.f90: Change KIND=16 to KIND=8.


diff --git a/gcc/testsuite/gfortran.dg/unsigned_25.f90 
b/gcc/testsuite/gfortran.dg/unsigned_25.f90

index f6144988d82..0cd86b093bb 100644
--- a/gcc/testsuite/gfortran.dg/unsigned_25.f90
+++ b/gcc/testsuite/gfortran.dg/unsigned_25.f90
@@ -27,9 +27,9 @@ contains
  5u, uint(-6), 7u, uint(-8), 9u],[3,3])
 unsigned, parameter :: v(3,3) = 1u - u
 unsigned, parameter :: w(3,3) = matmul(u,v)
-integer(kind=16), dimension(3,3), parameter :: &
- i = int(u,16), j = int(v,16)
-integer(kind=16), dimension(3,3) :: k = matmul(i,j)
+integer(kind=8), dimension(3,3), parameter :: &
+ i = int(u,8), j = int(v,8)
+integer(kind=8), dimension(3,3) :: k = matmul(i,j)
 if (any(uint(k) /= w)) error stop 2
   end subroutine test2
 end program memain



[committed] testsuite/gfortran.dg/open_errors_2.f90: Remove now-redundant file deletion

2024-09-26 Thread Hans-Peter Nilsson
Only because I wrote earlier that I'd do this patch.

Committed as obvious.  Sanity-checked by running the test in
a native tree as "make check-gcc-fortran
RUNTESTFLAGS=dg.exp=open_errors_2.f90"

-- >8 --
Now that fort.N files are removed by the testsuite
framework, remove this single "manual" file deletion.
(Also, it should have been "remote_file target delete",
since it's the target that creates the file, not the build
framework, which might matter to some setups.)

* gfortran.dg/open_errors_2.f90: Remove now-redundant file deletion.
---
 gcc/testsuite/gfortran.dg/open_errors_2.f90 | 1 -
 1 file changed, 1 deletion(-)

diff --git a/gcc/testsuite/gfortran.dg/open_errors_2.f90 
b/gcc/testsuite/gfortran.dg/open_errors_2.f90
index 72d63bb3a39f..dbe9112bc6fd 100644
--- a/gcc/testsuite/gfortran.dg/open_errors_2.f90
+++ b/gcc/testsuite/gfortran.dg/open_errors_2.f90
@@ -16,4 +16,3 @@
   rewind(522)
   close(522)
 end program
-! { dg-final { remote_file build delete "fort.345" } }
-- 
2.30.2



Re: Fwd: [patch, fortran] Matmul and dot_product for unsigned

2024-09-26 Thread rep . dot . nop
.

>
>I have also committed, right now, a fix for the failure of
>unsigned_25.f90 on 32-bit systems as obvious.

could we maybe walk all sizes, if they fit, according to the preprocessor?

>
>Best regards
>