aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Sema/SemaOpenMP.cpp
diff options
context:
space:
mode:
authorSandeep Kosuri <66305775+sandeepkosuri@users.noreply.github.com>2024-03-06 19:46:23 +0530
committerGitHub <noreply@github.com>2024-03-06 19:46:23 +0530
commit6d3bb854713e43daad34ffc84d0132d7fe010abf (patch)
tree8c8a5044ff9013e8ee00bb3b46a84fdd5df00b4f /clang/lib/Sema/SemaOpenMP.cpp
parent1fc5e50cebf1e423bce105930c3a075044998f68 (diff)
downloadllvm-6d3bb854713e43daad34ffc84d0132d7fe010abf.zip
llvm-6d3bb854713e43daad34ffc84d0132d7fe010abf.tar.gz
llvm-6d3bb854713e43daad34ffc84d0132d7fe010abf.tar.bz2
[OpenMP] Parse and Sema support for declare target in local scope (#83223)
- adds Parse and Sema support for the `declare target` directive inside a function scope.
Diffstat (limited to 'clang/lib/Sema/SemaOpenMP.cpp')
-rw-r--r--clang/lib/Sema/SemaOpenMP.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index f4364a2..afffd37 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -23353,6 +23353,15 @@ void Sema::ActOnOpenMPDeclareTargetName(NamedDecl *ND, SourceLocation Loc,
isa<FunctionTemplateDecl>(ND)) &&
"Expected variable, function or function template.");
+ if (auto *VD = dyn_cast<VarDecl>(ND)) {
+ // Only global variables can be marked as declare target.
+ if (!VD->isFileVarDecl() && !VD->isStaticLocal() &&
+ !VD->isStaticDataMember()) {
+ Diag(Loc, diag::err_omp_declare_target_has_local_vars)
+ << VD->getNameAsString();
+ return;
+ }
+ }
// Diagnose marking after use as it may lead to incorrect diagnosis and
// codegen.
if (LangOpts.OpenMP >= 50 &&