public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/omp/gcc-12] Fix 'omp_allocator_handle_kind' example in 'gfortran.dg/gomp/allocate-4.f90'
@ 2023-02-09 11:05 Thomas Schwinge
  0 siblings, 0 replies; only message in thread
From: Thomas Schwinge @ 2023-02-09 11:05 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:f98e0d62108e9bc9cdcdb53f5b7e356a81a3e6a2

commit f98e0d62108e9bc9cdcdb53f5b7e356a81a3e6a2
Author: Thomas Schwinge <thomas@codesourcery.com>
Date:   Wed Feb 1 12:30:28 2023 +0100

    Fix 'omp_allocator_handle_kind' example in 'gfortran.dg/gomp/allocate-4.f90'
    
    I've noticed that while 'gfortran.dg/gomp/allocate-4.f90' is all-PASS for
    x86_64-pc-linux-gnu (default) '-m64' testing, it does have one FAIL for
    '-m32' testing: 'test for errors, line 25'.  Here's the 'diff':
    
        @@ -1,8 +1,3 @@
        -source-gcc/gcc/testsuite/gfortran.dg/gomp/allocate-4.f90:25:34:
        -
        -   25 |   !$omp allocate (var1) allocator(10) ! { dg-error "Expected integer expression of the 'omp_allocator_handle_kind' kind at .1." }
        -      |                                  1
        -Error: Expected integer expression of the ‘omp_allocator_handle_kind’ kind at (1)
         source-gcc/gcc/testsuite/gfortran.dg/gomp/allocate-4.f90:28:130:
    
            28 |   !$omp allocate (var2)  ! { dg-error "'var2' in 'allocate' directive at .1. is not present in associated 'allocate' statement." }
    
    I understand that's due to an "accidental" non-match vs. match of
    '10' vs. 'omp_allocator_handle_kind' ('c_intptr_t') data types:
    
    > --- a/gcc/fortran/openmp.c
    > +++ b/gcc/fortran/openmp.c
    
    > +static void
    > +gfc_resolve_omp_allocate (gfc_code *code, gfc_namespace *ns)
    > +{
    > +  gfc_alloc *al;
    > +  gfc_omp_namelist *n = NULL;
    > +  gfc_omp_namelist *cn = NULL;
    > +  gfc_omp_namelist *p, *tail;
    > +  gfc_code *cur;
    > +  hash_set<gfc_symbol*> vars;
    > +
    > +  gfc_omp_clauses *clauses = code->ext.omp_clauses;
    > +  gcc_assert (clauses);
    > +  cn = clauses->lists[OMP_LIST_ALLOCATOR];
    > +  gfc_expr *omp_al = cn ? cn->expr : NULL;
    > +
    > +  if (omp_al && (omp_al->ts.type != BT_INTEGER
    > +      || omp_al->ts.kind != gfc_c_intptr_kind))
    > +    gfc_error ("Expected integer expression of the "
    > +            "%<omp_allocator_handle_kind%> kind at %L", &omp_al->where);
    
        $ git grep -i parameter.\*omp_allocator_handle_kind -- libgomp/omp_lib.*
        libgomp/omp_lib.f90.in:        integer, parameter :: omp_allocator_handle_kind = c_intptr_t
        libgomp/omp_lib.h.in:      parameter (omp_allocator_handle_kind = @INTPTR_T_KIND@)
    
    Fix-up for og12 commit 491478d12b83e102f72858e8a871a25c951df293
    "Add parsing support for allocate directive (OpenMP 5.0)".
    
            gcc/testsuite/
            * gfortran.dg/gomp/allocate-4.f90: Fix 'omp_allocator_handle_kind'
            example.

Diff:
---
 gcc/testsuite/ChangeLog.omp                   | 5 +++++
 gcc/testsuite/gfortran.dg/gomp/allocate-4.f90 | 7 ++++++-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/gcc/testsuite/ChangeLog.omp b/gcc/testsuite/ChangeLog.omp
index c5549aa8995..42769c7dae5 100644
--- a/gcc/testsuite/ChangeLog.omp
+++ b/gcc/testsuite/ChangeLog.omp
@@ -1,3 +1,8 @@
+2023-02-09  Thomas Schwinge  <thomas@codesourcery.com>
+
+	* gfortran.dg/gomp/allocate-4.f90: Fix 'omp_allocator_handle_kind'
+	example.
+
 2023-02-06  Andrew Stubbs  <ams@codesourcery.com>
 
 	* gcc.c-torture/execute/pr47237.c: Xfail on amdgcn.
diff --git a/gcc/testsuite/gfortran.dg/gomp/allocate-4.f90 b/gcc/testsuite/gfortran.dg/gomp/allocate-4.f90
index 3f512d66495..0773e5c59e6 100644
--- a/gcc/testsuite/gfortran.dg/gomp/allocate-4.f90
+++ b/gcc/testsuite/gfortran.dg/gomp/allocate-4.f90
@@ -22,7 +22,12 @@ subroutine foo(x, y)
   integer, allocatable :: var8(:)
   integer, allocatable :: var9(:)
 
-  !$omp allocate (var1) allocator(10) ! { dg-error "Expected integer expression of the 'omp_allocator_handle_kind' kind at .1." }
+  ! Don't use a hard-coded value (..., but it does pass the checks).
+  !$omp allocate (var1) allocator(10_omp_allocator_handle_kind) ! { dg-bogus "Expected integer expression of the 'omp_allocator_handle_kind' kind" }
+  allocate (var1(x))
+
+  ! Assumption is that 'omp_allocator_handle_kind' ('c_intptr_t') isn't 1.
+  !$omp allocate (var1) allocator(10_1) ! { dg-error "Expected integer expression of the 'omp_allocator_handle_kind' kind at .1." }
   allocate (var1(x))
 
   !$omp allocate (var2)  ! { dg-error "'var2' in 'allocate' directive at .1. is not present in associated 'allocate' statement." }

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

only message in thread, other threads:[~2023-02-09 11:05 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-09 11:05 [gcc/devel/omp/gcc-12] Fix 'omp_allocator_handle_kind' example in 'gfortran.dg/gomp/allocate-4.f90' Thomas Schwinge

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