[PATCH] D64842: [OPENMP] Fix crash in LoopCounterRefChecker when MemberExpr is not Var or Field

Mike Rice via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 17 08:20:58 PDT 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rL366336: [OPENMP]Fix crash in LoopCounterRefChecker when MemberExpr is not Var or Field (authored by mikerice, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D64842?vs=210226&id=210335#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64842/new/

https://reviews.llvm.org/D64842

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


Index: cfe/trunk/lib/Sema/SemaOpenMP.cpp
===================================================================
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp
@@ -4992,7 +4992,8 @@
   bool VisitMemberExpr(const MemberExpr *E) {
     if (isa<CXXThisExpr>(E->getBase()->IgnoreParens())) {
       const ValueDecl *VD = E->getMemberDecl();
-      return checkDecl(E, VD);
+      if (isa<VarDecl>(VD) || isa<FieldDecl>(VD))
+        return checkDecl(E, VD);
     }
     return false;
   }
Index: cfe/trunk/test/OpenMP/for_loop_messages.cpp
===================================================================
--- cfe/trunk/test/OpenMP/for_loop_messages.cpp
+++ cfe/trunk/test/OpenMP/for_loop_messages.cpp
@@ -626,6 +626,8 @@
 class TC {
   int ii, iii, kk;
 public:
+  enum { myconstant = 42 };
+  int ub();
   int dotest_lt(IT begin, IT end) {
 #pragma omp parallel
 // expected-error at +3 3 {{the loop initializer expression depends on the current loop control variable}}
@@ -634,6 +636,12 @@
   for (ii = ii * 10 + 25; ii < ii / ii - 23; ii += 1)
     ;
 
+// Check that member function calls and enum constants in the condition is
+// handled.
+#pragma omp for
+  for (ii = 0; ii < ub() + this->myconstant; ii += 1) // expected-no-error
+    ;
+
 #pragma omp parallel
 // expected-error at +4 2 {{expected loop invariant expression or '<invariant1> * ii + <invariant2>' kind of expression}}
 // expected-error at +3 {{expected loop invariant expression or '<invariant1> * TC::ii + <invariant2>' kind of expression}}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D64842.210335.patch
Type: text/x-patch
Size: 1532 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190717/f5ae7765/attachment.bin>


More information about the llvm-commits mailing list