[clang] b8266f5 - Correct the __has_c_attribute value for fallthrough

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 13 08:09:33 PDT 2022


Author: Aaron Ballman
Date: 2022-09-13T11:08:58-04:00
New Revision: b8266f512a6218e8319379b65a637fa82b3900f6

URL: https://github.com/llvm/llvm-project/commit/b8266f512a6218e8319379b65a637fa82b3900f6
DIFF: https://github.com/llvm/llvm-project/commit/b8266f512a6218e8319379b65a637fa82b3900f6.diff

LOG: Correct the __has_c_attribute value for fallthrough

The original proposal was seen in Apr 2019 and we accidentally used
that date (201904L) as the feature testing value. However, WG14 N2408
was adopted at the Oct 2019 meeting and so that's the correct date for
the feature testing macro. The committee draft for C2x shows 201910L
for this value, so this changes brings us in line with the standard.

Added: 
    

Modified: 
    clang/docs/ReleaseNotes.rst
    clang/include/clang/Basic/Attr.td
    clang/test/Preprocessor/has_c_attribute.c
    clang/test/Sema/c2x-fallthrough.c

Removed: 
    


################################################################################
diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 9bc96f4dc1e9..dcc2eaf4b202 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -188,6 +188,11 @@ Attribute Changes in Clang
   supported the ability to specify a message in the attribute, so there were no
   changes to the attribute behavior.
 
+- Updated the value returned by ``__has_c_attribute(fallthrough)`` to ``201910L``
+  based on the final date specified by the C2x committee draft. We previously
+  used ``201904L`` (the date the proposal was seen by the committee) by mistake.
+  There were no other changes to the attribute behavior.
+
 Windows Support
 ---------------
 - For the MinGW driver, added the options ``-mguard=none``, ``-mguard=cf`` and

diff  --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td
index 48c7791ebe33..2e3297b72a8c 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -1412,7 +1412,7 @@ def ExtVectorType : Attr {
 
 def FallThrough : StmtAttr {
   let Spellings = [CXX11<"", "fallthrough", 201603>,
-                   C2x<"", "fallthrough", 201904>,
+                   C2x<"", "fallthrough", 201910>,
                    CXX11<"clang", "fallthrough">, GCC<"fallthrough">];
   // The attribute only applies to a NullStmt, but we have special fix-it
   // behavior if applied to a case label.

diff  --git a/clang/test/Preprocessor/has_c_attribute.c b/clang/test/Preprocessor/has_c_attribute.c
index 401daa72b85b..1da4d0541e6e 100644
--- a/clang/test/Preprocessor/has_c_attribute.c
+++ b/clang/test/Preprocessor/has_c_attribute.c
@@ -3,7 +3,7 @@
 
 #define C2x(x) x: __has_c_attribute(x)
 
-// CHECK: fallthrough: 201904L
+// CHECK: fallthrough: 201910L
 C2x(fallthrough)
 
 // CHECK: __nodiscard__: 202003L

diff  --git a/clang/test/Sema/c2x-fallthrough.c b/clang/test/Sema/c2x-fallthrough.c
index baa62aa8f140..092d5285f80b 100644
--- a/clang/test/Sema/c2x-fallthrough.c
+++ b/clang/test/Sema/c2x-fallthrough.c
@@ -1,4 +1,7 @@
-// RUN: %clang_cc1 -fsyntax-only -fdouble-square-bracket-attributes -verify %s
+// RUN: %clang_cc1 -fsyntax-only -std=c2x -verify %s
+
+// This is the latest version of fallthrough that we support.
+_Static_assert(__has_c_attribute(fallthrough) == 201910L);
 
 void f(int n) {
   switch (n) {


        


More information about the cfe-commits mailing list