[PATCH] D130415: [Clang] Adjust extension warnings for #warning

Corentin Jabot via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Jul 23 05:02:17 PDT 2022


cor3ntin added inline comments.


================
Comment at: clang/include/clang/Basic/DiagnosticLexKinds.td:393-398
+def warn_cxx2b_compat_warning_directive : Warning<
+  "#warning is incompatible with C++ standards before C++2b">,
+  InGroup<CXXPre2bCompat>, DefaultIgnore;
+def warn_c2x_compat_warning_directive : Warning<
+  "#warning is incompatible with C standards before C2x">,
+  InGroup<CPre2xCompat>, DefaultIgnore;
----------------
aaron.ballman wrote:
> <Not Your Problem>Someday, it would be nice if we made the tablegen for diagnostics a wee bit smarter so that we don't need to use two separate warning declarations for this situation. In fact, it'd be nice if tablegen could just automate this pattern given how often we use it and will be using it in the future.</Not Your Problem>
That would be great indeed!


================
Comment at: clang/lib/Lex/PPDirectives.cpp:1264-1273
+      if (LangOpts.CPlusPlus)
+        Diag(Result, LangOpts.CPlusPlus2b
+                         ? diag::warn_cxx2b_compat_warning_directive
+                         : diag::ext_pp_warning_directive)
+            << /*C++2b*/ 1;
+      else
+        Diag(Result, LangOpts.C2x ? diag::warn_c2x_compat_warning_directive
----------------
aaron.ballman wrote:
> Similarly (and also not your problem), it'd be nice to have a helper function so that we don't need this complicated of a dance to diagnose the situation.
Agreed!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130415



More information about the cfe-commits mailing list