public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH, committed] Fortran: fix parsing of omp task affinity iterator clause [PR101330]
@ 2022-07-20 18:51 Harald Anlauf
  0 siblings, 0 replies; only message in thread
From: Harald Anlauf @ 2022-07-20 18:51 UTC (permalink / raw)
  To: fortran, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 433 bytes --]

Dear all,

there was some left-over code - likely from development - that could
lead to a compiler segfault when given invalid input.  Steve found
the offending line.  Removing it solves the issue.

The fix was acknowledged by Tobias in the PR.

Regtested on x86_64-pc-linux-gnu.

Pushed as: r13-1767-g26bbe78f77f73bb66af1ac13d0deec888a3c6510

Will backport to 12-branch, as the offending code was introduced there.

Thanks,
Harald


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: pr101330.diff --]
[-- Type: text/x-patch, Size: 2198 bytes --]

From 26bbe78f77f73bb66af1ac13d0deec888a3c6510 Mon Sep 17 00:00:00 2001
From: Harald Anlauf <anlauf@gmx.de>
Date: Wed, 20 Jul 2022 20:40:23 +0200
Subject: [PATCH] Fortran: fix parsing of omp task affinity iterator clause
 [PR101330]

gcc/fortran/ChangeLog:

	PR fortran/101330
	* openmp.cc (gfc_match_iterator): Remove left-over code from
	development that could lead to a crash on invalid input.

gcc/testsuite/ChangeLog:

	PR fortran/101330
	* gfortran.dg/gomp/affinity-clause-7.f90: New test.
---
 gcc/fortran/openmp.cc                         |  1 -
 .../gfortran.dg/gomp/affinity-clause-7.f90    | 19 +++++++++++++++++++
 2 files changed, 19 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/gfortran.dg/gomp/affinity-clause-7.f90

diff --git a/gcc/fortran/openmp.cc b/gcc/fortran/openmp.cc
index bd4ff259fe0..df9cdf43eb7 100644
--- a/gcc/fortran/openmp.cc
+++ b/gcc/fortran/openmp.cc
@@ -1181,7 +1181,6 @@ gfc_match_iterator (gfc_namespace **ns, bool permit_var)
 	}
       if (':' == gfc_peek_ascii_char ())
 	{
-	  step = gfc_get_expr ();
 	  if (gfc_match (": %e ", &step) != MATCH_YES)
 	    {
 	      gfc_free_expr (begin);
diff --git a/gcc/testsuite/gfortran.dg/gomp/affinity-clause-7.f90 b/gcc/testsuite/gfortran.dg/gomp/affinity-clause-7.f90
new file mode 100644
index 00000000000..5b1ca85aba3
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/affinity-clause-7.f90
@@ -0,0 +1,19 @@
+! { dg-do compile }
+! PR fortran/101330 - ICE in free_expr0(): Bad expr type
+! Contributed by G.Steinmetz
+
+  implicit none
+  integer :: j, b(10)
+!$omp task affinity (iterator(j=1:2:1) : b(j))
+!$omp end task
+!$omp task affinity (iterator(j=1:2:) : b(j)) ! { dg-error "Invalid character" }
+!!$omp end task
+!$omp task affinity (iterator(j=1:2:          ! { dg-error "Invalid character" }
+!!$omp end task
+!$omp task affinity (iterator(j=1:2:)         ! { dg-error "Invalid character" }
+!!$omp end task
+!$omp task affinity (iterator(j=1:2::)        ! { dg-error "Invalid character" }
+!!$omp end task
+!$omp task affinity (iterator(j=1:2:))        ! { dg-error "Invalid character" }
+!!$omp end task
+end
--
2.35.3


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-07-20 18:51 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-20 18:51 [PATCH, committed] Fortran: fix parsing of omp task affinity iterator clause [PR101330] Harald Anlauf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).