Skip to content

Conversation

@tbaederr
Copy link
Contributor

@tbaederr tbaederr commented Jan 7, 2025

No description provided.

@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Jan 7, 2025
@llvmbot
Copy link
Member

llvmbot commented Jan 7, 2025

@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/121950.diff

1 Files Affected:

  • (modified) clang/lib/Sema/SemaDecl.cpp (+2-1)
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.

@cor3ntin
Copy link
Contributor

cor3ntin commented Jan 7, 2025

Can you add a description/ test/changelog/C23 wording quote?

Copy link
Collaborator

@shafik shafik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would love to see tests that highlight any differences between C and C++ in this area.

@tbaederr
Copy link
Contributor Author

tbaederr commented Jan 9, 2025

This makes no sense, we're already checking for unversioned c++ above.

@tbaederr tbaederr closed this Jan 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants