Index: lib/Sema/SemaOpenMP.cpp =================================================================== --- lib/Sema/SemaOpenMP.cpp +++ lib/Sema/SemaOpenMP.cpp @@ -1506,7 +1506,7 @@ explicit VarOrFuncDeclFilterCCC(Sema &S) : SemaRef(S) {} bool ValidateCandidate(const TypoCorrection &Candidate) override { NamedDecl *ND = Candidate.getCorrectionDecl(); - if (isa(ND) || isa(ND)) { + if (ND && (isa(ND) || isa(ND))) { return SemaRef.isDeclInScope(ND, SemaRef.getCurLexicalContext(), SemaRef.getCurScope()); } Index: test/OpenMP/declare_target_messages.cpp =================================================================== --- test/OpenMP/declare_target_messages.cpp +++ test/OpenMP/declare_target_messages.cpp @@ -13,6 +13,10 @@ #pragma omp declare target map(a) // expected-error {{unexpected 'map' clause, only 'to' or 'link' clauses expected}} +#pragma omp declare target to(foo1) // expected-error {{use of undeclared identifier 'foo1'}} + +#pragma omp declare target link(foo2) // expected-error {{use of undeclared identifier 'foo2'}} + void c(); // expected-warning {{declaration is not declared in any declare target region}} extern int b;