[clang] [C23] Implement N3018: The constexpr specifier for object definitions (PR #73099)

Mariya Podchishchaeva via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 29 05:56:53 PST 2023


================
@@ -14397,17 +14559,21 @@ void Sema::CheckCompleteVariableDeclaration(VarDecl *var) {
   QualType baseType = Context.getBaseElementType(type);
   bool HasConstInit = true;
 
+  if (getLangOpts().C23 && var->isConstexpr() && !Init)
+    Diag(var->getLocation(), diag::err_constexpr_var_requires_const_init)
+        << var;
----------------
Fznamznon wrote:

Yes, existing logic uses `InitializationSequence` code paths that are deeply tied to C++ initialization rules, modifying these for C didn't seem reasonable.

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


More information about the cfe-commits mailing list