[clang] [Clang] Instantiate variables referenced in `decltype` with an undeduced type. (PR #161231)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 29 10:08:38 PDT 2025


================
@@ -20108,8 +20108,9 @@ static void DoMarkVarDeclReferenced(
   bool NeededForConstantEvaluation =
       isPotentiallyConstantEvaluatedContext(SemaRef) && UsableInConstantExpr;
 
-  bool NeedDefinition =
-      OdrUse == OdrUseContext::Used || NeededForConstantEvaluation;
+  bool NeedDefinition = OdrUse == OdrUseContext::Used ||
+                        NeededForConstantEvaluation ||
+                        Var->getType()->isUndeducedType();
----------------
erichkeane wrote:

I actually wonder if this should be `isUndeducedAutoType`.  This ends up doing a type visitor to check if there is ANY 'auto' in the type (`GetContainedDeducedTypeVisitor`).

Do we expect this to work with an `auto*` return type to the lambda, etc?  I actually lean towards YES, but would love a test or two?

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


More information about the cfe-commits mailing list