@@ -206,6 +206,30 @@ calculateConstraintSatisfaction(Sema &S, const Expr *ConstraintExpr,
206206 // Evaluator has decided satisfaction without yielding an expression.
207207 return ExprEmpty ();
208208
209+ // We don't have the ability to evaluate this, since it contains a
210+ // RecoveryExpr, so we want to fail overload resolution. Otherwise,
211+ // we'd potentially pick up a different overload, and cause confusing
212+ // diagnostics. SO, add a failure detail that will cause us to make this
213+ // overload set not viable.
214+ if (SubstitutedAtomicExpr.get ()->containsErrors ()) {
215+ Satisfaction.IsSatisfied = false ;
216+ Satisfaction.ContainsErrors = true ;
217+
218+ PartialDiagnostic Msg = S.PDiag (diag::note_constraint_references_error);
219+ SmallString<128 > DiagString;
220+ DiagString = " : " ;
221+ Msg.EmitToString (S.getDiagnostics (), DiagString);
222+ unsigned MessageSize = DiagString.size ();
223+ char *Mem = new (S.Context ) char [MessageSize];
224+ memcpy (Mem, DiagString.c_str (), MessageSize);
225+ Satisfaction.Details .emplace_back (
226+ ConstraintExpr,
227+ new (S.Context ) ConstraintSatisfaction::SubstitutionDiagnostic{
228+ SubstitutedAtomicExpr.get ()->getBeginLoc (),
229+ StringRef (Mem, MessageSize)});
230+ return SubstitutedAtomicExpr;
231+ }
232+
209233 EnterExpressionEvaluationContext ConstantEvaluated (
210234 S, Sema::ExpressionEvaluationContext::ConstantEvaluated);
211235 SmallVector<PartialDiagnosticAt, 2 > EvaluationDiags;
0 commit comments