]> granicus.if.org Git - clang/commit
[OpenMP] diagnose assign to firstprivate const, patch by Joel E. Denny
authorAlexey Bataev <a.bataev@hotmail.com>
Fri, 10 Nov 2017 15:39:50 +0000 (15:39 +0000)
committerAlexey Bataev <a.bataev@hotmail.com>
Fri, 10 Nov 2017 15:39:50 +0000 (15:39 +0000)
commit6bfc3d132e8ea9d1a1703e110473d25af0d9748a
treefadddf891fde619bba14c1f9d1c206750939e3b8
parent4fd3ff53bc69e6468c2938864a238612bc64bc53
[OpenMP] diagnose assign to firstprivate const, patch by Joel E. Denny

Summary:
[OpenMP] diagnose assign to firstprivate const

Clang does not diagnose assignments to const variables declared
firstprivate.  Furthermore, codegen is broken such that, at run time,
such assignments simply have no effect.  For example, the following
prints 0 not 1:

int main() {
  const int i = 0;
  #pragma omp parallel firstprivate(i)
  { i=1; printf("%d\n", i); }
  return 0;
}

This commit makes these assignments a compile error, which is
consistent with other OpenMP compilers I've tried (pgcc 17.4-0, gcc
6.3.0).

Reviewers: ABataev

Reviewed By: ABataev

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D39859

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@317891 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Sema/SemaExpr.cpp
test/OpenMP/parallel_firstprivate_messages.cpp