[clang] [Clang] Fix misleading diagnostic for pointer const type static data member (PR #223596)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 15 05:06:49 PDT 2026


================
@@ -14480,7 +14333,9 @@ void Sema::AddInitializerToDecl(Decl *RealDecl, Expr *Init, bool DirectInit) {
     } else if (VDecl->isConstexpr()) {
 
     // Require constness.
-    } else if (!DclT.isConstQualified()) {
+    } else if (!DclT.isConstQualified() &&
----------------
AaronBallman wrote:

I think there's a need to check the language mode here; in C++98 mode we still want to get the out-of-line diagnostic because `constexpr` isn't a thing there. That should also be added as test coverage.

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


More information about the cfe-commits mailing list