================
@@ -20715,8 +20715,7 @@ static void DoMarkVarDeclReferenced(
bool NeedDefinition =
OdrUse == OdrUseContext::Used || NeededForConstantEvaluation ||
- (TSK != clang::TSK_Undeclared && !UsableInConstantExpr &&
- Var->getType()->isUndeducedType());
+ (TSK != clang::TSK_Undeclared && Var->getType()->isUndeducedType());
----------------
akash-manna-sky wrote:
So I think here `obj<0>` is `constexpr`, and
`mightBeUsableInConstantExpressions()` returns true for `constexpr` variables
even while the type is still `undeduced`. The `!UsableInConstantExpr` guard
assumed the `NeededForConstantEvaluation` branch would instantiate such
variables, but that branch requires `isPotentiallyConstantEvaluatedContext()`,
which is false in an unevaluated operand like `decltype`. So when the first
reference is in `decltype`, neither branch requested the definition and the
type never got deduced — that's the state the "depends on itself" diagnostic
then misreads. Since the type of a deduced-type variable is needed at any
reference, the `undeduced` case shouldn't be gated on constant-expression
usability...
https://github.com/llvm/llvm-project/pull/217709
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits