[PATCH] D114787: [clang][PR51931] Enable `-Wdeclaration-after-statement` for all C versions

Markus Böck via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 6 13:02:27 PST 2022


zero9178 added inline comments.


================
Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:9865
 def ext_mixed_decls_code : Extension<
   "ISO C90 forbids mixing declarations and code">,
+  InGroup<DeclarationAfterStatement>;
----------------
aaron.ballman wrote:
> In the other review, I left a comment about the diagnostic text: https://reviews.llvm.org/D115094#3176985
> 
> Since we're cleaning this up, I think we should reword this diagnostic so it follows newer conventions. I think the extension diagnostic should read: `mixing declarations and code is a C99 extension` and the default ignore warning should read `mixing declarations and code is incompatible with standards before C99`. (This also helpfully removes the `ISO C90` wording, which is confused about the name of the standard.)
> 
> Typically, we'd put the default ignore warning under a new `CPre99Compat` diagnostic group (spelled `pre-c99-compat`) as we do with other precompat diagnostics, but the goal here is to match GCC's behavior and so the existing warning group seems fine to me (I don't think we want warnings in multiple groups, but that's possibly an option if it matters in the future).
A `CPre99Compat` diagnostic group sounds like a good idea if more such warnings would be requested by users. 


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D114787/new/

https://reviews.llvm.org/D114787



More information about the cfe-commits mailing list