[flang-commits] [flang] [Flang][OpenMP] DEFAULT(NONE) error checking on implicit references (PR #182214)
Leandro Lupori via flang-commits
flang-commits at lists.llvm.org
Mon Mar 2 08:54:52 PST 2026
================
@@ -2892,6 +2897,40 @@ void OmpAttributeVisitor::CreateImplicitSymbols(const Symbol *symbol) {
LLVM_DEBUG(llvm::dbgs()
<< "HasStaticStorageDuration(" << symbol->name() << "):\n");
+ if (checkDefaultNone) {
+ if (dsa.test(Symbol::Flag::OmpPrivate)) {
+ checkDefaultNone = false;
+ } else if (dsa.any()) {
+ if (symbol->GetUltimate().test(Symbol::Flag::CrayPointee)) {
+ std::string crayPtrName{
+ semantics::GetCrayPointer(*symbol).name().ToString()};
+ if (!IsObjectWithDSA(*currScope().FindSymbol(crayPtrName))) {
+ context_.Say(dirContext.directiveSource,
+ "The DEFAULT(NONE) clause requires that the Cray Pointer '%s' must be listed in a data-sharing attribute clause"_err_en_US,
+ crayPtrName);
+ }
+ } else {
+ context_.Say(dirContext.directiveSource,
+ "The DEFAULT(NONE) clause requires that '%s' must be listed in a data-sharing attribute clause"_err_en_US,
+ symbol->name());
+ }
+ } else if (dirDepth == (int)dirContext_.size() - 1) {
+ if (symbol->GetUltimate().test(Symbol::Flag::CrayPointee)) {
+ std::string crayPtrName{
+ semantics::GetCrayPointer(*symbol).name().ToString()};
+ if (!IsObjectWithDSA(*currScope().FindSymbol(crayPtrName))) {
+ context_.Say(name.source,
+ "The DEFAULT(NONE) clause requires that the Cray Pointer '%s' must be listed in a data-sharing attribute clause"_err_en_US,
+ crayPtrName);
+ }
+ } else {
+ context_.Say(name.source,
+ "The DEFAULT(NONE) clause requires that '%s' must be listed in a data-sharing attribute clause"_err_en_US,
+ symbol->name());
+ }
----------------
luporl wrote:
This part is almost identical as above.
Consider moving it to a separate function or lambda, that receives the source used in the error message as a parameter.
https://github.com/llvm/llvm-project/pull/182214
More information about the flang-commits
mailing list