[PATCH] D40588: [OpenMP] Diagnose undeclared variables on declare target clause

Phabricator via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 30 10:52:40 PST 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL319458: [OpenMP] Diagnose undeclared variables on declare target clause (authored by kli).

Changed prior to commit:
  https://reviews.llvm.org/D40588?vs=124811&id=124969#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D40588

Files:
  cfe/trunk/lib/Sema/SemaOpenMP.cpp
  cfe/trunk/test/OpenMP/declare_target_messages.cpp


Index: cfe/trunk/test/OpenMP/declare_target_messages.cpp
===================================================================
--- cfe/trunk/test/OpenMP/declare_target_messages.cpp
+++ cfe/trunk/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;
Index: cfe/trunk/lib/Sema/SemaOpenMP.cpp
===================================================================
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp
+++ cfe/trunk/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<VarDecl>(ND) || isa<FunctionDecl>(ND)) {
+    if (ND && (isa<VarDecl>(ND) || isa<FunctionDecl>(ND))) {
       return SemaRef.isDeclInScope(ND, SemaRef.getCurLexicalContext(),
                                    SemaRef.getCurScope());
     }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D40588.124969.patch
Type: text/x-patch
Size: 1324 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20171130/f3e5dcb0/attachment.bin>


More information about the cfe-commits mailing list