[clang] [C23] Implement N3018: The constexpr specifier for object definitions (PR #73099)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Tue Nov 28 09:00:03 PST 2023
================
@@ -9237,6 +9282,22 @@ static FunctionDecl *CreateNewFunctionDecl(Sema &SemaRef, Declarator &D,
FunctionDecl *NewFD = nullptr;
bool isInline = D.getDeclSpec().isInlineSpecified();
+ ConstexprSpecKind ConstexprKind = D.getDeclSpec().getConstexprSpecifier();
+ if (ConstexprKind == ConstexprSpecKind::Constinit ||
+ (SemaRef.getLangOpts().C23 &&
+ ConstexprKind == ConstexprSpecKind::Constexpr)) {
+
+ if (SemaRef.getLangOpts().C23)
+ SemaRef.Diag(D.getDeclSpec().getConstexprSpecLoc(),
+ diag::err_c23_constexpr_not_variable);
----------------
AaronBallman wrote:
Hmmm, I'm not certain we need to change anything here, but it would be more clear to say that a function cannot be constexpr in C instead of saying you declared something constexpr that isn't a variable. WDYT?
https://github.com/llvm/llvm-project/pull/73099
More information about the cfe-commits
mailing list