Page MenuHomePhabricator

[OpenMP] diagnose assign to firstprivate const
ClosedPublic

Authored by jdenny on Nov 9 2017, 12:05 PM.

Details

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).

Diff Detail

Repository
rL LLVM

Event Timeline

jdenny created this revision.Nov 9 2017, 12:05 PM
jdenny added a reviewer: ABataev.
jdenny removed a subscriber: ABataev.
ABataev added inline comments.Nov 9 2017, 1:21 PM
lib/Sema/SemaExpr.cpp
14356 ↗(On Diff #122292)

hasConst must start from capital letter HasConst.

14360 ↗(On Diff #122292)

Better to make it this way:

DeclRefType.addConst();
test/OpenMP/parallel_firstprivate_messages.cpp
75 ↗(On Diff #122292)

Please, add a separate directive with this assignment

jdenny updated this revision to Diff 122329.Nov 9 2017, 1:57 PM

Hi Alexey. Thanks for your comments. This update should address them all.

This revision is now accepted and ready to land.Nov 10 2017, 6:06 AM

Alexey: Thanks for accepting. I do not have commit privileges. Would you please commit for me?

Alexey: Thanks for accepting. I do not have commit privileges. Would you please commit for me?

Sure, no problems.

This revision was automatically updated to reflect the committed changes.