This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG13629b140801: [C2x] Support -std=c23 and -std=gnu23 
(authored by aaron.ballman).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157606

Files:
  clang-tools-extra/clangd/index/StdLib.cpp
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/LangStandards.def
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/lib/Headers/limits.h
  clang/lib/Headers/stdalign.h
  clang/lib/Headers/stdarg.h
  clang/lib/Headers/stdatomic.h
  clang/lib/Headers/stddef.h
  clang/lib/Headers/stdint.h
  clang/test/C/C11/n1330.c
  clang/test/C/drs/dr0xx.c
  clang/test/C/drs/dr2xx.c
  clang/test/C/drs/dr3xx.c
  clang/test/C/drs/dr411.c
  clang/test/Driver/unknown-std.c
  clang/test/Headers/limits.cpp
  clang/test/Headers/stdint.c
  clang/test/Lexer/unicode.c
  clang/test/Lexer/utf8-char-literal.cpp
  clang/test/Preprocessor/c2x.c
  clang/test/Preprocessor/ucn-allowed-chars.c
  clang/test/Sema/atomic-expr.c

Index: clang/test/Sema/atomic-expr.c
===================================================================
--- clang/test/Sema/atomic-expr.c
+++ clang/test/Sema/atomic-expr.c
@@ -152,23 +152,23 @@
   _Atomic(const int *) acip5 = cicp;
   _Atomic(const void *) acvip3 = cicp;
 
-#if __STDC_VERSION__ >= 202000L
+#if __STDC_VERSION__ >= 202311L
   // the left operand has an atomic ... version of the nullptr_t type and the
   // right operand is a null pointer constant or its type is nullptr_t
   typedef typeof(nullptr) nullptr_t;
   nullptr_t n;
   _Atomic nullptr_t cn2 = n;
   _Atomic nullptr_t cn3 = nullptr;
-#endif // __STDC_VERSION__ >= 202000L
+#endif // __STDC_VERSION__ >= 202311L
 
   // the left operand is an atomic ... pointer, and the right operand is a null
   // pointer constant or its type is nullptr_t;
   _Atomic(int *) aip2 = 0;
-#if __STDC_VERSION__ >= 202000L
+#if __STDC_VERSION__ >= 202311L
   _Atomic(int *) ip2 = n;
   _Atomic(int *) ip3 = nullptr;
   _Atomic(const int *) ip4 = nullptr;
-#endif // __STDC_VERSION__ >= 202000L
+#endif // __STDC_VERSION__ >= 202311L
 }
 
 // Ensure that the assignment constraints also work at file scope.
@@ -185,14 +185,14 @@
 const void *cvp = 0;
 _Atomic(const int *) acip2 = cvp; // expected-error {{initializer element is not a compile-time constant}}
 
-#if __STDC_VERSION__ >= 202000L
+#if __STDC_VERSION__ >= 202311L
   // the left operand has an atomic ... version of the nullptr_t type and the
   // right operand is a null pointer constant or its type is nullptr_t
   typedef typeof(nullptr) nullptr_t;
   nullptr_t n;
   _Atomic nullptr_t cn2 = n; // expected-error {{initializer element is not a compile-time constant}}
   _Atomic(int *) aip2 = nullptr;
-#endif // __STDC_VERSION__ >= 202000L
+#endif // __STDC_VERSION__ >= 202311L
 
 // FIXME: &ai is an address constant, so this should be accepted as an
 // initializer, but the bit-cast inserted due to the pointer conversion is
Index: clang/test/Preprocessor/ucn-allowed-chars.c
===================================================================
--- clang/test/Preprocessor/ucn-allowed-chars.c
+++ clang/test/Preprocessor/ucn-allowed-chars.c
@@ -53,8 +53,8 @@
 
 # endif
 #else
-# if __STDC_VERSION__ >= 201800L
-// C2X
+# if __STDC_VERSION__ >= 202311L
+// C23
 // expected-warning@8 {{using this character in an identifier is incompatible with C99}}
 // expected-error@10 {{character <U+0384> not allowed in an identifier}}
 // expected-error@12 {{character <U+FFFF> not allowed in an identifier}}
Index: clang/test/Preprocessor/c2x.c
===================================================================
--- clang/test/Preprocessor/c2x.c
+++ clang/test/Preprocessor/c2x.c
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c2x %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c23 %s
 // expected-no-diagnostics
 
-// FIXME: Test the correct value once C23 ships.
-_Static_assert(__STDC_VERSION__ > 201710L, "Incorrect __STDC_VERSION__");
+_Static_assert(__STDC_VERSION__ == 202311L, "Incorrect __STDC_VERSION__");
Index: clang/test/Lexer/utf8-char-literal.cpp
===================================================================
--- clang/test/Lexer/utf8-char-literal.cpp
+++ clang/test/Lexer/utf8-char-literal.cpp
@@ -16,7 +16,7 @@
 char d = u8'\u1234'; // expected-error {{character too large for enclosing character literal type}}
 char e = u8'ሴ'; // expected-error {{character too large for enclosing character literal type}}
 char f = u8'ab'; // expected-error {{Unicode character literals may not contain multiple characters}}
-#elif __STDC_VERSION__ >= 202000L
+#elif __STDC_VERSION__ >= 202311L
 char a = u8'ñ';      // expected-error {{character too large for enclosing character literal type}}
 char b = u8'\x80';   // ok
 char c = u8'\u0000'; // ok
@@ -49,8 +49,8 @@
 #  endif
 #endif
 
-/// In C2x, u8 char literals are always unsigned.
-#if __STDC_VERSION__ >= 202000L
+/// In C23, u8 char literals are always unsigned.
+#if __STDC_VERSION__ >= 202311L
 #  if u8'\xff' == '\xff'// expected-warning {{right side of operator converted from negative value to unsigned}}
 #    error u8 char literal is not unsigned
 #  endif
