[clang] fix explicit incomplete enum (PR #184210)

Matheus Izvekov via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 9 17:00:00 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());
----------------
mizvekov 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.

https://github.com/llvm/llvm-project/pull/184210


More information about the cfe-commits mailing list