Hi! Modifiers are only meaningful in declare simd construct, therefore latest OpenMP 4.5 disallows them on simd/for constructs.
2015-10-13 Jakub Jelinek <ja...@redhat.com> c/ * c-typeck.c (c_finish_omp_clauses): Disallow modifiers on simd/for constructs. cp/ * semantics.c (finish_omp_clauses): Disallow modifiers on simd/for constructs. testsuite/ * c-c++-common/gomp/linear-1.c: New test. * g++.dg/gomp/linear-1.C: New test. --- gcc/c/c-typeck.c.jj 2015-10-09 11:17:17.000000000 +0200 +++ gcc/c/c-typeck.c 2015-10-09 19:05:48.433813759 +0200 @@ -12470,6 +12470,14 @@ c_finish_omp_clauses (tree clauses, bool if (!declare_simd) need_implicitly_determined = true; t = OMP_CLAUSE_DECL (c); + if (!declare_simd + && OMP_CLAUSE_LINEAR_KIND (c) != OMP_CLAUSE_LINEAR_DEFAULT) + { + error_at (OMP_CLAUSE_LOCATION (c), + "modifier should not be specified in %<linear%> " + "clause on %<simd%> or %<for%> constructs"); + OMP_CLAUSE_LINEAR_KIND (c) = OMP_CLAUSE_LINEAR_DEFAULT; + } if (!INTEGRAL_TYPE_P (TREE_TYPE (t)) && TREE_CODE (TREE_TYPE (t)) != POINTER_TYPE) { --- gcc/cp/semantics.c.jj 2015-10-09 11:19:37.000000000 +0200 +++ gcc/cp/semantics.c 2015-10-09 19:07:12.604636561 +0200 @@ -5725,6 +5725,14 @@ finish_omp_clauses (tree clauses, bool a case OMP_CLAUSE_LINEAR: field_ok = allow_fields; t = OMP_CLAUSE_DECL (c); + if (!declare_simd + && OMP_CLAUSE_LINEAR_KIND (c) != OMP_CLAUSE_LINEAR_DEFAULT) + { + error_at (OMP_CLAUSE_LOCATION (c), + "modifier should not be specified in %<linear%> " + "clause on %<simd%> or %<for%> constructs"); + OMP_CLAUSE_LINEAR_KIND (c) = OMP_CLAUSE_LINEAR_DEFAULT; + } if ((VAR_P (t) || TREE_CODE (t) == PARM_DECL) && !type_dependent_expression_p (t)) { --- gcc/testsuite/c-c++-common/gomp/linear-1.c.jj 2015-10-12 10:59:33.058013750 +0200 +++ gcc/testsuite/c-c++-common/gomp/linear-1.c 2015-10-12 11:25:31.633491633 +0200 @@ -0,0 +1,42 @@ +/* { dg-do compile } */ +/* { dg-options "-fopenmp" } */ + +int i; + +#pragma omp declare simd linear (val (x) : 1) linear (y : 2) +int bar (int x, int y, int z); + +void +foo (int x, int y) +{ + #pragma omp simd linear (i: 3) + for (i = 0; i < 33; i += 3) + ; + #pragma omp simd linear (val (i): 3) /* { dg-error "modifier should not be specified in" } */ + for (i = 0; i < 33; i += 3) + ; + #pragma omp simd linear (x: y + 1) + for (i = 0; i < 10; i++) + x += y + 1; + #pragma omp simd linear (val (x): y + 1) /* { dg-error "modifier should not be specified in" } */ + for (i = 0; i < 10; i++) + x += y + 1; + #pragma omp for linear (x: y + 1) + for (i = 0; i < 10; i++) + x += y + 1; + #pragma omp for linear (val (x): y + 1) /* { dg-error "modifier should not be specified in" } */ + for (i = 0; i < 10; i++) + x += y + 1; + #pragma omp for simd linear (i: 3) + for (i = 0; i < 33; i += 3) + ; + #pragma omp for simd linear (val (i): 3) /* { dg-error "modifier should not be specified in" } */ + for (i = 0; i < 33; i += 3) + ; + #pragma omp for simd linear (x: y + 1) + for (i = 0; i < 10; i++) + x += y + 1; + #pragma omp for simd linear (val (x): y + 1) /* { dg-error "modifier should not be specified in" } */ + for (i = 0; i < 10; i++) + x += y + 1; +} --- gcc/testsuite/g++.dg/gomp/linear-1.C.jj 2015-10-12 11:37:13.327880757 +0200 +++ gcc/testsuite/g++.dg/gomp/linear-1.C 2015-10-12 11:39:16.052024819 +0200 @@ -0,0 +1,48 @@ +// { dg-do compile } +// { dg-options "-fopenmp" } + +int i; + +#pragma omp declare simd linear (ref (x) : 1) linear (uval (y) : 2) +int bar (int &x, int &y, int z); + +void +foo (int &x, int &y) +{ + #pragma omp simd linear (x: y + 1) + for (i = 0; i < 10; i++) + x += y + 1; + #pragma omp simd linear (val (x): y + 1) // { dg-error "modifier should not be specified in" } + for (i = 0; i < 10; i++) + x += y + 1; + #pragma omp simd linear (ref (x): y + 1) // { dg-error "modifier should not be specified in" } + for (i = 0; i < 10; i++) + x += y + 1; + #pragma omp simd linear (uval (x): y + 1) // { dg-error "modifier should not be specified in" } + for (i = 0; i < 10; i++) + x += y + 1; + #pragma omp for linear (x: y + 1) + for (i = 0; i < 10; i++) + x += y + 1; + #pragma omp for linear (val (x): y + 1) // { dg-error "modifier should not be specified in" } + for (i = 0; i < 10; i++) + x += y + 1; + #pragma omp for linear (ref (x): y + 1) // { dg-error "modifier should not be specified in" } + for (i = 0; i < 10; i++) + x += y + 1; + #pragma omp for linear (uval (x): y + 1) // { dg-error "modifier should not be specified in" } + for (i = 0; i < 10; i++) + x += y + 1; + #pragma omp for simd linear (x: y + 1) + for (i = 0; i < 10; i++) + x += y + 1; + #pragma omp for simd linear (val (x): y + 1) // { dg-error "modifier should not be specified in" } + for (i = 0; i < 10; i++) + x += y + 1; + #pragma omp for simd linear (ref (x): y + 1) // { dg-error "modifier should not be specified in" } + for (i = 0; i < 10; i++) + x += y + 1; + #pragma omp for simd linear (uval (x): y + 1) // { dg-error "modifier should not be specified in" } + for (i = 0; i < 10; i++) + x += y + 1; +} Jakub