Skip to content

[flang][Semantics] Fix updating flags of threadprivate symbols in presence of default clause #78283

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 12, 2024

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[flang][Semantics] Threadprivate symbols are ignored in presence of default clause
4 participants