[flang-commits] [flang] [Flang][OpenMP] Fix issue with named constants in SHARED and FIRSTPRIVATE clauses (PR #154335)
Michael Klemm via flang-commits
flang-commits at lists.llvm.org
Tue Aug 19 06:42:48 PDT 2025
================
@@ -2561,11 +2561,24 @@ void OmpStructureChecker::Enter(const parser::OmpClause &x) {
break;
}
+ // Named constants are OK to be used within 'shared' and 'firstprivate'
+ // clauses. The check for this happens a few lines below.
+ bool SharedOrFirstprivate = false;
+ switch (x.Id()) {
+ case llvm::omp::Clause::OMPC_shared:
+ case llvm::omp::Clause::OMPC_firstprivate:
+ SharedOrFirstprivate = true;
+ break;
+ default:
+ break;
+ }
+
if (const parser::OmpObjectList *objList{GetOmpObjectList(x)}) {
SymbolSourceMap symbols;
GetSymbolsInObjectList(*objList, symbols);
for (const auto &[symbol, source] : symbols) {
- if (!IsVariableListItem(*symbol)) {
+ if (!IsVariableListItem(*symbol) &&
+ !(IsNamedConstantListItem(*symbol) && SharedOrFirstprivate)) {
----------------
mjklemm wrote:
The expression was crafted this way to retain the logic of the decision.
https://github.com/llvm/llvm-project/pull/154335
More information about the flang-commits
mailing list