FYI: Conversion from TexInfo (.texi) to Sphinx/ReStructuredText (rst)

2021-06-04 Thread Tobias Burnus

Hi Fortraners,

as it was mostly discussed at gcc@ and gcc-patches@,
there are plans to move to .rst and process it with Sphinx
instead of .texi (TexInfo) for the GCC documentation.

* Sphinx: https://www.sphinx-doc.org/en/master/
* RST: https://docutils.sourceforge.io/rst.html

Autoconversion result of the GCC files:
* https://splichal.eu/scripts/sphinx/

Discussion at gcc@ / gcc-patches@:
* https://gcc.gnu.org/pipermail/gcc/2021-June/thread.html#236172
* https://gcc.gnu.org/pipermail/gcc/2021-May/thread.html#236043
  + https://gcc.gnu.org/pipermail/gcc/2021-June/236265.html

Cheers,

Tobias

-
Mentor Graphics (Deutschland) GmbH, Arnulfstrasse 201, 80634 München 
Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Frank 
Thürauf


[committed] gfortran.dg/gomp/pr99928-*.f90: Use implicit none, remove one xfail

2021-06-04 Thread Tobias Burnus

This adds a bunch of 'implicit none' to the testcases,
a missing 'integer i' and fixes a typo in a loop variable,
which permitted to remove an xfail.

Currently, there are two classes of xfail:
* !$omp parallel master taskloop (simd)
  → parallel misses shared(...)
for firstprivate/lastprivate/reduction variable
* !$omp target ...
  → Missing 'map(tofrom:'
for firstprivate/lastprivate/reduction
  → Wrong firstprivate in that case

Committed as r12-1210-g78b622e37381e1c0e9992f6634972dfbe0338d0b

Tobias

-
Mentor Graphics (Deutschland) GmbH, Arnulfstrasse 201, 80634 München 
Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Frank 
Thürauf
commit 78b622e37381e1c0e9992f6634972dfbe0338d0b
Author: Tobias Burnus 
Date:   Fri Jun 4 13:10:57 2021 +0200

gfortran.dg/gomp/pr99928-*.f90: Use implicit none, remove one xfail

gcc/testsuite/ChangeLog:

* gfortran.dg/gomp/pr99928-1.f90: Add 'implicit none'.
* gfortran.dg/gomp/pr99928-11.f90: Likewise.
* gfortran.dg/gomp/pr99928-4.f90: Likewise.
* gfortran.dg/gomp/pr99928-6.f90: Likewise.
* gfortran.dg/gomp/pr99928-8.f90: Likewise.
* gfortran.dg/gomp/pr99928-2.f90: Likewise. Add missing decl.
* gfortran.dg/gomp/pr99928-5.f90: Add implicit none;
fix loop-variable and remove xfail.

diff --git a/gcc/testsuite/gfortran.dg/gomp/pr99928-1.f90 b/gcc/testsuite/gfortran.dg/gomp/pr99928-1.f90
index 5cbffb09b3f..e5be42fba53 100644
--- a/gcc/testsuite/gfortran.dg/gomp/pr99928-1.f90
+++ b/gcc/testsuite/gfortran.dg/gomp/pr99928-1.f90
@@ -3,6 +3,7 @@
 ! { dg-options "-fopenmp -fdump-tree-gimple" }
 
 module m
+  implicit none
   integer :: f00, f01, f02, f03, f04, f05, f06, f07, f08, f09
   integer :: f12, f13, f14, f15, f16, f17, f18, f19
   integer :: f20, f21, f22, f23, f24, f25, f26, f27, f28, f29
diff --git a/gcc/testsuite/gfortran.dg/gomp/pr99928-11.f90 b/gcc/testsuite/gfortran.dg/gomp/pr99928-11.f90
index 864ae4b6c99..22a40e2b49c 100644
--- a/gcc/testsuite/gfortran.dg/gomp/pr99928-11.f90
+++ b/gcc/testsuite/gfortran.dg/gomp/pr99928-11.f90
@@ -3,6 +3,7 @@
 ! { dg-options "-fopenmp -fdump-tree-gimple" }
 
 module m
