[clang] [Clang][C2y] Add support for if declarations (N3356 paper) (PR #198244)
Muhammad Bassiouni via cfe-commits
cfe-commits at lists.llvm.org
Thu May 28 05:53:06 PDT 2026
================
@@ -1881,15 +1881,47 @@ Sema::ConditionResult Parser::ParseCXXCondition(StmtResult *InitStmt,
}
ParsedAttributes attrs(AttrFactory);
- MaybeParseCXX11Attributes(attrs);
+ bool ParsedAttrs = MaybeParseCXX11Attributes(attrs);
const auto WarnOnInit = [this, &CK] {
- Diag(Tok.getLocation(), getLangOpts().CPlusPlus17
- ? diag::warn_cxx14_compat_init_statement
- : diag::ext_init_statement)
- << (CK == Sema::ConditionKind::Switch);
+ if (getLangOpts().CPlusPlus)
+ Diag(Tok.getLocation(), getLangOpts().CPlusPlus17
+ ? diag::warn_cxx14_compat_init_statement
+ : diag::ext_init_statement)
+ << (CK == Sema::ConditionKind::Switch);
+ else
+ Diag(Tok.getLocation(), getLangOpts().C2y
+ ? diag::warn_c2y_compat_init_statement
+ : diag::ext_c2y_init_statement)
+ << (CK == Sema::ConditionKind::Switch);
};
+ if (!getLangOpts().CPlusPlus) {
+ if (Tok.isOneOf(tok::kw_static_assert, tok::kw__Static_assert)) {
----------------
bassiounix wrote:
I re-added the check for declarations, not just static assert.
As for `__extension__`, I have no information since it's not mentioned in the paper nor the C2y standard.
https://github.com/llvm/llvm-project/pull/198244
More information about the cfe-commits
mailing list