[clang] fix explicit incomplete enum (PR #184210)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Mar 10 05:12:57 PDT 2026
================
@@ -6466,6 +6464,9 @@ static ExprResult BuildConvertedConstantExpression(Sema &S, Expr *From,
if (checkPlaceholderForOverload(S, From))
return ExprError();
+ if (From->containsErrors())
+ return S.ImpCastExprToType(From, T, CK_NoOp, From->getValueKind());
----------------
Serosh-commits wrote:
> Hmm the cast kind is an interesting problem I hadn't considered.
>
> I don't think the NoOp cast is the right kind, because this does change the type significantly.
>
> If the origin or destination types are dependent, this should be a dependent cast, but I think in that case we would have bailed before we got here.
>
> If we insert any cast other than dependent cast, we risk forming an invalid expression which could trip further analysis.
>
> So I would be weakly in favor of using the dependent cast, unless someone else has a better idea?
>
> Otherwise, unless we can let this proceed further so we can at least figure out the cast kind, it seems I was wrong and a RecoveryExpr would be the better idea after all.
hmm, CK_NoOp seems a bit risky to me too. it acts a real semantic cast, so using it here could end up misleading later analysis passes as u said it can change the type significantly
RecoveryExpr feels like better to mee too as it let us mark the expression as invalid while keeps the expected type T. in that way we are leaving cascading failures without forcing an wrong cast kind seems good to me too too
@mizvekov what do u think we should go for Recoveryexpr ?
https://github.com/llvm/llvm-project/pull/184210
More information about the cfe-commits
mailing list