[PATCH] D121963: [clang] [OpenMP] Diagnose use of 'target_clones' in OpenMP variant declarations.

Tom Honermann via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 21 10:40:44 PDT 2022


This revision was automatically updated to reflect the committed changes.
Closed by commit rG059a953d8819: [clang] [OpenMP] Diagnose use of 'target_clones' in OpenMP variant declarations. (authored by tahonermann).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D121963/new/

https://reviews.llvm.org/D121963

Files:
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/declare_variant_messages.c


Index: clang/test/OpenMP/declare_variant_messages.c
===================================================================
--- clang/test/OpenMP/declare_variant_messages.c
+++ clang/test/OpenMP/declare_variant_messages.c
@@ -162,9 +162,8 @@
 #pragma omp declare variant(incompat_attr_variant) match(implementation={vendor(llvm)})
 __attribute__((target("default"))) void incompat_attr_target_default(void); // expected-error {{'#pragma omp declare variant' is not compatible with any target-specific attributes}}
 
-// FIXME: No diagnostics are produced for use of the 'target_clones' attribute in an OMP variant declaration.
 #pragma omp declare variant(incompat_attr_variant) match(implementation={vendor(llvm)})
-__attribute__((target_clones("sse,default"))) void incompat_attr_target_clones(void);
+__attribute__((target_clones("sse,default"))) void incompat_attr_target_clones(void); // expected-error {{'#pragma omp declare variant' is not compatible with any target-specific attributes}}
 
 void marked(void);
 void not_marked(void);
Index: clang/lib/Sema/SemaOpenMP.cpp
===================================================================
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -7036,11 +7036,11 @@
   }
 
   auto &&HasMultiVersionAttributes = [](const FunctionDecl *FD) {
-    return FD->hasAttrs() &&
-           (FD->hasAttr<CPUDispatchAttr>() || FD->hasAttr<CPUSpecificAttr>() ||
-            FD->hasAttr<TargetAttr>());
+    // The 'target' attribute needs to be separately checked because it does
+    // not always signify a multiversion function declaration.
+    return FD->isMultiVersion() || FD->hasAttr<TargetAttr>();
   };
-  // OpenMP is not compatible with CPU-specific attributes.
+  // OpenMP is not compatible with multiversion function attributes.
   if (HasMultiVersionAttributes(FD)) {
     Diag(FD->getLocation(), diag::err_omp_declare_variant_incompat_attributes)
         << SR;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D121963.417022.patch
Type: text/x-patch
Size: 1939 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220321/762e6204/attachment.bin>


More information about the cfe-commits mailing list