public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/omp/gcc-12] Fortran: Extend align-clause checks of OpenMP's allocate directive
@ 2023-02-01 14:28 Tobias Burnus
  0 siblings, 0 replies; only message in thread
From: Tobias Burnus @ 2023-02-01 14:28 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:23f2f065bf051ec7dd0e32bb60d4cdd707c501e9

commit 23f2f065bf051ec7dd0e32bb60d4cdd707c501e9
Author: Tobias Burnus <tobias@codesourcery.com>
Date:   Wed Feb 1 15:27:42 2023 +0100

    Fortran: Extend align-clause checks of OpenMP's allocate directive
    
    gcc/fortran/ChangeLog:
    
            * openmp.cc (resolve_omp_clauses): Check also for
            power of two.
    
    libgomp/ChangeLog:
    
            * testsuite/libgomp.fortran/allocate-3.f90: Fix ALIGN
            usage, remove unused -fdump-tree-original.
            * testsuite/libgomp.fortran/allocate-4.f90: New.
    
    (cherry picked from commit bf2cf6f3f1851054237ee7df99bdf60bf5a3e3ae)

Diff:
---
 gcc/fortran/ChangeLog.omp                        |  8 +++++
 gcc/fortran/openmp.cc                            |  9 ++---
 libgomp/ChangeLog.omp                            |  9 +++++
 libgomp/testsuite/libgomp.fortran/allocate-3.f90 |  4 +--
 libgomp/testsuite/libgomp.fortran/allocate-4.f90 | 42 ++++++++++++++++++++++++
 5 files changed, 66 insertions(+), 6 deletions(-)

diff --git a/gcc/fortran/ChangeLog.omp b/gcc/fortran/ChangeLog.omp
index 4450c067d87..a7e44234d2f 100644
--- a/gcc/fortran/ChangeLog.omp
+++ b/gcc/fortran/ChangeLog.omp
@@ -1,3 +1,11 @@
+2023-02-01  Tobias Burnus  <tobias@codesourcery.com>
+
+	Backported from master:
+	2023-01-23  Tobias Burnus  <tobias@codesourcery.com>
+
+	* openmp.cc (resolve_omp_clauses): Check also for
+	power of two.
+
 2023-01-16  Tobias Burnus  <tobias@codesourcery.com>
 
 	Backported from master:
diff --git a/gcc/fortran/openmp.cc b/gcc/fortran/openmp.cc
index 7679dbef088..7cc54bb05df 100644
--- a/gcc/fortran/openmp.cc
+++ b/gcc/fortran/openmp.cc
@@ -8183,11 +8183,12 @@ resolve_omp_clauses (gfc_code *code, gfc_omp_clauses *omp_clauses,
 	      || n->u.align->ts.type != BT_INTEGER
 	      || n->u.align->rank != 0
 	      || gfc_extract_int (n->u.align, &alignment)
-	      || alignment <= 0)
+	      || alignment <= 0
+	      || !pow2p_hwi (alignment))
 	    {
-	      gfc_error ("ALIGN modifier requires a scalar positive "
-			 "constant integer alignment expression at %L",
-			 &n->u.align->where);
+	      gfc_error ("ALIGN modifier requires at %L a scalar positive "
+			 "constant integer alignment expression that is a "
+			 "power of two", &n->u.align->where);
 	      break;
 	    }
 	}
diff --git a/libgomp/ChangeLog.omp b/libgomp/ChangeLog.omp
index d91aaed3558..3d1cb16348a 100644
--- a/libgomp/ChangeLog.omp
+++ b/libgomp/ChangeLog.omp
@@ -1,3 +1,12 @@
+2023-02-01  Tobias Burnus  <tobias@codesourcery.com>
+
+	Backported from master:
+	2023-02-01  Tobias Burnus  <tobias@codesourcery.com>
+
+	* testsuite/libgomp.fortran/allocate-3.f90: Fix ALIGN
+	usage, remove unused -fdump-tree-original.
+	* testsuite/libgomp.fortran/allocate-4.f90: New.
+
 2023-01-26  Tobias Burnus  <tobias@codesourcery.com>
 
 	Backported from master:
