[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 05:17:35 PST 2022


zero9178 marked an inline comment as done.
zero9178 added inline comments.


================
Comment at: clang/test/Sema/warn-mixed-decls.c:1-4
+/* RUN: %clang_cc1 -fsyntax-only -verify -std=c89 -pedantic %s
+ */
+/* RUN: %clang_cc1 -fsyntax-only -verify -std=c99 -Wdeclaration-after-statement %s
+ */
----------------
aaron.ballman wrote:
> I'd also like to see RUN lines for when we expect the diagnostic to not be enabled:
> ```
> /* RUN: %clang_cc1 -fsyntax-only -verify=none -std=c99 %s */
> /* RUN: %clang_cc1 -fsyntax-only -verify=none -x c++ %s */
> /* RUN: %clang_cc1 -fsyntax-only -verify=none -x c++ -Wdeclaration-after-statement %s */
> 
> /* none-no-diagnostics */
> ```
> I should note that the last RUN line will give different behavior between Clang and GCC: https://godbolt.org/z/o1PKo7dhM, but I think that's a more general issue that doesn't need to be addressed in this patch. (We don't have a way to flag a diagnostic as requiring a particular language mode.)
The `*/`  on the next line seems to be necessary so as lit seems to otherwise add `*/` to the command line of the `RUN` command. At least this is the case on my Windows machine.  


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

https://reviews.llvm.org/D114787



More information about the cfe-commits mailing list