https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115685
Bug ID: 115685 Summary: [OpenMP][5.1][OpenACC] Permit named constants ("PARAMETER") in firstprivate, shared and copyin clauses Product: gcc Version: 15.0 Status: UNCONFIRMED Keywords: openacc, openmp, rejects-valid Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: burnus at gcc dot gnu.org CC: jakub at gcc dot gnu.org, tschwinge at gcc dot gnu.org Target Milestone: --- OpenMP 5.1 permits now named constants ("PARAMETER") in 'shared' and in 'firstprivate' clauses. OpenACC 3.4 will permit it explicitly in 'firstprivate' and 'copyin' clauses (→ OpenACC, Issue 505), user code already used it for both arrays and scalars. * * * 3 | !$omp parallel firstprivate(p) shared(q) 6 | !$omp target firstprivate(p) Error: Object 'p' is not a variable at (1) Error: Object 'q' is not a variable at (1) Error: Object 'p' is not a variable at (1) ---- for: ---- integer, parameter :: p = 5, q= 7 !$omp parallel firstprivate(p) shared(q) !$omp end parallel !$omp target firstprivate(p) !$omp end target end * * * OpenACC (real-world use in the ICON code, https://gitlab.dkrz.de/icon/icon-model/ ): REAL(wp), PARAMETER :: zwdmin = 0.05_wp !$ACC DECLARE COPYIN(zwdmin) REAL(KIND=jprb), PARAMETER :: beta(2)= [0.7_jprb , 0.45_jprb ] !$ACC DECLARE COPYIN(beta) * * * Wording in OpenMP (here TR12, but it was added in 5.1): In "4.2.1 OpenMP Argument Lists": [104:8] A variable list item is one of the following: […] [104:11] * a named constant; […] [104:18] A named constant as a list item can appear only in clauses where it is explicitly allowed. And in "6.1 Data-Sharing Attribute Rules" → "6.1.1 Variables Referenced in a Construct": [148:3–4] Certain variables and objects have predetermined data-sharing attributes for the construct in which they are referenced […] [150:16–17] * […] named constants are shared in constructs that are not data-mapping constructs. [150:18] * Named constants are firstprivate in target constructs. [150:23–24] Variables with predetermined data-sharing attributes may not be listed in data-sharing attribute clauses, except for the cases listed below […] [151:11] Named constants may be listed in a shared or firstprivate clause. In 6.4.4 firstprivate Clause: The list items that appear in a firstprivate clause may include named constants. (Same in 'shared' clauses, once the omission has been fixed; OpenMP, Issue 3995.)