diff --git a/libgomp/testsuite/libgomp.fortran/allocate-3.f90 b/libgomp/testsuite/libgomp.fortran/allocate-3.f90
index a39819164d6..1fa0bb932c3 100644
--- a/libgomp/testsuite/libgomp.fortran/allocate-3.f90
+++ b/libgomp/testsuite/libgomp.fortran/allocate-3.f90
@@ -1,5 +1,4 @@
 ! { dg-do compile }
-! { dg-additional-options "-fdump-tree-original" }
 
 use omp_lib
 implicit none
@@ -23,6 +22,7 @@ integer :: q, x,y,z
 ! { dg-error "Object 'omp_high_bw_mem_alloc' is not a variable" "" { target *-*-* } .-1 }
 !$omp end parallel
 
-!$omp parallel allocate( align(q) : x) firstprivate(x) ! { dg-error "31:ALIGN modifier requires a scalar positive constant integer alignment expression at" }
+!$omp parallel allocate( align(128) : x) firstprivate(x) ! OK
 !$omp end parallel
+
 end
diff --git a/libgomp/testsuite/libgomp.fortran/allocate-4.f90 b/libgomp/testsuite/libgomp.fortran/allocate-4.f90
new file mode 100644
index 00000000000..ddb507ba8e4
--- /dev/null
+++ b/libgomp/testsuite/libgomp.fortran/allocate-4.f90
@@ -0,0 +1,42 @@
+! { dg-do compile }
+
+
+subroutine test()
+use iso_c_binding, only: c_intptr_t
+implicit none
+integer, parameter :: omp_allocator_handle_kind = 1 !! <<<
+integer (kind=omp_allocator_handle_kind), &
+                 parameter :: omp_high_bw_mem_alloc = 4
+integer :: q, x,y,z
+integer, parameter :: cnst(2) = [64, 101]
+
+!$omp parallel allocate( omp_high_bw_mem_alloc : x)  firstprivate(x) ! { dg-error "Expected integer expression of the 'omp_allocator_handle_kind' kind" }
+!$omp end parallel
+
+!$omp parallel allocate( allocator (omp_high_bw_mem_alloc) : x)  firstprivate(x) ! { dg-error "Expected integer expression of the 'omp_allocator_handle_kind' kind" }
+!$omp end parallel
+
+!$omp parallel allocate( align (q) : x)  firstprivate(x) ! { dg-error "32:ALIGN modifier requires at \\(1\\) a scalar positive constant integer alignment expression that is a power of two" }
+!$omp end parallel
+
+!$omp parallel allocate( align (32) : x)  firstprivate(x) ! OK
+!$omp end parallel
+
+!$omp parallel allocate( align(q) : x) firstprivate(x) ! { dg-error "31:ALIGN modifier requires at \\(1\\) a scalar positive constant integer alignment expression that is a power of two" }
+!$omp end parallel
+
+!$omp parallel allocate( align(cnst(1)) : x ) firstprivate(x) ! OK
+!$omp end parallel
+
+!$omp parallel allocate( align(cnst(2)) : x) firstprivate(x)  ! { dg-error "31:ALIGN modifier requires at \\(1\\) a scalar positive constant integer alignment expression that is a power of two" }
+!$omp end parallel
+
+!$omp parallel allocate( align( 31) :x) firstprivate(x)  ! { dg-error "32:ALIGN modifier requires at \\(1\\) a scalar positive constant integer alignment expression that is a power of two" }
+!$omp end parallel
+
+!$omp parallel allocate( align (32.0): x) firstprivate(x)  ! { dg-error "32:ALIGN modifier requires at \\(1\\) a scalar positive constant integer alignment expression that is a power of two" }
+!$omp end parallel
+
+!$omp parallel allocate( align(cnst ) : x ) firstprivate(x)  ! { dg-error "31:ALIGN modifier requires at \\(1\\) a scalar positive constant integer alignment expression that is a power of two" }
+!$omp end parallel
+end

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

only message in thread, other threads:[~2023-02-01 14:28 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-01 14:28 [gcc/devel/omp/gcc-12] Fortran: Extend align-clause checks of OpenMP's allocate directive Tobias Burnus

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).