]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fix 'omp_allocator_handle_kind' example in 'gfortran.dg/gomp/allocate-4.f90'
authorThomas Schwinge <thomas@codesourcery.com>
Wed, 1 Feb 2023 11:30:28 +0000 (12:30 +0100)
committerThomas Schwinge <thomas@codesourcery.com>
Thu, 9 Feb 2023 11:05:08 +0000 (12:05 +0100)
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.

gcc/testsuite/ChangeLog.omp
gcc/testsuite/gfortran.dg/gomp/allocate-4.f90

index c5549aa8995a2fcaaa7a05c1f88609b74a341695..42769c7dae5e654e108961e15841ec1b23d7fa2f 100644 (file)
@@ -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.
index 3f512d664950d73c26e3df5adc8d3f478e7066bf..0773e5c59e66d8d589661ca01d3878e0e1f7c04e 100644 (file)
@@ -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." }