This is an archive of the discontinued LLVM Phabricator instance.

[flang][OpenMP] Add semantic checks for threadprivate and declare target directives
ClosedPublic

Authored by peixin on Sep 15 2021, 6:39 PM.

Details

Summary

This patch supports the following checks for THREADPRIVATE Directive:

[5.1] 2.21.2 THREADPRIVATE Directive
A variable that appears in a threadprivate directive must be declared in
the scope of a module or have the SAVE attribute, either explicitly or
implicitly.
A variable that appears in a threadprivate directive must not be an
element of a common block or appear in an EQUIVALENCE statement.

This patch supports the following checks for DECLARE TARGET Directive:

[5.1] 2.14.7 Declare Target Directive
A variable that is part of another variable (as an array, structure
element or type parameter inquiry) cannot appear in a declare
target directive.
A variable that appears in a declare target directive must be declared
in the scope of a module or have the SAVE attribute, either explicitly
or implicitly.
A variable that appears in a declare target directive must not be an
element of a common block or appear in an EQUIVALENCE statement.

As Fortran 2018 standard [8.5.16] states, a variable, common block, or
procedure pointer declared in the scoping unit of a main program,
module, or submodule implicitly has the SAVE attribute, which may be
confirmed by explicit specification.

Diff Detail

Event Timeline

peixin created this revision.Sep 15 2021, 6:39 PM
peixin requested review of this revision.Sep 15 2021, 6:39 PM

LGTM. Nicely done. Apologies again for the delay.

Assuming other checks (including the one mentioned below) will come in separate patches.
"A threadprivate variable cannot appear in a declare target directive."

This revision is now accepted and ready to land.Oct 14 2021, 3:07 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 14 2021, 3:07 PM
Assuming other checks (including the one mentioned below) will come in separate patches.

"A threadprivate variable cannot appear in a declare target directive."

Yes. Thanks for the review. Is it OK to land this patch now?

Assuming other checks (including the one mentioned below) will come in separate patches.

"A threadprivate variable cannot appear in a declare target directive."

Yes. Thanks for the review. Is it OK to land this patch now?

Yes, please go ahead and submit.