================ @@ -2487,14 +2487,19 @@ bool VarDecl::mightBeUsableInConstantExpressions(const ASTContext &C) const { if (!getType().isConstant(C) || getType().isVolatileQualified()) return false; - // In C++, const, non-volatile variables of integral or enumeration types - // can be used in constant expressions. - if (getType()->isIntegralOrEnumerationType()) + // In C++, but not in C, const, non-volatile variables of integral or + // enumeration types can be used in constant expressions. + if (getType()->isIntegralOrEnumerationType() && !Lang.C23) ---------------- AaronBallman wrote:
We might want to relax this in the future because we *do* allow const, non-volatile integer variables in constant expressions in C: https://godbolt.org/z/jc1h49Wox But I think the code is fine for now because I think the function is not accurate in other ways: ``` // Function parameters are never usable in constant expressions. if (isa<ParmVarDecl>(this)) return false; ``` which is not quite the case: https://godbolt.org/z/Kdq9xY617 and yet is the case: https://godbolt.org/z/1zEGsbYfn https://github.com/llvm/llvm-project/pull/73099 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits