Hi! Just a simple restriction, committed to gomp-5_0-branch.
2018-06-01 Jakub Jelinek <ja...@redhat.com> * c-typeck.c (c_finish_omp_clauses): Diagnose more than one nontemporal clause refering to the same variable. * semantics.c (finish_omp_clauses): Diagnose more than one nontemporal clause refering to the same variable. * c-c++-common/gomp/nontemporal-2.c: New test. --- gcc/c/c-typeck.c.jj 2018-05-04 19:08:55.309273302 +0200 +++ gcc/c/c-typeck.c 2018-06-01 09:52:06.498468358 +0200 @@ -13061,8 +13061,10 @@ c_finish_omp_clauses (tree clauses, enum bitmap_initialize (&firstprivate_head, &bitmap_default_obstack); bitmap_initialize (&lastprivate_head, &bitmap_default_obstack); bitmap_initialize (&aligned_head, &bitmap_default_obstack); + /* If ort == C_ORT_OMP_DECLARE_SIMD used as uniform_head instead. */ bitmap_initialize (&map_head, &bitmap_default_obstack); bitmap_initialize (&map_field_head, &bitmap_default_obstack); + /* If ort == C_ORT_OMP used as nontemporal_head instead. */ bitmap_initialize (&oacc_reduction_head, &bitmap_default_obstack); if (ort & C_ORT_ACC) @@ -13534,6 +13536,15 @@ c_finish_omp_clauses (tree clauses, enum "%qE is not a variable in %<nontemporal%> clause", t); remove = true; } + else if (bitmap_bit_p (&oacc_reduction_head, DECL_UID (t))) + { + error_at (OMP_CLAUSE_LOCATION (c), + "%qE appears more than once in %<nontemporal%> " + "clauses", t); + remove = true; + } + else + bitmap_set_bit (&oacc_reduction_head, DECL_UID (t)); break; case OMP_CLAUSE_DEPEND: --- gcc/cp/semantics.c.jj 2018-05-31 15:18:22.659856911 +0200 +++ gcc/cp/semantics.c 2018-06-01 10:15:48.760084496 +0200 @@ -5871,8 +5871,10 @@ finish_omp_clauses (tree clauses, enum c bitmap_initialize (&firstprivate_head, &bitmap_default_obstack); bitmap_initialize (&lastprivate_head, &bitmap_default_obstack); bitmap_initialize (&aligned_head, &bitmap_default_obstack); + /* If ort == C_ORT_OMP_DECLARE_SIMD used as uniform_head instead. */ bitmap_initialize (&map_head, &bitmap_default_obstack); bitmap_initialize (&map_field_head, &bitmap_default_obstack); + /* If ort == C_ORT_OMP used as nontemporal_head instead. */ bitmap_initialize (&oacc_reduction_head, &bitmap_default_obstack); if (ort & C_ORT_ACC) @@ -6625,6 +6627,14 @@ finish_omp_clauses (tree clauses, enum c error ("%qE is not a variable in %<nontemporal%> clause", t); remove = true; } + else if (bitmap_bit_p (&oacc_reduction_head, DECL_UID (t))) + { + error ("%qD appears more than once in %<nontemporal%> clauses", + t); + remove = true; + } + else + bitmap_set_bit (&oacc_reduction_head, DECL_UID (t)); break; case OMP_CLAUSE_DEPEND: --- gcc/testsuite/c-c++-common/gomp/nontemporal-2.c.jj 2018-06-01 10:37:11.305873349 +0200 +++ gcc/testsuite/c-c++-common/gomp/nontemporal-2.c 2018-06-01 12:13:16.106230308 +0200 @@ -0,0 +1,19 @@ +/* { dg-do compile } */ + +#define N 1024 +extern int a[N], b[N], c[N], d[N]; + +void +foo (void) +{ + int i; + #pragma omp simd nontemporal (a, b) aligned (a, b, c) + for (i = 0; i < N; ++i) + a[i] = b[i] + c[i]; + #pragma omp simd nontemporal (d) nontemporal (d) /* { dg-error "'d' appears more than once in 'nontemporal' clauses" } */ + for (i = 0; i < N; ++i) + d[i] = 2 * c[i]; + #pragma omp simd nontemporal (a, b, b) /* { dg-error "'b' appears more than once in 'nontemporal' clauses" } */ + for (i = 0; i < N; ++i) + a[i] += b[i] + c[i]; +} Jakub