[llvm-branch-commits] [flang] [flang][OpenMP] Use OmpDirectiveSpecification in DECLARE_VARIANT (PR #160371)

Tom Eccles via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu Sep 25 02:53:16 PDT 2025


================
@@ -1370,9 +1365,50 @@ void OmpStructureChecker::Leave(const parser::OpenMPDeclareSimdConstruct &) {
 }
 
 void OmpStructureChecker::Enter(const parser::OmpDeclareVariantDirective &x) {
-  const auto &dir{std::get<parser::Verbatim>(x.t)};
-  PushContextAndClauseSets(
-      dir.source, llvm::omp::Directive::OMPD_declare_variant);
+  const parser::OmpDirectiveName &dirName{x.v.DirName()};
+  PushContextAndClauseSets(dirName.source, dirName.v);
+
+  const parser::OmpArgumentList &args{x.v.Arguments()};
+  if (args.v.size() != 1) {
+    context_.Say(args.source,
+        "DECLARE_VARIANT directive should have a single argument"_err_en_US);
+    return;
+  }
+
+  auto InvalidArgument{[&](parser::CharBlock source) {
+    context_.Say(source,
+        "The argument to the DECLARE_VARIANT directive should be [base-name:]variant-name"_err_en_US);
+  }};
+
+  auto CheckSymbol{[&](const Symbol *sym, parser::CharBlock source) {
+    if (sym) {
+      if (!IsProcedure(*sym) && !IsFunction(*sym)) {
+        context_.Say(source,
+            "The name '%s' should refer to a procedure"_err_en_US, sym->name());
+      }
+      if (sym->test(Symbol::Flag::Implicit)) {
+        context_.Say(source,
+            "The name '%s' has been implicitly declared"_err_en_US,
+            sym->name());
----------------
tblah wrote:

Same as my nit on the other PR. I wonder if this should be checked before the type.

Edit: actually I can see from the test that both are printed so it probably doesn't matter

https://github.com/llvm/llvm-project/pull/160371


More information about the llvm-branch-commits mailing list