[PATCH] D80200: [AST][RecoveryExpr] Fix an assertion crash on openMP.

Haojian Wu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue May 19 03:13:04 PDT 2020


hokein created this revision.
hokein added a reviewer: sammccall.
Herald added subscribers: guansong, yaxunl.
Herald added a reviewer: jdoerfert.
Herald added a project: clang.

With recovery expr, it is possible that we have a value-dependent expr
within non-dependent context.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D80200

Files:
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/recovery-crash.cpp


Index: clang/test/OpenMP/recovery-crash.cpp
===================================================================
--- /dev/null
+++ clang/test/OpenMP/recovery-crash.cpp
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=50 -frecovery-ast %s
+
+void foo(int i) {
+#pragma omp target update from(i) device(undef()) // expected-error {{use of undeclared identifier 'undef'}}
+}
Index: clang/lib/Sema/SemaOpenMP.cpp
===================================================================
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -6894,8 +6894,8 @@
 static ExprResult
 tryBuildCapture(Sema &SemaRef, Expr *Capture,
                 llvm::MapVector<const Expr *, DeclRefExpr *> &Captures) {
-  if (SemaRef.CurContext->isDependentContext())
-    return ExprResult(Capture);
+  if (SemaRef.CurContext->isDependentContext() || Capture->containsErrors())
+    return Capture;
   if (Capture->isEvaluatable(SemaRef.Context, Expr::SE_AllowSideEffects))
     return SemaRef.PerformImplicitConversion(
         Capture->IgnoreImpCasts(), Capture->getType(), Sema::AA_Converting,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D80200.264832.patch
Type: text/x-patch
Size: 1108 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200519/aaa275cb/attachment.bin>


More information about the cfe-commits mailing list