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

Shivam Gupta via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Dec 11 03:54:24 PST 2021


xgupta added subscribers: zero9178, xgupta.
xgupta added a comment.

In D115094#3174635 <https://reviews.llvm.org/D115094#3174635>, @dblaikie wrote:

> This'll at least need a test case added - though the specifics of how the warning should work I'll leave up to @aaron.ballman - unless he wants some second opinions. (I don't immediately have a strong feeling either way regarding the current or proposed behavior)



In D115094#3176985 <https://reviews.llvm.org/D115094#3176985>, @aaron.ballman wrote:

> 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.

There is already a revision uploaded for this: https://reviews.llvm.org/D114787 by @zero9178.


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