diff options
author | Tobias Burnus <tburnus@baylibre.com> | 2024-02-13 20:55:26 +0100 |
---|---|---|
committer | Tobias Burnus <tburnus@baylibre.com> | 2024-02-13 20:55:26 +0100 |
commit | a5d34b60c949e85aa3e213872fbc42f4eee7457b (patch) | |
tree | 17f561d8802114e56b1c0d38e08205c309a18048 /gcc/cp/parser.cc | |
parent | 0eb9265fe737d901f484e4bcd73ffe386eb35693 (diff) | |
download | gcc-a5d34b60c949e85aa3e213872fbc42f4eee7457b.zip gcc-a5d34b60c949e85aa3e213872fbc42f4eee7457b.tar.gz gcc-a5d34b60c949e85aa3e213872fbc42f4eee7457b.tar.bz2 |
OpenMP: Reject non-const 'condition' trait in Fortran
OpenMP 5.0 only permits constant expressions for the 'condition' trait
in context selectors; this is relaxed in 5.2 but not implemented. In order
to avoid wrong code, it is now rejected.
Additionally, in Fortran, 'condition' should not accept an integer
expression, which is now ensured. Additionally, as 'device_num' should be
a conforming device number, there is now a check on the value.
PR middle-end/113904
gcc/c/ChangeLog:
* c-parser.cc (c_parser_omp_context_selector): Handle splitting of
OMP_TRAIT_PROPERTY_EXPR into OMP_TRAIT_PROPERTY_{DEV_NUM,BOOL}_EXPR.
gcc/cp/ChangeLog:
* parser.cc (cp_parser_omp_context_selector): Handle splitting of
OMP_TRAIT_PROPERTY_EXPR into OMP_TRAIT_PROPERTY_{DEV_NUM,BOOL}_EXPR.
gcc/fortran/ChangeLog:
* trans-openmp.cc (gfc_trans_omp_declare_variant): Handle splitting of
OMP_TRAIT_PROPERTY_EXPR into OMP_TRAIT_PROPERTY_{DEV_NUM,BOOL}_EXPR.
* openmp.cc (gfc_match_omp_context_selector): Likewise; rejects
non-const device_num/condition; improve diagnostic.
gcc/ChangeLog:
* omp-general.cc (struct omp_ts_info): Update for splitting of
OMP_TRAIT_PROPERTY_EXPR into OMP_TRAIT_PROPERTY_{DEV_NUM,BOOL}_EXPR.
* omp-selectors.h (enum omp_tp_type): Replace
OMP_TRAIT_PROPERTY_EXPR by OMP_TRAIT_PROPERTY_{DEV_NUM,BOOL}_EXPR.
gcc/testsuite/ChangeLog:
* gfortran.dg/gomp/declare-variant-1.f90: Change 'condition' trait's
argument from integer to a logical expression.
* gfortran.dg/gomp/declare-variant-11.f90: Likewise.
* gfortran.dg/gomp/declare-variant-12.f90: Likewise.
* gfortran.dg/gomp/declare-variant-13.f90: Likewise.
* gfortran.dg/gomp/declare-variant-2.f90: Likewise.
* gfortran.dg/gomp/declare-variant-2a.f90: Likewise.
* gfortran.dg/gomp/declare-variant-3.f90: Likewise.
* gfortran.dg/gomp/declare-variant-4.f90: Likewise.
* gfortran.dg/gomp/declare-variant-6.f90: Likewise.
* gfortran.dg/gomp/declare-variant-8.f90: Likewise.
* gfortran.dg/gomp/declare-variant-20.f90: New test.
Diffstat (limited to 'gcc/cp/parser.cc')
-rw-r--r-- | gcc/cp/parser.cc | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc index f0c8f9c..68ab74d 100644 --- a/gcc/cp/parser.cc +++ b/gcc/cp/parser.cc @@ -47984,7 +47984,8 @@ cp_parser_omp_context_selector (cp_parser *parser, enum omp_tss_code set, } while (1); break; - case OMP_TRAIT_PROPERTY_EXPR: + case OMP_TRAIT_PROPERTY_DEV_NUM_EXPR: + case OMP_TRAIT_PROPERTY_BOOL_EXPR: /* FIXME: this is bogus, the expression need not be constant. */ t = cp_parser_constant_expression (parser); |