[PATCH] D116833: [clang][Sema] Disable -Wc++20-designator in system macros

Richard Smith - zygoloid via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 7 11:16:01 PST 2022


rsmith added inline comments.


================
Comment at: clang/lib/Sema/SemaExpr.cpp:7161
+        !DiagnosedNestedDesignator && !DiagnosedMixedDesignator &&
+        !getSourceManager().isInSystemMacro(FirstDesignator)) {
       Diag(FirstDesignator, getLangOpts().CPlusPlus20
----------------
I think we should be checking `Diags.getSuppressSystemWarnings()` before considering whether we're in a system header. (Eg, if we're building libc++ and it enables warnings even in system headers, we want to warn if it uses non-C++ designator syntax.)

Given that this is something that we will presumably want to do for a bunch of diagnostics, not just this one, I think we should extend the current `ShowInSystemHeader` / `SuppressInSystemHeader` markings in our diagnostics `.td` files to also have a `SuppressInSystemMacro` level, and handle this centrally with the other "suppress warnings in system headers" logic, rather than special-casing this here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116833



More information about the cfe-commits mailing list