diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp --- a/clang/lib/Sema/SemaOpenMP.cpp +++ b/clang/lib/Sema/SemaOpenMP.cpp @@ -6894,8 +6894,8 @@ static ExprResult tryBuildCapture(Sema &SemaRef, Expr *Capture, llvm::MapVector &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 --- /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'}} +}