Correct the __has_c_attribute value for nodiscard

The original proposal was adopted in Apr 2019 and so the previous value
was 201904L. However, a subsequent proposal (N2448) was adopted to add
an optional message argument to the attribute. We already support that
functionality, but had not bumped the feature test value.
This commit is contained in:
Aaron Ballman 2022-09-13 08:09:55 -04:00
parent 7f57b646d1
commit 1b19df12b8
4 changed files with 13 additions and 5 deletions

View File

@ -183,6 +183,11 @@ Attribute Changes in Clang
- Introduced a new function attribute ``__attribute__((nouwtable))`` to suppress
LLVM IR ``uwtable`` function attribute.
- Updated the value returned by ``__has_c_attribute(nodiscard)`` to ``202003L``
based on the final date specified by the C2x committee draft. We already
supported the ability to specify a message in the attribute, so there were no
changes to the attribute behavior.
Windows Support
---------------
- For the MinGW driver, added the options ``-mguard=none``, ``-mguard=cf`` and

View File

@ -2987,7 +2987,7 @@ def WarnUnused : InheritableAttr {
def WarnUnusedResult : InheritableAttr {
let Spellings = [CXX11<"", "nodiscard", 201907>,
C2x<"", "nodiscard", 201904>,
C2x<"", "nodiscard", 202003>,
CXX11<"clang", "warn_unused_result">,
GCC<"warn_unused_result">];
let Subjects = SubjectList<[ObjCMethod, Enum, Record, FunctionLike, TypedefName]>;

View File

@ -6,7 +6,7 @@
// CHECK: fallthrough: 201904L
C2x(fallthrough)
// CHECK: __nodiscard__: 201904L
// CHECK: __nodiscard__: 202003L
C2x(__nodiscard__)
// CHECK: selectany: 0
@ -27,10 +27,10 @@ C2x(deprecated)
// CHECK: maybe_unused: 201904L
C2x(maybe_unused)
// CHECK: __gnu__::warn_unused_result: 201904L
// CHECK: __gnu__::warn_unused_result: 202003L
C2x(__gnu__::warn_unused_result)
// CHECK: gnu::__warn_unused_result__: 201904L
// CHECK: gnu::__warn_unused_result__: 202003L
C2x(gnu::__warn_unused_result__)
// Test that macro expansion of the builtin argument works.

View File

@ -1,12 +1,15 @@
// RUN: %clang_cc1 -fsyntax-only -std=c2x -verify %s
// This is the latest version of nodiscard that we support.
_Static_assert(__has_c_attribute(nodiscard) == 202003L);
struct [[nodiscard]] S1 { // ok
int i;
};
struct [[nodiscard, nodiscard]] S2 { // ok
int i;
};
struct [[nodiscard("Wrong")]] S3 { // FIXME: may need an extension warning.
struct [[nodiscard("Wrong")]] S3 {
int i;
};