Index: clang/test/Lexer/unicode.c
===================================================================
--- clang/test/Lexer/unicode.c
+++ clang/test/Lexer/unicode.c
@@ -32,7 +32,7 @@
 extern int X\UAAAAAAAA; // expected-error {{not allowed in an identifier}}
 int Y = '\UAAAAAAAA'; // expected-error {{invalid universal character}}
 
-#if defined(__cplusplus) || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202000L)
+#if defined(__cplusplus) || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L)
 
 extern int ༀ;
 extern int 𑩐;
Index: clang/test/Headers/stdint.c
===================================================================
--- clang/test/Headers/stdint.c
+++ clang/test/Headers/stdint.c
@@ -20,9 +20,7 @@
 
 #include <stdint.h>
 
-/* FIXME: This is using the placeholder dates Clang produces for these macros
-   in C2x mode; switch to the correct values once they've been published. */
-#if __STDC_VERSION__ >= 202000L
+#if __STDC_VERSION__ >= 202311L
 /* Validate the standard requirements. */
 _Static_assert(SIG_ATOMIC_WIDTH >= 8);
 _Static_assert(SIZE_WIDTH >= 16);
@@ -52,7 +50,7 @@
     INTPTR_WIDTH, UINTPTR_WIDTH, INTMAX_WIDTH, UINTMAX_WIDTH;
 #endif
 
-#if defined(INT8_MAX) && __STDC_VERSION__ >= 202000L
+#if defined(INT8_MAX) && __STDC_VERSION__ >= 202311L
 _Static_assert(INT8_WIDTH == 8, "");
 _Static_assert(UINT8_WIDTH == INT8_WIDTH, "");
 _Static_assert(INT8_WIDTH / __CHAR_BIT__ == sizeof(int8_t), "");
@@ -60,7 +58,7 @@
 #else
 int INT8_WIDTH, UINT8_WIDTH; /* None of these are defined. */
 #endif
-#if defined(INT_LEAST8_MAX) && __STDC_VERSION__ >= 202000L
+#if defined(INT_LEAST8_MAX) && __STDC_VERSION__ >= 202311L
 _Static_assert(INT_LEAST8_WIDTH >= 8, "");
 _Static_assert(INT_LEAST8_WIDTH / __CHAR_BIT__ == sizeof(int_least8_t), "");
 _Static_assert(UINT_LEAST8_WIDTH == INT_LEAST8_WIDTH, "");
@@ -68,7 +66,7 @@
 #else
 int INT_LEAST8_WIDTH, UINT_LEAST8_WIDTH; /* None of these are defined. */
 #endif
-#if defined(INT_FAST8_MAX) && __STDC_VERSION__ >= 202000L
+#if defined(INT_FAST8_MAX) && __STDC_VERSION__ >= 202311L
 _Static_assert(INT_FAST8_WIDTH >= 8, "");
 _Static_assert(INT_FAST8_WIDTH / __CHAR_BIT__ == sizeof(int_fast8_t), "");
 _Static_assert(UINT_FAST8_WIDTH == INT_FAST8_WIDTH, "");
@@ -77,7 +75,7 @@
 int INT_FAST8_WIDTH, UINT_FAST8_WIDTH; /* None of these are defined. */
 #endif
 
-#if defined(INT16_MAX) && __STDC_VERSION__ >= 202000L
+#if defined(INT16_MAX) && __STDC_VERSION__ >= 202311L
 _Static_assert(INT16_WIDTH == 16, "");
 _Static_assert(UINT16_WIDTH == INT16_WIDTH, "");
 _Static_assert(INT16_WIDTH / __CHAR_BIT__ == sizeof(int16_t), "");
@@ -85,7 +83,7 @@
 #else
 int INT16_WIDTH, UINT16_WIDTH; /* None of these are defined. */
 #endif
-#if defined(INT_LEAST16_MAX) && __STDC_VERSION__ >= 202000L
+#if defined(INT_LEAST16_MAX) && __STDC_VERSION__ >= 202311L
 _Static_assert(INT_LEAST16_WIDTH >= 16, "");
 _Static_assert(INT_LEAST16_WIDTH / __CHAR_BIT__ == sizeof(int_least16_t), "");
 _Static_assert(UINT_LEAST16_WIDTH == INT_LEAST16_WIDTH, "");
@@ -93,7 +91,7 @@
 #else
 int INT_LEAST16_WIDTH, UINT_LEAST16_WIDTH; /* None of these are defined. */
 #endif
-#if defined(INT_FAST16_MAX) && __STDC_VERSION__ >= 202000L
+#if defined(INT_FAST16_MAX) && __STDC_VERSION__ >= 202311L
 _Static_assert(INT_FAST16_WIDTH >= 16, "");
 _Static_assert(INT_FAST16_WIDTH / __CHAR_BIT__ == sizeof(int_fast16_t), "");
 _Static_assert(UINT_FAST16_WIDTH == INT_FAST16_WIDTH, "");
@@ -102,7 +100,7 @@
 int INT_FAST16_WIDTH, UINT_FAST16_WIDTH; /* None of these are defined. */
 #endif
 
-#if defined(INT24_MAX) && __STDC_VERSION__ >= 202000L
+#if defined(INT24_MAX) && __STDC_VERSION__ >= 202311L
 _Static_assert(INT24_WIDTH == 24, "");
 _Static_assert(UINT24_WIDTH == INT24_WIDTH, "");
 _Static_assert(INT24_WIDTH / __CHAR_BIT__ == sizeof(int24_t), "");
@@ -110,7 +108,7 @@
 #else
 int INT24_WIDTH, UINT24_WIDTH; /* None of these are defined. */
 #endif
-#if defined(INT_LEAST24_MAX) && __STDC_VERSION__ >= 202000L
+#if defined(INT_LEAST24_MAX) && __STDC_VERSION__ >= 202311L
 _Static_assert(INT_LEAST24_WIDTH >= 24, "");
 _Static_assert(INT_LEAST24_WIDTH / __CHAR_BIT__ == sizeof(int_least24_t), "");
 _Static_assert(UINT_LEAST24_WIDTH == INT_LEAST24_WIDTH, "");
@@ -118,7 +116,7 @@
 #else
 int INT_LEAST24_WIDTH, UINT_LEAST24_WIDTH; /* None of these are defined. */
 #endif
-#if defined(INT_FAST24_MAX) && __STDC_VERSION__ >= 202000L
+#if defined(INT_FAST24_MAX) && __STDC_VERSION__ >= 202311L
 _Static_assert(INT_FAST24_WIDTH >= 24, "");
 _Static_assert(INT_FAST24_WIDTH / __CHAR_BIT__ == sizeof(int_fast24_t), "");
 _Static_assert(UINT_FAST24_WIDTH == INT_FAST24_WIDTH, "");
@@ -127,7 +125,7 @@
 int INT_FAST24_WIDTH, UINT_FAST24_WIDTH; /* None of these are defined. */
 #endif
 
-#if defined(INT32_MAX) && __STDC_VERSION__ >= 202000L
+#if defined(INT32_MAX) && __STDC_VERSION__ >= 202311L
 _Static_assert(INT32_WIDTH == 32, "");
 _Static_assert(UINT32_WIDTH == INT32_WIDTH, "");
 _Static_assert(INT32_WIDTH / __CHAR_BIT__ == sizeof(int32_t), "");
@@ -135,7 +133,7 @@
 #else
 int INT32_WIDTH, UINT32_WIDTH; /* None of these are defined. */
 #endif
-#if defined(INT_LEAST32_MAX) && __STDC_VERSION__ >= 202000L
+#if defined(INT_LEAST32_MAX) && __STDC_VERSION__ >= 202311L
 _Static_assert(INT_LEAST32_WIDTH >= 32, "");
 _Static_assert(INT_LEAST32_WIDTH / __CHAR_BIT__ == sizeof(int_least32_t), "");
 _Static_assert(UINT_LEAST32_WIDTH == INT_LEAST32_WIDTH, "");
@@ -143,7 +141,7 @@
 #else
 int INT_LEAST32_WIDTH, UINT_LEAST32_WIDTH; /* None of these are defined. */
 #endif
-#if defined(INT_FAST32_MAX) && __STDC_VERSION__ >= 202000L
+#if defined(INT_FAST32_MAX) && __STDC_VERSION__ >= 202311L
 _Static_assert(INT_FAST32_WIDTH >= 32, "");
 _Static_assert(INT_FAST32_WIDTH / __CHAR_BIT__ == sizeof(int_fast32_t), "");
 _Static_assert(UINT_FAST32_WIDTH == INT_FAST32_WIDTH, "");
@@ -152,7 +150,7 @@
 int INT_FAST32_WIDTH, UINT_FAST32_WIDTH; /* None of these are defined. */
 #endif
 
-#if defined(INT40_MAX) && __STDC_VERSION__ >= 202000L
+#if defined(INT40_MAX) && __STDC_VERSION__ >= 202311L
 _Static_assert(INT40_WIDTH == 40, "");
 _Static_assert(UINT40_WIDTH == INT40_WIDTH, "");
 _Static_assert(INT40_WIDTH / __CHAR_BIT__ == sizeof(int40_t), "");
@@ -160,7 +158,7 @@
 #else
 int INT40_WIDTH, UINT40_WIDTH; /* None of these are defined. */
 #endif
-#if defined(INT_LEAST40_MAX) && __STDC_VERSION__ >= 202000L
+#if defined(INT_LEAST40_MAX) && __STDC_VERSION__ >= 202311L
 _Static_assert(INT_LEAST40_WIDTH >= 40, "");
 _Static_assert(INT_LEAST40_WIDTH / __CHAR_BIT__ == sizeof(int_least40_t), "");
 _Static_assert(UINT_LEAST40_WIDTH == INT_LEAST40_WIDTH, "");
@@ -168,7 +166,7 @@
 #else
 int INT_LEAST40_WIDTH, UINT_LEAST40_WIDTH; /* None of these are defined. */
 #endif
-#if defined(INT_FAST40_MAX) && __STDC_VERSION__ >= 202000L
+#if defined(INT_FAST40_MAX) && __STDC_VERSION__ >= 202311L
 _Static_assert(INT_FAST40_WIDTH >= 40, "");
 _Static_assert(INT_FAST40_WIDTH / __CHAR_BIT__ == sizeof(int_fast40_t), "");
 _Static_assert(UINT_FAST40_WIDTH == INT_FAST40_WIDTH, "");
@@ -177,7 +175,7 @@
 int INT_FAST40_WIDTH, UINT_FAST40_WIDTH; /* None of these are defined. */
 #endif
 
-#if defined(INT48_MAX) && __STDC_VERSION__ >= 202000L
+#if defined(INT48_MAX) && __STDC_VERSION__ >= 202311L
 _Static_assert(INT48_WIDTH == 48, "");
 _Static_assert(UINT48_WIDTH == INT48_WIDTH, "");
 _Static_assert(INT48_WIDTH / __CHAR_BIT__ == sizeof(int48_t), "");
@@ -185,7 +183,7 @@
 #else
 int INT48_WIDTH, UINT48_WIDTH; /* None of these are defined. */
 #endif
-#if defined(INT_LEAST48_MAX) && __STDC_VERSION__ >= 202000L
+#if defined(INT_LEAST48_MAX) && __STDC_VERSION__ >= 202311L
 _Static_assert(INT_LEAST48_WIDTH >= 48, "");
 _Static_assert(INT_LEAST48_WIDTH / __CHAR_BIT__ == sizeof(int_least48_t), "");
 _Static_assert(UINT_LEAST48_WIDTH == INT_LEAST48_WIDTH, "");
@@ -193,7 +191,7 @@
 #else
 int INT_LEAST48_WIDTH, UINT_LEAST48_WIDTH; /* None of these are defined. */
 #endif
-#if defined(INT_FAST48_MAX) && __STDC_VERSION__ >= 202000L
+#if defined(INT_FAST48_MAX) && __STDC_VERSION__ >= 202311L
 _Static_assert(INT_FAST48_WIDTH >= 48, "");
 _Static_assert(INT_FAST48_WIDTH / __CHAR_BIT__ == sizeof(int_fast48_t), "");
 _Static_assert(UINT_FAST48_WIDTH == INT_FAST48_WIDTH, "");
@@ -202,7 +200,7 @@
 int INT_FAST48_WIDTH, UINT_FAST48_WIDTH; /* None of these are defined. */
 #endif
 
-#if defined(INT56_MAX) && __STDC_VERSION__ >= 202000L
+#if defined(INT56_MAX) && __STDC_VERSION__ >= 202311L
 _Static_assert(INT56_WIDTH == 56, "");
 _Static_assert(UINT56_WIDTH == INT56_WIDTH, "");
 _Static_assert(INT56_WIDTH / __CHAR_BIT__ == sizeof(int56_t), "");
@@ -210,7 +208,7 @@
 #else
 int INT56_WIDTH, UINT56_WIDTH; /* None of these are defined. */
 #endif
-#if defined(INT_LEAST56_MAX) && __STDC_VERSION__ >= 202000L
+#if defined(INT_LEAST56_MAX) && __STDC_VERSION__ >= 202311L
 _Static_assert(INT_LEAST56_WIDTH >= 56, "");
 _Static_assert(INT_LEAST56_WIDTH / __CHAR_BIT__ == sizeof(int_least56_t), "");
 _Static_assert(UINT_LEAST56_WIDTH == INT_LEAST56_WIDTH, "");
@@ -218,7 +216,7 @@
 #else
 int INT_LEAST56_WIDTH, UINT_LEAST56_WIDTH; /* None of these are defined. */
 #endif
-#if defined(INT_FAST56_MAX) && __STDC_VERSION__ >= 202000L
+#if defined(INT_FAST56_MAX) && __STDC_VERSION__ >= 202311L
 _Static_assert(INT_FAST56_WIDTH >= 56, "");
 _Static_assert(INT_FAST56_WIDTH / __CHAR_BIT__ == sizeof(int_fast56_t), "");
 _Static_assert(UINT_FAST56_WIDTH == INT_FAST56_WIDTH, "");
@@ -227,7 +225,7 @@
 int INT_FAST56_WIDTH, UINT_FAST56_WIDTH; /* None of these are defined. */
 #endif
 
-#if defined(INT64_MAX) && __STDC_VERSION__ >= 202000L
+#if defined(INT64_MAX) && __STDC_VERSION__ >= 202311L
 _Static_assert(INT64_WIDTH == 64, "");
 _Static_assert(UINT64_WIDTH == INT64_WIDTH, "");
 _Static_assert(INT64_WIDTH / __CHAR_BIT__ == sizeof(int64_t), "");
@@ -235,7 +233,7 @@
 #else
 int INT64_WIDTH, UINT64_WIDTH; /* None of these are defined. */
 #endif
-#if defined(INT_LEAST64_MAX) && __STDC_VERSION__ >= 202000L
+#if defined(INT_LEAST64_MAX) && __STDC_VERSION__ >= 202311L
 _Static_assert(INT_LEAST64_WIDTH >= 64, "");
 _Static_assert(INT_LEAST64_WIDTH / __CHAR_BIT__ == sizeof(int_least64_t), "");
 _Static_assert(UINT_LEAST64_WIDTH == INT_LEAST64_WIDTH, "");
@@ -243,7 +241,7 @@
 #else
 int INT_LEAST64_WIDTH, UINT_LEAST64_WIDTH; /* None of these are defined. */
 #endif
-#if defined(INT_FAST64_MAX) && __STDC_VERSION__ >= 202000L
+#if defined(INT_FAST64_MAX) && __STDC_VERSION__ >= 202311L
 _Static_assert(INT_FAST64_WIDTH >= 64, "");
 _Static_assert(INT_FAST64_WIDTH / __CHAR_BIT__ == sizeof(int_fast64_t), "");
 _Static_assert(UINT_FAST64_WIDTH == INT_FAST64_WIDTH, "");
Index: clang/test/Headers/limits.cpp
===================================================================
--- clang/test/Headers/limits.cpp
+++ clang/test/Headers/limits.cpp
@@ -126,9 +126,7 @@
 int LLONG_MIN, LLONG_MAX, ULLONG_MAX; // Not defined.
 #endif
 
-/* FIXME: This is using the placeholder dates Clang produces for these macros
-   in C2x mode; switch to the correct values once they've been published. */
-#if __STDC_VERSION__ >= 202000L
+#if __STDC_VERSION__ >= 202311L
 /* Validate the standard requirements. */
 _Static_assert(BOOL_WIDTH >= 1);
 #if BOOL_WIDTH
Index: clang/test/Driver/unknown-std.c
===================================================================
--- clang/test/Driver/unknown-std.c
+++ clang/test/Driver/unknown-std.c
@@ -16,8 +16,8 @@
 // CHECK-NEXT: note: use 'gnu11' for 'ISO C 2011 with GNU extensions' standard
 // CHECK-NEXT: note: use 'c17', 'iso9899:2017', 'c18', or 'iso9899:2018' for 'ISO C 2017' standard
 // CHECK-NEXT: note: use 'gnu17' or 'gnu18' for 'ISO C 2017 with GNU extensions' standard
-// CHECK-NEXT: note: use 'c2x' for 'Working Draft for ISO C2x' standard
-// CHECK-NEXT: note: use 'gnu2x' for 'Working Draft for ISO C2x with GNU extensions' standard
+// CHECK-NEXT: note: use 'c23' for 'Working Draft for ISO C23' standard
+// CHECK-NEXT: note: use 'gnu23' for 'Working Draft for ISO C23 with GNU extensions' standard
 
 // Make sure that no other output is present.
 // CHECK-NOT: {{^.+$}}
Index: clang/test/C/drs/dr411.c
===================================================================
--- clang/test/C/drs/dr411.c
+++ clang/test/C/drs/dr411.c
@@ -25,8 +25,7 @@
 #elif defined(C17)
 _Static_assert(__STDC_VERSION__ == 201710L, "");
 #elif defined(C2X)
-/* FIXME: this value will change once WG14 picks the final value for C2x. */
-_Static_assert(__STDC_VERSION__ == 202000L, "");
+_Static_assert(__STDC_VERSION__ == 202311L, "");
 #else
 #error "unknown language standard version"
 #endif
Index: clang/test/C/drs/dr3xx.c
===================================================================
--- clang/test/C/drs/dr3xx.c
+++ clang/test/C/drs/dr3xx.c
@@ -114,7 +114,7 @@
  */
 _Static_assert(sizeof(dr315.c + dr315.d) == sizeof(int), "");
 
-#if __STDC_VERSION__ < 202000L
+#if __STDC_VERSION__ < 202311L
 /* WG14 DR316: yes
  * Unprototyped function types
  */
@@ -137,7 +137,7 @@
                    expected-warning {{passing arguments to 'dr317_1' without a prototype is deprecated in all versions of C and is not supported in C2x}}
                  */
 }
-#endif /* __STDC_VERSION__ < 202000L */
+#endif /* __STDC_VERSION__ < 202311L */
 
 /* WG14 DR320: yes
  * Scope of variably modified type
@@ -243,7 +243,7 @@
  * unclear whether the Clang behavior is intentional, but because the code is
  * UB, any behavior is acceptable.
  */
-#if __STDC_VERSION__ < 202000L
+#if __STDC_VERSION__ < 202311L
 void dr340(int x, int y) {
   typedef void (*T1)(int);
   typedef void (*T2)(); /* expected-warning {{a function declaration without a prototype is deprecated in all versions of C}} */
@@ -254,7 +254,7 @@
                          */
   (y ? a : b)[0][0]();
 }
-#endif /* __STDC_VERSION__ < 202000L */
+#endif /* __STDC_VERSION__ < 202311L */
 
 /* WG14 DR341: yes
  * [*] in abstract declarators
Index: clang/test/C/drs/dr2xx.c
===================================================================
--- clang/test/C/drs/dr2xx.c
+++ clang/test/C/drs/dr2xx.c
@@ -231,7 +231,7 @@
   struct dr251_fred *ptr; /* expected-error {{use of 'dr251_fred' with tag type that does not match previous declaration}} */
 }
 
-#if __STDC_VERSION__ < 202000L
+#if __STDC_VERSION__ < 202311L
 /* WG14 DR252: yes
  * Incomplete argument types when calling non-prototyped functions
  */
@@ -250,7 +250,7 @@
                                     expected-warning {{passing arguments to 'dr252_no_proto' without a prototype is deprecated in all versions of C and is not supported in C2x}}
                                   */
 }
-#endif /* __STDC_VERSION__ < 202000L */
+#endif /* __STDC_VERSION__ < 202311L */
 
 /* WG14 DR258: yes
  * Ordering of "defined" and macro replacement
Index: clang/test/C/drs/dr0xx.c
===================================================================
--- clang/test/C/drs/dr0xx.c
+++ clang/test/C/drs/dr0xx.c
@@ -234,7 +234,7 @@
  */
 int dr032 = (1, 2); /* expected-warning {{left operand of comma operator has no effect}} */
 
-#if __STDC_VERSION__ < 202000L
+#if __STDC_VERSION__ < 202311L
 /* WG14 DR035: partial
  * Questions about definition of functions without a prototype
  */
@@ -251,7 +251,7 @@
    */
   int test = q; /* expected-error {{use of undeclared identifier 'q'}} */
 }
-#endif /* __STDC_VERSION__ < 202000L */
+#endif /* __STDC_VERSION__ < 202311L */
 
 /* WG14 DR038: yes
  * Questions about argument substitution during macro expansion
@@ -339,7 +339,7 @@
   (void)NULL; /* expected-error {{use of undeclared identifier 'NULL'}} */
 }
 
-#if __STDC_VERSION__ < 202000L
+#if __STDC_VERSION__ < 202311L
 /* WG14 DR053: yes
  * Accessing a pointer to a function with a prototype through a pointer to
  * pointer to function without a prototype
@@ -356,7 +356,7 @@
   fpp = &fp1;
   (**fpp)(3); /* expected-warning {{passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x}} */
 }
-#endif /* __STDC_VERSION__ < 202000L */
+#endif /* __STDC_VERSION__ < 202311L */
 
 /* WG14 DR064: yes
  * Null pointer constants
@@ -385,7 +385,7 @@
 #endif
 }
 
-#if __STDC_VERSION__ < 202000L
+#if __STDC_VERSION__ < 202311L
 /* WG14: DR070: yes
  * Interchangeability of function arguments
  *
@@ -406,7 +406,7 @@
   dr070_1(6);
   dr070_1(6U); /* Pedantically UB */
 }
