================
@@ -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)) {
----------------
AaronBallman wrote:
This kind of special casing is a bit concerning; if C adds new kinds of
declarations, we're not going to know to come update this place where we're
only calling `ParseDeclaration` if there's a `static_assert` keyword.
This makes me wonder if we have extensions to declarations that we need to be
concerned about here as well.
Hmm, also, is this expected to work?
```
if (__extension__ int i = 12; i < 100)
;
```
GCC doesn't support it: https://godbolt.org/z/57MnqzM53 but the point to
`__extension__` is to disable extension warnings and it is allowed on other
declarations (despite being documented as impacting expressions:
https://gcc.gnu.org/onlinedocs/gcc/Alternate-Keywords.html):
https://godbolt.org/z/TsbG5ch77 so I would have expected that to suppress the
extension diagnostic.
CC @pinskia in case you know if the `__extension__` behavior is intentional in
GCC or not
https://github.com/llvm/llvm-project/pull/198244
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits