Skip to content

Commit

Permalink
[clang] [OpenMP] Diagnose use of 'target_clones' in OpenMP variant de…
Browse files Browse the repository at this point in the history
…clarations.

Previously, OpenMP variant declarations for a function declaration that included
the 'cpu_dispatch', 'cpu_specific', or 'target' attributes was diagnosed, but
one with the 'target_clones' attribute was not. Now fixed.

Reviewed By: erichkeane, jdoerfert

Differential Revision: https://reviews.llvm.org/D121963
  • Loading branch information
tahonermann committed Mar 21, 2022
1 parent 8ff8c3a commit 059a953
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
8 changes: 4 additions & 4 deletions clang/lib/Sema/SemaOpenMP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7036,11 +7036,11 @@ Sema::checkOpenMPDeclareVariantFunction(Sema::DeclGroupPtrTy DG,
}

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;
Expand Down
3 changes: 1 addition & 2 deletions clang/test/OpenMP/declare_variant_messages.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,8 @@ __attribute__((target("sse"))) void incompat_attr_target(void); // expected-erro
#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);
Expand Down

0 comments on commit 059a953

Please sign in to comment.