-#endif /* __STDC_VERSION__ < 202000L */
+#endif /* __STDC_VERSION__ < 202311L */
 
 /* WG14 DR071: yes
  * Enumerated types
Index: clang/test/C/C11/n1330.c
===================================================================
--- clang/test/C/C11/n1330.c
+++ clang/test/C/C11/n1330.c
@@ -58,9 +58,7 @@
   _Static_assert(1.0f, "this should not compile"); // expected-warning {{expression is not an integer constant expression; folding it to a constant is a GNU extension}}
 }
 
-// FIXME: This is using the placeholder date Clang produces for the macro in
-// C2x mode; switch to the correct value once it's been published.
-#if __STDC_VERSION__ < 202000L
+#if __STDC_VERSION__ < 202311L
 // The use of a _Static_assert in a K&R C function definition is prohibited per
 // 6.9.1p6 requiring each declaration to have a declarator (which a static
 // assertion does not have) and only declare identifiers from the identifier
Index: clang/lib/Headers/stdint.h
===================================================================
--- clang/lib/Headers/stdint.h
+++ clang/lib/Headers/stdint.h
@@ -499,9 +499,8 @@
 # define INT64_MAX           INT64_C( 9223372036854775807)
 # define INT64_MIN         (-INT64_C( 9223372036854775807)-1)
 # define UINT64_MAX         UINT64_C(18446744073709551615)
-/* FIXME: This is using the placeholder dates Clang produces for these macros
-   in C2x mode; switch to the correct values once they've been published. */
-#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202000L
+
+#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L
 # define UINT64_WIDTH         64
 # define INT64_WIDTH          UINT64_WIDTH
 
@@ -545,9 +544,7 @@
 # define INT_FAST64_MAX    __INT_LEAST64_MAX
 # define UINT_FAST64_MAX  __UINT_LEAST64_MAX
 
-/* FIXME: This is using the placeholder dates Clang produces for these macros
-   in C2x mode; switch to the correct values once they've been published. */
-#if defined(__STDC_VERSION__) &&  __STDC_VERSION__ >= 202000L
+#if defined(__STDC_VERSION__) &&  __STDC_VERSION__ >= 202311L
 # define UINT_LEAST64_WIDTH __UINT_LEAST64_WIDTH
 # define INT_LEAST64_WIDTH  UINT_LEAST64_WIDTH
 # define UINT_FAST64_WIDTH  __UINT_LEAST64_WIDTH
@@ -586,9 +583,7 @@
 # undef __UINT_LEAST8_MAX
 # define __UINT_LEAST8_MAX  UINT56_MAX
 
-/* FIXME: This is using the placeholder dates Clang produces for these macros
-   in C2x mode; switch to the correct values once they've been published. */
-#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202000L
+#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L
 # define UINT56_WIDTH         56
 # define INT56_WIDTH          UINT56_WIDTH
 # define UINT_LEAST56_WIDTH   UINT56_WIDTH
@@ -635,9 +630,7 @@
 # undef __UINT_LEAST8_MAX
 # define __UINT_LEAST8_MAX  UINT48_MAX
 
-/* FIXME: This is using the placeholder dates Clang produces for these macros
-   in C2x mode; switch to the correct values once they've been published. */
-#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202000L
+#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L
 #define UINT48_WIDTH         48
 #define INT48_WIDTH          UINT48_WIDTH
 #define UINT_LEAST48_WIDTH   UINT48_WIDTH
@@ -684,9 +677,7 @@
 # undef __UINT_LEAST8_MAX
 # define __UINT_LEAST8_MAX  UINT40_MAX
 
-/* FIXME: This is using the placeholder dates Clang produces for these macros
-   in C2x mode; switch to the correct values once they've been published. */
-#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202000L
+#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L
 # define UINT40_WIDTH         40
 # define INT40_WIDTH          UINT40_WIDTH
 # define UINT_LEAST40_WIDTH   UINT40_WIDTH
@@ -727,9 +718,7 @@
 # undef __UINT_LEAST8_MAX
 # define __UINT_LEAST8_MAX  UINT32_MAX
 
-/* FIXME: This is using the placeholder dates Clang produces for these macros
-   in C2x mode; switch to the correct values once they've been published. */
-#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202000L
+#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L
 # define UINT32_WIDTH         32
 # define INT32_WIDTH          UINT32_WIDTH
 # undef __UINT_LEAST32_WIDTH
@@ -749,9 +738,7 @@
 # define INT_FAST32_MAX    __INT_LEAST32_MAX
 # define UINT_FAST32_MAX  __UINT_LEAST32_MAX
 
-/* FIXME: This is using the placeholder dates Clang produces for these macros
-   in C2x mode; switch to the correct values once they've been published. */
-#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202000L
+#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L
 # define UINT_LEAST32_WIDTH __UINT_LEAST32_WIDTH
 # define INT_LEAST32_WIDTH  UINT_LEAST32_WIDTH
 # define UINT_FAST32_WIDTH  __UINT_LEAST32_WIDTH
@@ -784,9 +771,7 @@
 # undef __UINT_LEAST8_MAX
 # define __UINT_LEAST8_MAX  UINT24_MAX
 
-/* FIXME: This is using the placeholder dates Clang produces for these macros
-   in C2x mode; switch to the correct values once they've been published. */
-#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202000L
+#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L
 # define UINT24_WIDTH         24
 # define INT24_WIDTH          UINT24_WIDTH
 # define UINT_LEAST24_WIDTH   UINT24_WIDTH
@@ -819,9 +804,7 @@
 # undef __UINT_LEAST8_MAX
 # define __UINT_LEAST8_MAX  UINT16_MAX
 
