[flang-commits] [flang] Revert "[flang][cuda][openacc] Emit an error when CUDA symbols are imported with CUDA disabled" (PR #205254)
via flang-commits
flang-commits at lists.llvm.org
Mon Jun 22 21:53:56 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-flang-semantics
Author: Valentin Clement (バレンタイン クレメン) (clementval)
<details>
<summary>Changes</summary>
Reverts llvm/llvm-project#<!-- -->205207
---
Full diff: https://github.com/llvm/llvm-project/pull/205254.diff
2 Files Affected:
- (modified) flang/lib/Semantics/mod-file.cpp (-29)
- (removed) flang/test/Semantics/modfile84.f90 (-17)
``````````diff
diff --git a/flang/lib/Semantics/mod-file.cpp b/flang/lib/Semantics/mod-file.cpp
index ac44f17009344..89a535c6ff6f9 100644
--- a/flang/lib/Semantics/mod-file.cpp
+++ b/flang/lib/Semantics/mod-file.cpp
@@ -11,7 +11,6 @@
#include "flang/Common/restorer.h"
#include "flang/Evaluate/tools.h"
#include "flang/Parser/message.h"
-#include "flang/Parser/parse-tree-visitor.h"
#include "flang/Parser/parsing.h"
#include "flang/Parser/unparse.h"
#include "flang/Semantics/scope.h"
@@ -73,7 +72,6 @@ static bool FileContentsMatch(
const std::string &, const std::string &, const std::string &);
static ModuleCheckSumType ComputeCheckSum(const std::string_view &);
static std::string CheckSumString(ModuleCheckSumType);
-static bool ProgramHasCUDAAttrs(const parser::Program &);
// Collect symbols needed for a subprogram interface
class SubprogramSymbolCollector {
@@ -1705,13 +1703,6 @@ Scope *ModFileReader::Read(SourceName name, std::optional<bool> isIntrinsic,
return nullptr;
}
parser::Program &parseTree{context_.SaveParseTree(std::move(*parsedProgram))};
- if (context_.languageFeatures().IsEnabled(common::LanguageFeature::OpenACC) &&
- !context_.languageFeatures().IsEnabled(common::LanguageFeature::CUDA) &&
- ProgramHasCUDAAttrs(parseTree)) {
- Say("use", name, ancestorName,
- "CUDA is not enabled, but '%s' defines CUDA symbols"_err_en_US,
- sourceFile->path());
- }
Scope *parentScope; // the scope this module/submodule goes into
if (!isIntrinsic.has_value()) {
for (const auto &dir : context_.intrinsicModuleDirectories()) {
@@ -1832,26 +1823,6 @@ static std::optional<SourceName> GetSubmoduleParent(
}
}
-struct CUDAAttrProgramVisitor {
- template <typename A> bool Pre(const A &) { return true; }
- template <typename A> void Post(const A &) {}
- bool Pre(const common::CUDADataAttr &) {
- foundCUDAAttrs = true;
- return false;
- }
- bool Pre(const common::CUDASubprogramAttrs &) {
- foundCUDAAttrs = true;
- return false;
- }
- bool foundCUDAAttrs{false};
-};
-
-static bool ProgramHasCUDAAttrs(const parser::Program &program) {
- CUDAAttrProgramVisitor visitor;
- parser::Walk(program, visitor);
- return visitor.foundCUDAAttrs;
-}
-
void SubprogramSymbolCollector::Collect() {
const auto &details{symbol_.get<SubprogramDetails>()};
isInterface_ = details.isInterface();
diff --git a/flang/test/Semantics/modfile84.f90 b/flang/test/Semantics/modfile84.f90
deleted file mode 100644
index 2abcd8083eea6..0000000000000
--- a/flang/test/Semantics/modfile84.f90
+++ /dev/null
@@ -1,17 +0,0 @@
-! RUN: split-file %s %t
-! RUN: %flang_fc1 -fsyntax-only -x cuda -module-dir %t %t/m.cuf
-! RUN: not %flang_fc1 -fsyntax-only -fopenacc -module-dir %t %t/use.f90 2>&1 | FileCheck %s
-
-!--- m.cuf
-module modfile84m
- real, device :: d
-contains
- attributes(device) subroutine s()
- end subroutine
-end module
-
-!--- use.f90
-use modfile84m
-end
-
-! CHECK: error: Cannot use module file for module 'modfile84m': CUDA is not enabled, but '{{.*modfile84m.mod}}' defines CUDA symbols
``````````
</details>
https://github.com/llvm/llvm-project/pull/205254
More information about the flang-commits
mailing list