[flang-commits] [flang] Revert "[flang][cuda][openacc] Emit an error when CUDA symbols are imported with CUDA disabled" (PR #205254)
Valentin Clement バレンタイン クレメン via flang-commits
flang-commits at lists.llvm.org
Mon Jun 22 21:53:22 PDT 2026
https://github.com/clementval created https://github.com/llvm/llvm-project/pull/205254
Reverts llvm/llvm-project#205207
>From 60607314f44bd4327e4e2fdf62b9d3d908b44ee2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Valentin=20Clement=20=28=E3=83=90=E3=83=AC=E3=83=B3?=
=?UTF-8?q?=E3=82=BF=E3=82=A4=E3=83=B3=20=E3=82=AF=E3=83=AC=E3=83=A1?=
=?UTF-8?q?=E3=83=B3=29?= <clementval at gmail.com>
Date: Mon, 22 Jun 2026 21:53:10 -0700
Subject: [PATCH] =?UTF-8?q?Revert=20"[flang][cuda][openacc]=20Emit=20an=20?=
=?UTF-8?q?error=20when=20CUDA=20symbols=20are=20imported=20w=E2=80=A6"?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This reverts commit a6986f0b929d575728d564cd41bb0f9a6b6fdea4.
---
flang/lib/Semantics/mod-file.cpp | 29 -----------------------------
flang/test/Semantics/modfile84.f90 | 17 -----------------
2 files changed, 46 deletions(-)
delete mode 100644 flang/test/Semantics/modfile84.f90
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
More information about the flang-commits
mailing list