[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)
commit77aed73c2d1a6917ede2250c40e9ced6cc3582da
tree7f2ef3a6697c345d8ebd5b07984547a57021641a
parentd30cb27a17860bdbcc49153c35e3893aea6a2882
[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

llvm-svn: 317891
clang/lib/Sema/SemaExpr.cpp
clang/test/OpenMP/parallel_firstprivate_messages.cpp