+  implicit none
   integer :: r00, r01, r02
 
 contains
diff --git a/gcc/testsuite/gfortran.dg/gomp/pr99928-2.f90 b/gcc/testsuite/gfortran.dg/gomp/pr99928-2.f90
index 5dbf78ba291..fe8a715279a 100644
--- a/gcc/testsuite/gfortran.dg/gomp/pr99928-2.f90
+++ b/gcc/testsuite/gfortran.dg/gomp/pr99928-2.f90
@@ -3,12 +3,14 @@
 ! { dg-options "-fopenmp -fdump-tree-gimple" }
 
 module m
+  implicit none
   integer :: l00, l01, l02, l03, l04, l05, l06, l07
   integer :: l10, l11, l12, l13, l14, l15, l16, l17, l18
 
 contains
 
 subroutine foo ()
+  integer :: i
   ! { dg-final { scan-tree-dump "omp distribute\[^\n\r]*lastprivate\\(l00\\)" "gimple" } }
   ! { dg-final { scan-tree-dump "omp parallel\[^\n\r]*lastprivate\\(l00\\)" "gimple" } } ! FIXME: This should be on for instead. 
   ! { dg-final { scan-tree-dump-not "omp for\[^\n\r]*lastprivate\\(l00\\)" "gimple" } } ! FIXME. 
diff --git a/gcc/testsuite/gfortran.dg/gomp/pr99928-4.f90 b/gcc/testsuite/gfortran.dg/gomp/pr99928-4.f90
index 5b82dd6581c..ead8f030e63 100644
--- a/gcc/testsuite/gfortran.dg/gomp/pr99928-4.f90
+++ b/gcc/testsuite/gfortran.dg/gomp/pr99928-4.f90
@@ -3,6 +3,7 @@
 ! { dg-options "-fopenmp -fdump-tree-gimple" }
 
 module m
+  implicit none
   integer :: l00, l01, l05, l06, l07, l08
 
 contains
diff --git a/gcc/testsuite/gfortran.dg/gomp/pr99928-5.f90 b/gcc/testsuite/gfortran.dg/gomp/pr99928-5.f90
index 9f45e48feb4..c612aaf9556 100644
--- a/gcc/testsuite/gfortran.dg/gomp/pr99928-5.f90
+++ b/gcc/testsuite/gfortran.dg/gomp/pr99928-5.f90
@@ -3,6 +3,7 @@
 ! { dg-options "-fopenmp -fdump-tree-gimple" }
 
 module m
+  implicit none
   integer :: j00, j01, j02, j03, j04, j06, j07, j08, j09
   integer :: j10
 
@@ -85,9 +86,9 @@ subroutine bar ()
   end do
   ! { dg-final { scan-tree-dump "omp taskloop\[^\n\r]*shared\\(j10\\)" "gimple" } } ! NOTE: This is implementation detail. 
   ! { dg-final { scan-tree-dump "omp taskloop\[^\n\r]*lastprivate\\(j10\\)" "gimple" } }
-  ! { dg-final { scan-tree-dump "omp simd\[^\n\r]*linear\\(j10:1\\)" "gimple" { xfail *-*-* } } }
+  ! { dg-final { scan-tree-dump "omp simd\[^\n\r]*linear\\(j10:1\\)" "gimple" } }
   !$omp taskloop simd linear (j10) default(none)
-  do j010 = 1, 64
+  do j01 = 1, 64
   end do
   ! { dg-final { scan-tree-dump "omp teams\[^\n\r]*shared\\(j11\\)" "gimple" } }
   ! { dg-final { scan-tree-dump "omp distribute\[^\n\r]*lastprivate\\(j11\\)" "gimple" } }
