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

via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 28 21:09:13 PST 2023


================
@@ -8857,7 +8894,9 @@ void Sema::CheckVariableDeclarationType(VarDecl *NewVD) {
 
   if (NewVD->isConstexpr() && !T->isDependentType() &&
       RequireLiteralType(NewVD->getLocation(), T,
-                         diag::err_constexpr_var_non_literal)) {
+                         getLangOpts().C23
+                             ? diag::err_c23_constexpr_invalid_type
+                             : diag::err_constexpr_var_non_literal)) {
----------------
cor3ntin wrote:

`RequireLiteralType` assumes C++ (ie it will cast to CXXRecordDecl), so maybe we need to duplicate that entirely.
Maybe just renaming `CheckC23ConstexprVarTypeQualifiers` to `CheckC23ConstexprVarType` and do the VLAs test there

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


More information about the cfe-commits mailing list