Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions clang/lib/Sema/SemaOpenMP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22819,8 +22819,12 @@ class GlobalDeclRefChecker final : public StmtVisitor<GlobalDeclRefChecker> {
void declareTargetInitializer(Decl *TD) {
A = TD->getAttr<OMPDeclareTargetDeclAttr>();
DeclVector.push_back(cast<VarDecl>(TD));
llvm::DenseSet<Decl *> Visited;
while (!DeclVector.empty()) {
VarDecl *TargetVarDecl = DeclVector.pop_back_val();
if (!Visited.insert(TargetVarDecl).second)
continue;

if (TargetVarDecl->hasAttr<OMPDeclareTargetDeclAttr>() &&
TargetVarDecl->hasInit() && TargetVarDecl->hasGlobalStorage()) {
if (Expr *Ex = TargetVarDecl->getInit())
Expand Down
5 changes: 5 additions & 0 deletions clang/test/OpenMP/declare_target_messages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@
// RUN: %clang_cc1 %{common_opts_mac} -verify=expected,omp51,ompvar,omp45-to-51,omp5-and-51,omp5-or-later,omp5-or-later-var,omp45-to-51-var,omp45-to-51-clause,host-5-and-51,no-host5-and-51 -fopenmp %{limit} -o - %s
// RUN: %clang_cc1 %{common_opts_mac} -verify=expected,omp52,ompvar,omp5-or-later,omp5-or-later-var %{openmp60} %{limit} -o - %s

#pragma omp begin declare target
static int gg;
// expected-warning@+1 {{variable 'recursive' is uninitialized when used within its own initialization}}
int recursive = recursive ^ 3 + gg;
#pragma omp end declare target

// expected-error@+1 {{unexpected OpenMP directive '#pragma omp end declare target'}}
#pragma omp end declare target
Expand Down