Fix assert during the call to getCanonicalDecl.
authorJennifer Yu <jennifer.yu@intel.com>
Tue, 2 Aug 2022 19:23:12 +0000 (12:23 -0700)
committerTobias Hieta <tobias@hieta.se>
Mon, 15 Aug 2022 07:30:40 +0000 (09:30 +0200)
https://github.com/llvm/llvm-project/issues/56884

The root problem is in isOpenMPRebuildMemberExpr, it is only need to rebuild
for field expression.  No need for member function call.

The fix is to check field for member expression and skip rebuild for member
function call.

Differential Revision: https://reviews.llvm.org/D131024

(cherry picked from commit a7bca18bc50cd2483fded0c77706980b2721ce6a)

clang/lib/Sema/SemaOpenMP.cpp
clang/test/OpenMP/parallel_default_messages.cpp

index dc1470bf7a9d1d76c20579050dd4de4fd7c4b159..a92fec6a02323f6a58476e9df994c3a12e3c1a48 100644 (file)
@@ -2270,6 +2270,9 @@ bool Sema::isInOpenMPTargetExecutionDirective() const {
 }
 
 bool Sema::isOpenMPRebuildMemberExpr(ValueDecl *D) {
+  // Only rebuild for Field.
+  if (!dyn_cast<FieldDecl>(D))
+    return false;
   DSAStackTy::DSAVarData DVarPrivate = DSAStack->hasDSA(
       D,
       [](OpenMPClauseKind C, bool AppliedToPointee,
index 7db15d72673176514fd84b1a497af37029d0ff53..65e0d92c32fc2aa462339d40974dda5e7d188849 100644 (file)
@@ -49,3 +49,10 @@ int main(int argc, char **argv) {
 
   return 0;
 }
+
+class A{
+  void a() {
+    #pragma omp parallel
+    a(b); // expected-error {{use of undeclared identifier 'b'}}
+ }
+};