-/* FIXME: This is using the placeholder dates Clang produces for these macros
-   in C2x mode; switch to the correct values once they've been published. */
-#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202000L
+#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L
 # define UINT16_WIDTH         16
 # define INT16_WIDTH          UINT16_WIDTH
 # undef __UINT_LEAST16_WIDTH
@@ -839,9 +822,7 @@
 # define INT_FAST16_MAX    __INT_LEAST16_MAX
 # define UINT_FAST16_MAX  __UINT_LEAST16_MAX
 
-/* FIXME: This is using the placeholder dates Clang produces for these macros
-   in C2x mode; switch to the correct values once they've been published. */
-#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202000L
+#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L
 # define UINT_LEAST16_WIDTH __UINT_LEAST16_WIDTH
 # define INT_LEAST16_WIDTH  UINT_LEAST16_WIDTH
 # define UINT_FAST16_WIDTH  __UINT_LEAST16_WIDTH
@@ -862,9 +843,7 @@
 # undef __UINT_LEAST8_MAX
 # define __UINT_LEAST8_MAX  UINT8_MAX
 
-/* FIXME: This is using the placeholder dates Clang produces for these macros
-   in C2x mode; switch to the correct values once they've been published. */
-#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202000L
+#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L
 # define UINT8_WIDTH         8
 # define INT8_WIDTH          UINT8_WIDTH
 # undef __UINT_LEAST8_WIDTH
@@ -880,9 +859,7 @@
 # define INT_FAST8_MAX    __INT_LEAST8_MAX
 # define UINT_FAST8_MAX  __UINT_LEAST8_MAX
 
-/* FIXME: This is using the placeholder dates Clang produces for these macros
-   in C2x mode; switch to the correct values once they've been published. */
-#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202000L
+#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L
 # define UINT_LEAST8_WIDTH __UINT_LEAST8_WIDTH
 # define INT_LEAST8_WIDTH  UINT_LEAST8_WIDTH
 # define UINT_FAST8_WIDTH  __UINT_LEAST8_WIDTH
@@ -908,9 +885,7 @@
 #define    SIZE_MAX      __SIZE_MAX__
 
 /* C2x 7.20.2.4 Width of integer types capable of holding object pointers. */
-/* FIXME: This is using the placeholder dates Clang produces for these macros
-   in C2x mode; switch to the correct values once they've been published. */
-#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202000L
+#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L
 /* NB: The C standard requires that these be the same value, but the compiler
    exposes separate internal width macros. */
 #define INTPTR_WIDTH  __INTPTR_WIDTH__
@@ -929,9 +904,7 @@
 #define UINTMAX_MAX  __UINTMAX_MAX__
 
 /* C2x 7.20.2.5 Width of greatest-width integer types. */
-/* FIXME: This is using the placeholder dates Clang produces for these macros
-   in C2x mode; switch to the correct values once they've been published. */
-#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202000L
+#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L
 /* NB: The C standard requires that these be the same value, but the compiler
    exposes separate internal width macros. */
 #define INTMAX_WIDTH __INTMAX_WIDTH__
@@ -965,9 +938,7 @@
 #define UINTMAX_C(v) __int_c(v, __UINTMAX_C_SUFFIX__)
 
 /* C2x 7.20.3.x Width of other integer types. */
-/* FIXME: This is using the placeholder dates Clang produces for these macros
-   in C2x mode; switch to the correct values once they've been published. */
-#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202000L
+#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L
 #define PTRDIFF_WIDTH    __PTRDIFF_WIDTH__
 #define SIG_ATOMIC_WIDTH __SIG_ATOMIC_WIDTH__
 #define SIZE_WIDTH       __SIZE_WIDTH__
Index: clang/lib/Headers/stddef.h
===================================================================
--- clang/lib/Headers/stddef.h
+++ clang/lib/Headers/stddef.h
@@ -97,14 +97,12 @@
 #undef __need_NULL
 #endif /* defined(__need_NULL) */
 
-/* FIXME: This is using the placeholder dates Clang produces for these macros
-   in C2x mode; switch to the correct values once they've been published. */
-#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202000L
+#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L
 typedef typeof(nullptr) nullptr_t;
-#endif /* defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202000L */
+#endif /* defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L */
 
 #if defined(__need_STDDEF_H_misc) && defined(__STDC_VERSION__) &&              \
-    __STDC_VERSION__ >= 202000L
+    __STDC_VERSION__ >= 202311L
 #define unreachable() __builtin_unreachable()
 #endif /* defined(__need_STDDEF_H_misc) && >= C23 */
 
Index: clang/lib/Headers/stdatomic.h
===================================================================
--- clang/lib/Headers/stdatomic.h
+++ clang/lib/Headers/stdatomic.h
@@ -45,16 +45,14 @@
 #define ATOMIC_POINTER_LOCK_FREE    __CLANG_ATOMIC_POINTER_LOCK_FREE
 
 /* 7.17.2 Initialization */
-/* FIXME: This is using the placeholder dates Clang produces for these macros
-   in C2x mode; switch to the correct values once they've been published. */
-#if (defined(__STDC_VERSION__) && __STDC_VERSION__ < 202000L) ||               \
+#if (defined(__STDC_VERSION__) && __STDC_VERSION__ < 202311L) ||               \
     defined(__cplusplus)
-/* ATOMIC_VAR_INIT was removed in C2x, but still remains in C++23. */
+/* ATOMIC_VAR_INIT was removed in C23, but still remains in C++23. */
 #define ATOMIC_VAR_INIT(value) (value)
 #endif
 
 #if ((defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201710L &&              \