diff --git a/gcc/testsuite/gfortran.dg/gomp/pr99928-6.f90 b/gcc/testsuite/gfortran.dg/gomp/pr99928-6.f90
index 37a93e6b1ac..0e60199476b 100644
--- a/gcc/testsuite/gfortran.dg/gomp/pr99928-6.f90
+++ b/gcc/testsuite/gfortran.dg/gomp/pr99928-6.f90
@@ -3,6 +3,7 @@
 ! { dg-options "-fopenmp -fdump-tree-gimple" }
 
 module m
+  implicit none
   integer :: j00, j01, j02

Re: [committed] gfortran.dg/gomp/pr99928-*.f90: Use implicit none, remove one xfail

2021-06-04 Thread Tobias Burnus

On 04.06.21 13:20, Tobias Burnus wrote:


This adds a bunch of 'implicit none' to the testcases,
a missing 'integer i' and fixes a typo in a loop variable,
which permitted to remove an xfail.


Or actually it didn't, as I seemingly did a last-minute change in the
wrong way after running the testsuite or missed a 'git add' or ...  :-(

The xfail is fixed – but only with this follow-up commit
r12-1211-gad3f0ad4bafe377072a53ded468fd9948e659f46.

Tobias

-
Mentor Graphics (Deutschland) GmbH, Arnulfstrasse 201, 80634 München 
Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Frank 
Thürauf
commit ad3f0ad4bafe377072a53ded468fd9948e659f46
Author: Tobias Burnus 
Date:   Fri Jun 4 13:26:40 2021 +0200

gfortran.dg/gomp/pr99928-5.f90: Use proper iteration var

gcc/testsuite/ChangeLog:

* gfortran.dg/gomp/pr99928-5.f90: Really use the
proper iteration variable.

diff --git a/gcc/testsuite/gfortran.dg/gomp/pr99928-5.f90 b/gcc/testsuite/gfortran.dg/gomp/pr99928-5.f90
index c612aaf9556..49cbf1e8cc2 100644
--- a/gcc/testsuite/gfortran.dg/gomp/pr99928-5.f90
+++ b/gcc/testsuite/gfortran.dg/gomp/pr99928-5.f90
@@ -90,3 +90,3 @@ subroutine bar ()
   !$omp taskloop simd linear (j10) default(none)
-  do j01 = 1, 64
+  do j10 = 1, 64
   end do


Re: [Patch, fortran] PR fortran/100120/100816/100818/100819/100821 problems raised by aggregate data types

2021-06-04 Thread Paul Richard Thomas via Fortran
Hi José,

I can second Dominique's thanks. I applied it to my tree when you first
posted, set the regtest in motion and have not been able to return to
gfortran matters since.

OK for master.

I am especially happy that you have tackled this area and have rationalised
it to a substantial degree. The wheel keeps being re-invented by different
people, largely for a lack of documentation or coherent self-documentation.
I know, as one of the guilty ones.

Regards

Paul


On Thu, 3 Jun 2021 at 16:05, dhumieres.dominique--- via Fortran <
fortran@gcc.gnu.org> wrote:

> Hi José,
>
> > Patch tested only on x86_64-pc-linux-gnu.
>
> Also tested on darwin20. The patch is OK for me.
>
> Thanks for the work,
>
> Dominique
>


-- 
"If you can't explain it simply, you don't understand it well enough" -
Albert Einstein


[Patch] Fortran: Fix OpenMP/OpenACC continue-line parsing

2021-06-04 Thread Tobias Burnus

Hi all, hi Jakub & Thomas,

I did run into this issue with the previous patch where

!$omp  parallel &
!$acc& loop

did no longer report an error – hence, I changed 'loop' to 'kernels loop'
as buffered 'gfc_error' might not be output.

Having no error is very unfortunate.
There is no ideal solution for the problem, but I think the
attached patch makes sense.

I now include the original version besides the patch version of
the 'parallel' / '(kernels )loop' test.


This patch now does:

* For Fortran's free source form:
  - use 'gfc_error_now' to ensure an error is printed
  - cache the error location such that the same error is not
shown multiple times
  - Return '\n' to avoid parsing the code again.

* For Fortran's fixed source form:
  - Likewise
Except:
!$OMP  ...
!$ACC  ...
Here, '!$ACC ' is not a continuation line! Not even when
placing a '&' in column > 72 (as those columns are ignored).
Thus, handle this !$ACC as separate statement.


SIDE EFFECT: Due to returning '\n', the parsing of
 !$OMP parallel &
 !$ACC LOOP
now succeeds: '!$OMP parallel' + '!$ACC LOOP' - such that
the rest of the syntax/semantic rules apply.

Thus, (after printing the gfc_error_now), gfortran continues and
- there is now the resolution-time error about invalid nesting of OMP/ACC
- the '!$OMP parallel' now requires an '!$OMP end parallel' to avoid
  parsing errors.


OK? More comments?

Tobias

-
Mentor Graphics (Deutschland) GmbH, Arnulfstrasse 201, 80634 München 
Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Frank 
Thürauf
Fortran: Fix OpenMP/OpenACC continue-line parsing

gcc/fortran/ChangeLog:

	* scanner.c (skip_fixed_omp_sentinel): Set openacc_flag if
	this is not an (OpenMP) continuation line.
	(skip_fixed_oacc_sentinel): Likewise for openmp_flag and OpenACC.
	(gfc_next_char_literal): gfc_error_now to force error for mixed OMP/ACC
	continuation once per location and return '\n'.

gcc/testsuite/ChangeLog:

	* gfortran.dg/goacc/omp-fixed.f: Re-add test item changed in previous
	commit in addition - add more dg-errors and '... end ...' due to changed
	parsing.
	* gfortran.dg/goacc/omp.f95: Likewise.
	* gfortran.dg/goacc-gomp/mixed-1.f: New test.

 gcc/fortran/scanner.c  | 35 +-
 gcc/testsuite/gfortran.dg/goacc-gomp/mixed-1.f | 23 +
 gcc/testsuite/gfortran.dg/goacc/omp-fixed.f| 10 +++-
 gcc/testsuite/gfortran.dg/goacc/omp.f95| 12 +
 4 files changed, 67 insertions(+), 13 deletions(-)

diff --git a/gcc/fortran/scanner.c b/gcc/fortran/scanner.c
index 74c5461ed6f..39db0994b62 100644
--- a/gcc/fortran/scanner.c
+++ b/gcc/fortran/scanner.c
@@ -942,6 +942,8 @@ skip_fixed_omp_sentinel (locus *start)
 	  && (continue_flag
 	  || c == ' ' || c == '\t' || c == '0'))
 	{
+	  if (c == ' ' || c == '\t' || c == '0')
+	openacc_flag = 0;
 	  do
 	c = next_char ();
 	  while (gfc_is_whitespace (c));
@@ -971,6 +973,8 @@ skip_fixed_oacc_sentinel (locus *start)
 	  && (continue_flag
 	  || c == ' ' || c == '\t' || c == '0'))
 	{
+	  if (c == ' ' || c == '\t' || c == '0')
+	openmp_flag = 0;
 	  do
 	c = next_char ();
 	  while (gfc_is_whitespace (c));
@@ -1205,6 +1209,7 @@ gfc_skip_comments (void)
 gfc_char_t
 gfc_next_char_literal (gfc_instring in_string)
 {
+  static locus omp_acc_err_loc = {};
   locus old_loc;
   int i, prev_openmp_flag, prev_openacc_flag;
   gfc_char_t c;
@@ -1403,14 +1408,16 @@ restart:
 	{
 	  if (gfc_wide_tolower (c) != (unsigned char) "!$acc"[i])
 		is_openmp = 1;
-	  if (i == 4)
-		old_loc = gfc_current_locus;
 	}
-	  gfc_error (is_openmp
-		 ? G_("Wrong OpenACC continuation at %C: "
-			  "expected !$ACC, got !$OMP")
-		 : G_("Wrong OpenMP continuation at %C: "
-			  "expected !$OMP, got !$ACC"));
+	  if (omp_acc_err_loc.nextc != gfc_current_locus.nextc
+	  || omp_acc_err_loc.lb != gfc_current_locus.lb)
+	gfc_error_now (is_openmp
+			   ? G_("Wrong OpenACC continuation at %C: "
+"expected !$ACC, got !$OMP")
+			   : G_("Wrong OpenMP continuation at %C: "
+"expected !$OMP, got !$ACC"));
+	  omp_acc_err_loc = gfc_current_locus;
+	  goto not_continuation;
 	}
 
   if (c != '&')
@@ -1511,11 +1518,15 @@ restart:
 	  if (gfc_wide_tolower (c) != (unsigned char) "*$acc"[i])
 		is_openmp = 1;
 	}
