[PATCH] D115094: Fix -Wdeclaration-after-statement doesn't work when used with -std=c99

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Dec 7 10:30:00 PST 2021


aaron.ballman added a comment.

I'm not opposed to the idea of issuing this diagnostic when it's explicitly enabled, but the changes aren't quite correct. `ext_mixed_decls_code` is defined as an `Extension` in DiagnosticSemaKinds.td, which means that these changes will cause us to issue a pedantic diagnostic in C99 and later mode now. We should not be issuing this as an extension warning in those modes.

The usual approach we have for this sort of thing is to issue two warnings:

- "blah is a C99 extension" (issued as an extension warning when compiling in a mode earlier than C99)
- "blah is incompatible with standards before C99" (issued when explicitly opting into compatibility warnings)

e.g., https://github.com/llvm/llvm-project/blob/main/clang/include/clang/Basic/DiagnosticSemaKinds.td#L575 and https://github.com/llvm/llvm-project/blob/main/clang/include/clang/Basic/DiagnosticSemaKinds.td#L572

Also, as @dblaikie points out, the changes are missing test coverage.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115094



More information about the cfe-commits mailing list