-      __STDC_VERSION__ < 202000L) ||                                           \
+      __STDC_VERSION__ < 202311L) ||                                           \
      (defined(__cplusplus) && __cplusplus >= 202002L)) &&                      \
     !defined(_CLANG_DISABLE_CRT_DEPRECATION_WARNINGS)
 /* ATOMIC_VAR_INIT was deprecated in C17 and C++20. */
Index: clang/lib/Headers/stdarg.h
===================================================================
--- clang/lib/Headers/stdarg.h
+++ clang/lib/Headers/stdarg.h
@@ -23,13 +23,11 @@
 #define _VA_LIST
 #endif
 
-/* FIXME: This is using the placeholder dates Clang produces for these macros
-   in C2x mode; switch to the correct values once they've been published. */
-#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202000L
-/* C2x does not require the second parameter for va_start. */
+#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L
+/* C23 does not require the second parameter for va_start. */
 #define va_start(ap, ...) __builtin_va_start(ap, 0)
 #else
-/* Versions before C2x do require the second parameter. */
+/* Versions before C23 do require the second parameter. */
 #define va_start(ap, param) __builtin_va_start(ap, param)
 #endif
 #define va_end(ap)          __builtin_va_end(ap)
Index: clang/lib/Headers/stdalign.h
===================================================================
--- clang/lib/Headers/stdalign.h
+++ clang/lib/Headers/stdalign.h
@@ -10,10 +10,8 @@
 #ifndef __STDALIGN_H
 #define __STDALIGN_H
 
-/* FIXME: This is using the placeholder dates Clang produces for these macros
-   in C2x mode; switch to the correct values once they've been published. */
 #if defined(__cplusplus) ||                                                    \
-    (defined(__STDC_VERSION__) && __STDC_VERSION__ < 202000L)
+    (defined(__STDC_VERSION__) && __STDC_VERSION__ < 202311L)
 #ifndef __cplusplus
 #define alignas _Alignas
 #define alignof _Alignof
Index: clang/lib/Headers/limits.h
===================================================================
--- clang/lib/Headers/limits.h
+++ clang/lib/Headers/limits.h
@@ -67,9 +67,7 @@
 #define CHAR_BIT  __CHAR_BIT__
 
 /* C2x 5.2.4.2.1 */
-/* FIXME: This is using the placeholder dates Clang produces for these macros
-   in C2x mode; switch to the correct values once they've been published. */
-#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202000L
+#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L
 #define BOOL_WIDTH   __BOOL_WIDTH__
 #define CHAR_WIDTH   CHAR_BIT
 #define SCHAR_WIDTH  CHAR_BIT
Index: clang/lib/Frontend/InitPreprocessor.cpp
===================================================================
--- clang/lib/Frontend/InitPreprocessor.cpp
+++ clang/lib/Frontend/InitPreprocessor.cpp
@@ -438,9 +438,8 @@
   //      value is, are implementation-defined.
   // (Removed in C++20.)
   if (!LangOpts.CPlusPlus) {
-    // FIXME: Use correct value for C23.
     if (LangOpts.C2x)
-      Builder.defineMacro("__STDC_VERSION__", "202000L");
+      Builder.defineMacro("__STDC_VERSION__", "202311L");
     else if (LangOpts.C17)
       Builder.defineMacro("__STDC_VERSION__", "201710L");
     else if (LangOpts.C11)
Index: clang/include/clang/Basic/LangStandards.def
===================================================================
--- clang/include/clang/Basic/LangStandards.def
+++ clang/include/clang/Basic/LangStandards.def
@@ -87,13 +87,17 @@
              LineComment | C99 | C11 | C17 | Digraphs | GNUMode | HexFloat)
 LANGSTANDARD_ALIAS(gnu17, "gnu18")
 
-// C2x modes
-LANGSTANDARD(c2x, "c2x",
-             C, "Working Draft for ISO C2x",
+// C23 modes
+LANGSTANDARD(c23, "c23",
+             C, "Working Draft for ISO C23",
              LineComment | C99 | C11 | C17 | C2x | Digraphs | HexFloat)
-LANGSTANDARD(gnu2x, "gnu2x",
-             C, "Working Draft for ISO C2x with GNU extensions",
+LANGSTANDARD_ALIAS_DEPR(c23, "c2x")
+LANGSTANDARD(gnu23, "gnu23",
+             C, "Working Draft for ISO C23 with GNU extensions",
              LineComment | C99 | C11 | C17 | C2x | Digraphs | GNUMode | HexFloat)
+LANGSTANDARD_ALIAS_DEPR(gnu23, "gnu2x")
+// FIXME: Add the alias for iso9899:202* once we know the year ISO publishes
+// the document (expected to be 2024).
 
 // C++ modes
 LANGSTANDARD(cxx98, "c++98",
Index: clang/docs/ReleaseNotes.rst
===================================================================
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -98,6 +98,10 @@
 
 C2x Feature Support
 ^^^^^^^^^^^^^^^^^^^
+- Clang now accepts ``-std=c23`` and ``-std=gnu23`` as language standard modes,
+  and the ``__STDC_VERSION__`` macro now expands to ``202311L`` instead of its
+  previous placeholder value. Clang continues to accept ``-std=c2x`` and
+  ``-std=gnu2x`` as aliases for C23 and GNU C23, respectively.
 
 Non-comprehensive list of changes in this release
 -------------------------------------------------
Index: clang-tools-extra/clangd/index/StdLib.cpp
===================================================================
--- clang-tools-extra/clangd/index/StdLib.cpp
+++ clang-tools-extra/clangd/index/StdLib.cpp
@@ -60,7 +60,7 @@
     return LangStandard::lang_cxx98;
   }
   if (LO.C2x)
-    return LangStandard::lang_c2x;
+    return LangStandard::lang_c23;
   // C17 has no new features, so treat {C11,C17} as C17.
   if (LO.C11)
     return LangStandard::lang_c17;
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to