From d1406be551dedd4bfe7d221d43d8fd0787ce85e3 Mon Sep 17 00:00:00 2001 From: "Podchishchaeva, Mariya" Date: Thu, 17 Oct 2024 08:11:45 -0700 Subject: [PATCH] Extend the comment --- clang/lib/AST/Decl.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp index c642fcf8785151..8321cee0e0bc94 100644 --- a/clang/lib/AST/Decl.cpp +++ b/clang/lib/AST/Decl.cpp @@ -2620,7 +2620,9 @@ bool VarDecl::hasICEInitializer(const ASTContext &Context) const { } bool VarDecl::hasConstantInitialization() const { - // In C, all globals (and only globals) have constant initialization. + // In C, all globals and constexpr variables should have constant + // initialization. For constexpr variables in C check that initializer is a + // constant initializer because they can be used in constant expressions. if (hasGlobalStorage() && !getASTContext().getLangOpts().CPlusPlus && !isConstexpr()) return true;