[clang] [clang] Evaluate constant initializers in C as well (PR #121950)

Timm Baeder via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 7 07:21:55 PST 2025


https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/121950

None

>From 87176299fcd501ec6f440e61e224b30854920e10 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= <tbaeder at redhat.com>
Date: Tue, 7 Jan 2025 16:18:56 +0100
Subject: [PATCH] [clang] Evaluate constant initializers in C as well

---
 clang/lib/Sema/SemaDecl.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 4001c4d263f1d2..ff334e9d52b9dd 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -14481,7 +14481,8 @@ void Sema::CheckCompleteVariableDeclaration(VarDecl *var) {
     // do this lazily, because the result might depend on things that change
     // later, such as which constexpr functions happen to be defined.
     SmallVector<PartialDiagnosticAt, 8> Notes;
-    if (!getLangOpts().CPlusPlus11 && !getLangOpts().C23) {
+    if (getLangOpts().CPlusPlus && !getLangOpts().CPlusPlus11 &&
+        !getLangOpts().C23) {
       // Prior to C++11, in contexts where a constant initializer is required,
       // the set of valid constant initializers is described by syntactic rules
       // in [expr.const]p2-6.



More information about the cfe-commits mailing list