// Apply the feature via the target.
if (Name[0] != '+' && Name[0] != '-')
Diags.Report(diag::warn_fe_backend_invalid_feature_flag) << Name;
- else if (isReadOnlyFeature(Name.substr(1)))
- Diags.Report(diag::warn_fe_backend_readonly_feature_flag) << Name;
else
setFeatureEnabled(Features, Name.substr(1), Name[0] == '+');
}
#include "Targets/X86.h"
#include "Targets/XCore.h"
#include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/DiagnosticFrontend.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/TargetParser/Triple.h"
// Compute the default target features, we need the target to handle this
// because features may have dependencies on one another.
+ llvm::erase_if(Opts->FeaturesAsWritten, [&](StringRef Name) {
+ if (Target->isReadOnlyFeature(Name.substr(1))) {
+ Diags.Report(diag::warn_fe_backend_readonly_feature_flag) << Name;
+ return true;
+ }
+ return false;
+ });
if (!Target->initFeatureMap(Opts->FeatureMap, Diags, Opts->CPU,
Opts->FeaturesAsWritten))
return nullptr;
--- /dev/null
+// REQUIRES: x86-registered-target
+// REQUIRES: amdgpu-registered-target
+// REQUIRES: clang-target-64-bits
+
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -target-cpu gfx1030 \
+// RUN: -fopenmp -nogpulib -fopenmp-is-device -verify %s
+// expected-no-diagnostics
+
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -target-cpu gfx1030 \
+// RUN: -fopenmp -nogpulib -target-feature -image-insts \
+// RUN: -fopenmp-is-device -emit-llvm -S -o - %s 2>&1 | FileCheck %s
+// CHECK: warning: feature flag '-image-insts' is ignored since the feature is read only
+
+#pragma omp begin declare variant match(device = {arch(amdgcn)})
+void foo();
+#pragma omp end declare variant