Skip to content

Conversation

@NimishMishra
Copy link
Contributor

Current semantic checks of default clause incorrectly update symbol flags related to threadprivate symbols. This patch adds an additional check to skip such updation should a symbol be already declared threadprivate.

Fixes #78282

@llvmbot
Copy link
Member

llvmbot commented Jan 16, 2024

@llvm/pr-subscribers-flang-fir-hlfir
@llvm/pr-subscribers-flang-openmp

@llvm/pr-subscribers-flang-semantics

Author: None (NimishMishra)

Changes

Current semantic checks of default clause incorrectly update symbol flags related to threadprivate symbols. This patch adds an additional check to skip such updation should a symbol be already declared threadprivate.

Fixes #78282


Full diff: https://github.com/llvm/llvm-project/pull/78283.diff

1 Files Affected:

  • (modified) flang/lib/Semantics/resolve-directives.cpp (+5)
diff --git a/flang/lib/Semantics/resolve-directives.cpp b/flang/lib/Semantics/resolve-directives.cpp index b30b81cf90c9517..c3e5578fe72f034 100644 --- a/flang/lib/Semantics/resolve-directives.cpp +++ b/flang/lib/Semantics/resolve-directives.cpp @@ -1958,6 +1958,11 @@ void OmpAttributeVisitor::Post(const parser::Name &name) { } } } + + if (Symbol * found{currScope().FindSymbol(name.source)}) { + if (found->test(semantics::Symbol::Flag::OmpThreadprivate)) + return; + } std::vector<Symbol *> defaultDSASymbols; for (int dirDepth{0}; dirDepth < (int)dirContext_.size(); ++dirDepth) { DirContext &dirContext = dirContext_[dirDepth]; 
@luporl
Copy link
Contributor

luporl commented Jan 18, 2024

It would be nice to add a test for this.

@NimishMishra
Copy link
Contributor Author

It would be nice to add a test for this.

Thank you @luporl for the comment! I've added a test case.

Copy link
Contributor

@luporl luporl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test case looks good, thanks!

Skipping threadprivate symbols from default clause processing makes sense to me.

@NimishMishra
Copy link
Contributor Author

Ping for review!

Copy link
Contributor

@kiranchandramohan kiranchandramohan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

flang:fir-hlfir flang:openmp flang:semantics flang Flang issues not falling into any other category

4 participants