[PATCH] D125178: Warn if using `elifdef` & `elifndef` in not C2x mode

Ken Matsui via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue May 10 06:52:05 PDT 2022


ken-matsui added a comment.

Thank you so much for your review!



================
Comment at: clang/include/clang/Basic/DiagnosticLexKinds.td:696-698
+def ext_c2x_pp_directive : Extension<
+  "%select{#elifdef|#elifndef}0 is a C2x extension">,
+  InGroup<CPre2xCompatPedantic>;
----------------
aaron.ballman wrote:
> I think we need two diagnostics, one for C2x and one for C++2b (https://wg21.link/p2334 was adopted for C++23). Each of these diagnostics should come in a pair:
> ```
> def warn_cxx20_compat_pp_directive : Warning<
>   "use of a '#%select{elifdef|elifndef}0' directive is incompatible with C++ standards before C++2b",
>   InGroup<CXXPre2bCompat>, DefaultIgnore;
> def ext_cxx20_pp_directive : ExtWarn<
>   "use of a '#%select{elifdef|elifndef}0' directive is a C++2b extension",
>   InGroup<CXX2b>;
> ```
> and similar for C, except with wording about C standards and in the C warning groups.
I thought I had to use `Extension` here, but what is the difference between `Warning`, `ExtWarn`, and `Extension`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125178



More information about the cfe-commits mailing list