From: Thomas Schwinge Date: Wed, 1 Feb 2023 11:30:28 +0000 (+0100) Subject: Fix 'omp_allocator_handle_kind' example in 'gfortran.dg/gomp/allocate-4.f90' X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f98e0d62108e9bc9cdcdb53f5b7e356a81a3e6a2;p=thirdparty%2Fgcc.git 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 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 " > + "% 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 --git a/gcc/testsuite/ChangeLog.omp b/gcc/testsuite/ChangeLog.omp index c5549aa8995a..42769c7dae5e 100644 --- a/gcc/testsuite/ChangeLog.omp +++ b/gcc/testsuite/ChangeLog.omp @@ -1,3 +1,8 @@ +2023-02-09 Thomas Schwinge + + * gfortran.dg/gomp/allocate-4.f90: Fix 'omp_allocator_handle_kind' + example. + 2023-02-06 Andrew Stubbs * 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 3f512d664950..0773e5c59e66 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." }