[all-commits] [llvm/llvm-project] a18632: Add diagnostic groups for attribute extensions

Aaron Ballman via All-commits all-commits at lists.llvm.org
Tue Dec 7 08:50:08 PST 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: a18632adc884397e0cd7f27bdb8ea3a822b63000
      https://github.com/llvm/llvm-project/commit/a18632adc884397e0cd7f27bdb8ea3a822b63000
  Author: Aaron Ballman <aaron at aaronballman.com>
  Date:   2021-12-07 (Tue, 07 Dec 2021)

  Changed paths:
    M clang/docs/ReleaseNotes.rst
    M clang/include/clang/Basic/DiagnosticGroups.td
    M clang/include/clang/Basic/DiagnosticSemaKinds.td
    A clang/test/SemaCXX/attr-extension-diags.cpp

  Log Message:
  -----------
  Add diagnostic groups for attribute extensions

Some users have a need to control attribute extension diagnostics
independent of other extension diagnostics. Consider something like use
of [[nodiscard]] within C++11:
```
[[nodiscard]]
int f();
```
If compiled with -Wc++17-extensions enabled, this will produce warning:
use of the 'nodiscard' attribute is a C++17 extension. This diagnostic
is correct -- using [[nodiscard]] in C++11 mode is a C++17 extension.
And the behavior of __has_cpp_attribute(nodiscard) is also correct --
we support [[nodiscard]] in C++11 mode as a conforming extension. But
this makes use of -Werror or -pedantic-errors` builds more onerous.

This patch adds diagnostic groups for attribute extensions so that
users can selectively disable attribute extension diagnostics. I
believe this is preferable to requiring users to specify additional
flags because it means -Wc++17-extensions continues to be the way we
enable all C++17-related extension diagnostics. It would be quite easy
for someone to use that flag thinking they're protected from some
portability issues without realizing it skipped attribute extensions if
we went the other way.

This addresses PR33518.




More information about the All-commits mailing list