-	  gfc_error (is_openmp
-		 ? G_("Wrong OpenACC continuation at %C: "
-			  "expected !$ACC, got !$OMP")
-		 : G_("Wrong OpenMP continuation at %C: "
-			  "expected !$OMP, got !$ACC"));
+	  if (omp_acc_err_loc.nextc != gfc_current_locus.nextc
+	  || omp_acc_err_loc.lb != gfc_current_locus.lb)
+	gfc_error_now (is_openmp
+			   ? G_("Wrong OpenACC continuation at %C: "
+"expected !$ACC, got !$OMP")
+			   : G_("Wrong OpenMP continuation at %C: "
+"expected !$OMP, got !$ACC"));
+	  omp_acc_err_loc = gfc_current_locus;
+	  goto not_continuation;
 	}
   else if (!openmp_flag && !openacc_flag)
 	for (i = 0; 

Re: [Patch] Fortran: Fix OpenMP/OpenACC continue-line parsing

2021-06-04 Thread Jakub Jelinek via Fortran
On Fri, Jun 04, 2021 at 05:28:37PM +0200, Tobias Burnus wrote:
> Fortran: Fix OpenMP/OpenACC continue-line parsing
> 
> gcc/fortran/ChangeLog:
> 
>   * scanner.c (skip_fixed_omp_sentinel): Set openacc_flag if
>   this is not an (OpenMP) continuation line.
>   (skip_fixed_oacc_sentinel): Likewise for openmp_flag and OpenACC.
>   (gfc_next_char_literal): gfc_error_now to force error for mixed OMP/ACC
>   continuation once per location and return '\n'.
> 
> gcc/testsuite/ChangeLog:
> 
>   * gfortran.dg/goacc/omp-fixed.f: Re-add test item changed in previous
>   commit in addition - add more dg-errors and '... end ...' due to changed
>   parsing.
>   * gfortran.dg/goacc/omp.f95: Likewise.
>   * gfortran.dg/goacc-gomp/mixed-1.f: New test.

LGTM, thanks.

Jakub



Re: PING [PATCH] PR fortran/99839 - [9/10/11/12 Regression] ICE in inline_matmul_assign, at fortran/frontend-passes.c:4234

2021-06-04 Thread Paul Richard Thomas via Fortran
Hi Harald,

Looks good to me - OK for as many branches as you have sufficient fortitude
for.

Regards

Paul


On Thu, 3 Jun 2021 at 21:22, Harald Anlauf via Fortran 
wrote:

> *PING*
>
> > Gesendet: Donnerstag, 27. Mai 2021 um 22:20 Uhr
> > Von: "Harald Anlauf" 
> > An: "fortran" , "gcc-patches" <
> gcc-patc...@gcc.gnu.org>
> > Betreff: [PATCH] PR fortran/99839 - [9/10/11/12 Regression] ICE in
> inline_matmul_assign, at fortran/frontend-passes.c:4234
> >
> > Dear Fortranners,
> >
> > frontend optimization tries to inline matmul, but then it also needs
> > to take care of the assignment to the result array.  If that one is
> > not of canonical type, we currently get an ICE.  The straightforward
> > solution is to simply punt in those cases and avoid inlining.
> >
> > Regtested on x86_64-pc-linux-gnu.
> >
> > OK for mainline?  Backport to affected branches?
> >
> > Thanks,
> > Harald
> >
> >
> > Fortran - ICE in inline_matmul_assign
> >
> > Restrict inlining of matmul to those cases where assignment to the
> > result array does not need special treatment.
> >
> > gcc/fortran/ChangeLog:
> >
> >   PR fortran/99839
> >   * frontend-passes.c (inline_matmul_assign): Do not inline matmul
> >   if the assignment to the resulting array if it is not of canonical
> >   type (real/integer/complex/logical).
> >
> > gcc/testsuite/ChangeLog:
> >
> >   PR fortran/99839
> >   * gfortran.dg/inline_matmul_25.f90: New test.
> >
> >
>


-- 
"If you can't explain it simply, you don't understand it well enough" -
Albert Einstein


[Ping, Patch, Fortran] PR100337 Should be able to pass non-present optional arguments to CO_BROADCAST

2021-06-04 Thread Andre Vehreschild via Fortran
Ping!

On Fri, 21 May 2021 15:33:11 +0200
Andre Vehreschild  wrote:

> Hi,
>
> the attached patch fixes an issue when calling CO_BROADCAST in
> -fcoarray=single mode, where the optional but non-present (in the calling
> scope) stat variable was assigned to before checking for it being not present.
>
> Regtests fine on x86-64-linux/f33. Ok for trunk?
>
> Regards,
>   Andre


--
Andre Vehreschild * Email: vehre ad gmx dot de
gcc/fortran/ChangeLog:

	PR fortran/100337
	* trans-intrinsic.c (conv_co_collective): Check stat for null ptr
	before dereferrencing.

gcc/testsuite/ChangeLog:

	PR fortran/100337
	* gfortran.dg/coarray_collectives_17.f90: New test.

diff --git a/gcc/fortran/trans-intrinsic.c b/gcc/fortran/trans-intrinsic.c
index 4d7451479d3..03a38090051 100644
--- a/gcc/fortran/trans-intrinsic.c
+++ b/gcc/fortran/trans-intrinsic.c
@@ -11232,8 +11232,28 @@ conv_co_collective (gfc_code *code)
   if (flag_coarray == GFC_FCOARRAY_SINGLE)
 {
   if (stat != NULL_TREE)
-	gfc_add_modify (&block, stat,
-			fold_convert (TREE_TYPE (stat), integer_zero_node));
+	{
+	  /* For optional stats, check the pointer is valid before zero'ing.  */
+	  if (gfc_expr_attr (stat_expr).optional)
+	{
+	  tree tmp;
+	  stmtblock_t ass_block;
+	  gfc_start_block (&ass_block);
+	  gfc_add_modify (&ass_block, stat,
+			  fold_convert (TREE_TYPE (stat),
+	integer_zero_node));
+	  tmp = fold_build2 (NE_EXPR, logical_type_node,
+ gfc_build_addr_expr (NULL_TREE, stat),
+ null_pointer_node);
+	  tmp = fold_build3 (COND_EXPR, void_type_node, tmp,
+ gfc_finish_block (&ass_block),
+ build_empty_stmt (input_location));
+	  gfc_add_expr_to_block (&block, tmp);
+	}
+	  else
+	gfc_add_modify (&block, stat,
+			fold_convert (TREE_TYPE (stat), integer_zero_node));
+	}
   return gfc_finish_block (&block);
 }

diff --git a/gcc/testsuite/gfortran.dg/coarray_collectives_17.f90 b/gcc/testsuite/gfortran.dg/coarray_collectives_17.f90
new file mode 100644
index 000..84a6645865e
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/coarray_collectives_17.f90
@@ -0,0 +1,42 @@
+! { dg-do run }
+! { dg-options "-fcoarray=single" }
+!
+! PR 100337
+! Test case inspired by code submitted by Brad Richardson
+
+program main
+implicit none
+
+integer, parameter :: MESSAGE = 42
+integer :: result
+
+call myco_broadcast(MESSAGE, result, 1)
+
+if (result /= MESSAGE) error stop 1
+contains
+subroutine myco_broadcast(m, r, source_image, stat, errmsg)
+integer, intent(in) :: m
+integer, intent(out) :: r
+integer, intent(in) :: source_image
+integer, intent(out), optional :: stat
+character(len=*), intent(inout), optional :: errmsg
+
+integer :: data_length
+
+data_length = 1
+
+call co_broadcast(data_length, source_image, stat, errmsg)
+
+if (present(stat)) then
+if (stat /= 0) return
+end if
+
+if (this_image() == source_image) then
+r = m
+end if
+
+call co_broadcast(r, source_image, stat, errmsg)
+end subroutine
+
+end program
+


[committed] Fortran/OpenMP: Fix -fdump-parse-tree for 'omp loop'

2021-06-04 Thread Tobias Burnus

Committed as r12-1220-gcb6e6d5faa3f817435b6f203226fa5969d7a7264

-
Mentor Graphics (Deutschland) GmbH, Arnulfstrasse 201, 80634 München 
Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Frank 
Thürauf
commit cb6e6d5faa3f817435b6f203226fa5969d7a7264
Author: Tobias Burnus 
Date:   Fri Jun 4 18:51:35 2021 +0200

Fortran/OpenMP: Fix -fdump-parse-tree for 'omp loop'

gcc/fortran/ChangeLog
* dump-parse-tree.c (show_code_node): Handle
EXEC_OMP_(TARGET_)(,PARALLEL_,TEAMS_)LOOP.

diff --git a/gcc/fortran/dump-parse-tree.c b/gcc/fortran/dump-parse-tree.c
index 8e2df736d8c..141101e699d 100644
--- a/gcc/fortran/dump-parse-tree.c
+++ b/gcc/fortran/dump-parse-tree.c
@@ -3214,6 +3214,7 @@ show_code_node (int level, gfc_code *c)
 case EXEC_OMP_DO:
 case EXEC_OMP_DO_SIMD:
 case EXEC_OMP_FLUSH:
+case EXEC_OMP_LOOP:
 case EXEC_OMP_MASTER:
 case EXEC_OMP_MASTER_TASKLOOP:
 case EXEC_OMP_MASTER_TASKLOOP_SIMD:
@@ -3221,6 +3222,7 @@ show_code_node (int level, gfc_code *c)
 case EXEC_OMP_PARALLEL:
 case EXEC_OMP_PARALLEL_DO:
 case EXEC_OMP_PARALLEL_DO_SIMD:
+case EXEC_OMP_PARALLEL_LOOP:
 case EXEC_OMP_PARALLEL_MASTER:
 case EXEC_OMP_PARALLEL_MASTER_TASKLOOP:
 case EXEC_OMP_PARALLEL_MASTER_TASKLOOP_SIMD:
@@ -3237,12 +3239,14 @@ show_code_node (int level, gfc_code *c)
 case EXEC_OMP_TARGET_PARALLEL:
 case EXEC_OMP_TARGET_PARALLEL_DO:
 case EXEC_OMP_TARGET_PARALLEL_DO_SIMD:
+case EXEC_OMP_TARGET_PARALLEL_LOOP:
 case EXEC_OMP_TARGET_SIMD:
 case EXEC_OMP_TARGET_TEAMS:
 case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE:
 case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO:
 case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD:
 case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_SIMD:
+case EXEC_OMP_TARGET_TEAMS_LOOP:
 case EXEC_OMP_TARGET_UPDATE:
 case EXEC_OMP_TASK:
 case EXEC_OMP_TASKGROUP:
@@ -3255,6 +3259,7 @@ show_code_node (int level, gfc_code *c)
 case EXEC_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO:
 case EXEC_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD:
 case EXEC_OMP_TEAMS_DISTRIBUTE_SIMD:
+case EXEC_OMP_TEAMS_LOOP:
 case EXEC_OMP_WORKSHARE:
   show_omp_node (level, c);
   break;


[PATCH] PR fortran/95502 - ICE in gfc_check_do_variable, at fortran/parse.c:4446

2021-06-04 Thread Harald Anlauf via Fortran
ICE-on-invalid issues during error recovery.  Testcase by Gerhard,
initial patch by Steve.  I found another variant which needed an
additional fix for a NULL pointer dereference.

Regtested on x86_64-pc-linux-gnu.

OK for mainline / 11-branch?

Thanks,
Harald


Fortran - ICE in gfc_check_do_variable, at fortran/parse.c:4446

Avoid NULL pointer dereferences during error recovery.

gcc/fortran/ChangeLog:

PR fortran/95502
* expr.c (gfc_check_pointer_assign): Avoid NULL pointer
dereference.
* match.c (gfc_match_pointer_assignment): Likewise.
* parse.c (gfc_check_do_variable): Avoid comparison with NULL
symtree.

gcc/testsuite/ChangeLog:

PR fortran/95502
* gfortran.dg/pr95502.f90: New test.

diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c
index 956003ec605..b11ae7ce5c5 100644
--- a/gcc/fortran/expr.c
+++ b/gcc/fortran/expr.c
@@ -3815,6 +3815,9 @@ gfc_check_pointer_assign (gfc_expr *lvalue, gfc_expr *rvalue,
   int proc_pointer;
   bool same_rank;

+  if (!lvalue->symtree)
+return false;
+
   lhs_attr = gfc_expr_attr (lvalue);
   if (lvalue->ts.type == BT_UNKNOWN && !lhs_attr.proc_pointer)
 {
diff --git a/gcc/fortran/match.c b/gcc/fortran/match.c
index 29462013038..d148de3e3b5 100644
--- a/gcc/fortran/match.c
+++ b/gcc/fortran/match.c
@@ -1409,7 +1409,7 @@ gfc_match_pointer_assignment (void)
   gfc_matching_procptr_assignment = 0;

   m = gfc_match (" %v =>", &lvalue);
-  if (m != MATCH_YES)
+  if (m != MATCH_YES || !lvalue->symtree)
 {
   m = MATCH_NO;
   goto cleanup;
diff --git a/gcc/fortran/parse.c b/gcc/fortran/parse.c
index 0522b391393..6d7845e8517 100644
--- a/gcc/fortran/parse.c
+++ b/gcc/fortran/parse.c
@@ -4588,6 +4588,9 @@ gfc_check_do_variable (gfc_symtree *st)
 {
   gfc_state_data *s;

+  if (!st)
+return 0;
+
   for (s=gfc_state_stack; s; s = s->previous)
 if (s->do_variable == st)
   {
diff --git a/gcc/testsuite/gfortran.dg/pr95502.f90 b/gcc/testsuite/gfortran.dg/pr95502.f90
new file mode 100644
index 000..d40fd9a5508
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr95502.f90
@@ -0,0 +1,8 @@
+! { dg-do compile }
+! PR fortran/95502 - ICE in gfc_check_do_variable, at fortran/parse.c:4446
+
+program p
+  integer, pointer :: z
+  nullify (z%kind)  ! { dg-error "in variable definition context" }
+  z%kind => NULL()  ! { dg-error "constant expression" }
+end


GFortran

2021-06-04 Thread afshin zaheri via Fortran
Hello, my name is Afshin Zaheri. I am a Phd. Student in Kharazmi University
of Tehran. I would like to know that if Gfortran is Compliant with Fortran
2018?