diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp --- a/clang/lib/Sema/SemaOpenMP.cpp +++ b/clang/lib/Sema/SemaOpenMP.cpp @@ -7036,11 +7036,11 @@ } auto &&HasMultiVersionAttributes = [](const FunctionDecl *FD) { - return FD->hasAttrs() && - (FD->hasAttr() || FD->hasAttr() || - FD->hasAttr()); + // The 'target' attribute needs to be separately checked because it does + // not always signify a multiversion function declaration. + return FD->isMultiVersion() || FD->hasAttr(); }; - // 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; diff --git a/clang/test/OpenMP/declare_variant_messages.c b/clang/test/OpenMP/declare_variant_messages.c --- a/clang/test/OpenMP/declare_variant_messages.c +++ b/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);