[clang] 2395431 - [AST][RecoveryExpr] Fix an assertion crash on openMP.
Haojian Wu via cfe-commits
cfe-commits at lists.llvm.org
Tue May 19 06:09:39 PDT 2020
Author: Haojian Wu
Date: 2020-05-19T15:09:26+02:00
New Revision: 23954318f49f1b96cb5c4b76921bea4f7ac0d5f3
URL: https://github.com/llvm/llvm-project/commit/23954318f49f1b96cb5c4b76921bea4f7ac0d5f3
DIFF: https://github.com/llvm/llvm-project/commit/23954318f49f1b96cb5c4b76921bea4f7ac0d5f3.diff
LOG: [AST][RecoveryExpr] Fix an assertion crash on openMP.
Summary:
With recovery expr, it is possible that we have a value-dependent expr
within non-dependent context.
Reviewers: sammccall, jdoerfert
Subscribers: yaxunl, guansong, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D80200
Added:
clang/test/OpenMP/recovery-crash.cpp
Modified:
clang/lib/Sema/SemaOpenMP.cpp
Removed:
################################################################################
diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index b62fb26f8b49..e556969a786a 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -6896,8 +6896,8 @@ bool OpenMPIterationSpaceChecker::checkAndSetInc(Expr *S) {
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,
diff --git a/clang/test/OpenMP/recovery-crash.cpp b/clang/test/OpenMP/recovery-crash.cpp
new file mode 100644
index 000000000000..709218ae4678
--- /dev/null
+++ b/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'}}
+}
More information about the cfe-commits
mailing list