Skip to content

Commit 59e3d19

Browse files
committedNov 30, 2017
[OpenMP] Diagnose undeclared variables on declare target clause
Clang asserts on undeclared variables on the to or link clause in the declare target directive. The patch is to properly diagnose the error. // foo1 and foo2 are not declared #pragma omp declare target to(foo1) #pragma omp declare target link(foo2) Differential Revision: https://reviews.llvm.org/D40588 llvm-svn: 319458
1 parent f499b2b commit 59e3d19

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed
 

‎clang/lib/Sema/SemaOpenMP.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1506,7 +1506,7 @@ class VarOrFuncDeclFilterCCC : public CorrectionCandidateCallback {
15061506
explicit VarOrFuncDeclFilterCCC(Sema &S) : SemaRef(S) {}
15071507
bool ValidateCandidate(const TypoCorrection &Candidate) override {
15081508
NamedDecl *ND = Candidate.getCorrectionDecl();
1509-
if (isa<VarDecl>(ND) || isa<FunctionDecl>(ND)) {
1509+
if (ND && (isa<VarDecl>(ND) || isa<FunctionDecl>(ND))) {
15101510
return SemaRef.isDeclInScope(ND, SemaRef.getCurLexicalContext(),
15111511
SemaRef.getCurScope());
15121512
}

‎clang/test/OpenMP/declare_target_messages.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ void f();
1313

1414
#pragma omp declare target map(a) // expected-error {{unexpected 'map' clause, only 'to' or 'link' clauses expected}}
1515

16+
#pragma omp declare target to(foo1) // expected-error {{use of undeclared identifier 'foo1'}}
17+
18+
#pragma omp declare target link(foo2) // expected-error {{use of undeclared identifier 'foo2'}}
19+
1620
void c(); // expected-warning {{declaration is not declared in any declare target region}}
1721

1822
extern int b;

0 commit comments

Comments
 (0)
Please sign in to comment.