diff options
Diffstat (limited to 'clang')
-rw-r--r-- | clang/docs/ReleaseNotes.rst | 6 | ||||
-rw-r--r-- | clang/docs/UsersManual.rst | 10 | ||||
-rw-r--r-- | clang/include/clang/Basic/LangOptions.def | 1 | ||||
-rw-r--r-- | clang/include/clang/Basic/LangStandard.h | 28 | ||||
-rw-r--r-- | clang/include/clang/Basic/LangStandards.def | 9 | ||||
-rw-r--r-- | clang/lib/Basic/LangOptions.cpp | 1 | ||||
-rw-r--r-- | clang/lib/Frontend/InitPreprocessor.cpp | 4 | ||||
-rw-r--r-- | clang/test/Driver/unknown-std.c | 2 | ||||
-rw-r--r-- | clang/www/c_status.html | 5 |
9 files changed, 47 insertions, 19 deletions
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index fd8d9ad..e4707bf 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -320,6 +320,12 @@ Resolutions to C++ Defect Reports C Language Changes ------------------ +C2y Feature Support +^^^^^^^^^^^^^^^^^^^ +- Clang now enables C2y mode with ``-std=c2y``. This sets ``__STDC_VERSION__`` + to ``202400L`` so that it's greater than the value for C23. The value of this + macro is subject to change in the future. + C23 Feature Support ^^^^^^^^^^^^^^^^^^^ - No longer diagnose use of binary literals as an extension in C23 mode. Fixes diff --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst index d273102..087c75b 100644 --- a/clang/docs/UsersManual.rst +++ b/clang/docs/UsersManual.rst @@ -3458,9 +3458,9 @@ Differences between various standard modes clang supports the -std option, which changes what language mode clang uses. The supported modes for C are c89, gnu89, c94, c99, gnu99, c11, gnu11, c17, -gnu17, c23, gnu23, and various aliases for those modes. If no -std option is -specified, clang defaults to gnu17 mode. Many C99 and C11 features are -supported in earlier modes as a conforming extension, with a warning. Use +gnu17, c23, gnu23, c2y, gnu2y, and various aliases for those modes. If no -std +option is specified, clang defaults to gnu17 mode. Many C99 and C11 features +are supported in earlier modes as a conforming extension, with a warning. Use ``-pedantic-errors`` to request an error if a feature from a later standard revision is used in an earlier mode. @@ -3523,6 +3523,10 @@ Differences between ``*17`` and ``*23`` modes: - ``[[]]`` attributes are supported by default in ``*23`` mode, and as an extension in ``*17`` and earlier modes. +Differences between ``*23`` and ``*2y`` modes: + +- ``__STDC_VERSION__`` is defined to ``202400L`` rather than ``202311L``. + GCC extensions not implemented yet ---------------------------------- diff --git a/clang/include/clang/Basic/LangOptions.def b/clang/include/clang/Basic/LangOptions.def index 6dd6b56..491759e 100644 --- a/clang/include/clang/Basic/LangOptions.def +++ b/clang/include/clang/Basic/LangOptions.def @@ -87,6 +87,7 @@ LANGOPT(C99 , 1, 0, "C99") LANGOPT(C11 , 1, 0, "C11") LANGOPT(C17 , 1, 0, "C17") LANGOPT(C23 , 1, 0, "C23") +LANGOPT(C2y , 1, 0, "C2y") LANGOPT(MSVCCompat , 1, 0, "Microsoft Visual C++ full compatibility mode") LANGOPT(Kernel , 1, 0, "Kernel mode") LANGOPT(MicrosoftExt , 1, 0, "Microsoft C++ extensions") diff --git a/clang/include/clang/Basic/LangStandard.h b/clang/include/clang/Basic/LangStandard.h index 8e25afc..f79b4aa 100644 --- a/clang/include/clang/Basic/LangStandard.h +++ b/clang/include/clang/Basic/LangStandard.h @@ -52,18 +52,19 @@ enum LangFeatures { C11 = (1 << 2), C17 = (1 << 3), C23 = (1 << 4), - CPlusPlus = (1 << 5), - CPlusPlus11 = (1 << 6), - CPlusPlus14 = (1 << 7), - CPlusPlus17 = (1 << 8), - CPlusPlus20 = (1 << 9), - CPlusPlus23 = (1 << 10), - CPlusPlus26 = (1 << 11), - Digraphs = (1 << 12), - GNUMode = (1 << 13), - HexFloat = (1 << 14), - OpenCL = (1 << 15), - HLSL = (1 << 16) + C2y = (1 << 5), + CPlusPlus = (1 << 6), + CPlusPlus11 = (1 << 7), + CPlusPlus14 = (1 << 8), + CPlusPlus17 = (1 << 9), + CPlusPlus20 = (1 << 10), + CPlusPlus23 = (1 << 11), + CPlusPlus26 = (1 << 12), + Digraphs = (1 << 13), + GNUMode = (1 << 14), + HexFloat = (1 << 15), + OpenCL = (1 << 16), + HLSL = (1 << 17) }; /// LangStandard - Information about the properties of a particular language @@ -106,6 +107,9 @@ public: /// isC23 - Language is a superset of C23. bool isC23() const { return Flags & C23; } + /// isC2y - Language is a superset of C2y. + bool isC2y() const { return Flags & C2y; } + /// isCPlusPlus - Language is a C++ variant. bool isCPlusPlus() const { return Flags & CPlusPlus; } diff --git a/clang/include/clang/Basic/LangStandards.def b/clang/include/clang/Basic/LangStandards.def index b6192e4..f0c2593 100644 --- a/clang/include/clang/Basic/LangStandards.def +++ b/clang/include/clang/Basic/LangStandards.def @@ -99,6 +99,15 @@ 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). +// C2y modes +LANGSTANDARD(c2y, "c2y", + C, "Working Draft for ISO C2y", + LineComment | C99 | C11 | C17 | C23 | C2y | Digraphs | HexFloat) +LANGSTANDARD(gnu2y, "gnu2y", + C, "Working Draft for ISO C2y with GNU extensions", + LineComment | C99 | C11 | C17 | C23 | C2y | Digraphs | GNUMode | HexFloat) + + // C++ modes LANGSTANDARD(cxx98, "c++98", CXX, "ISO C++ 1998 with amendments", diff --git a/clang/lib/Basic/LangOptions.cpp b/clang/lib/Basic/LangOptions.cpp index 2b90646..61072b7 100644 --- a/clang/lib/Basic/LangOptions.cpp +++ b/clang/lib/Basic/LangOptions.cpp @@ -112,6 +112,7 @@ void LangOptions::setLangDefaults(LangOptions &Opts, Language Lang, Opts.C11 = Std.isC11(); Opts.C17 = Std.isC17(); Opts.C23 = Std.isC23(); + Opts.C2y = Std.isC2y(); Opts.CPlusPlus = Std.isCPlusPlus(); Opts.CPlusPlus11 = Std.isCPlusPlus11(); Opts.CPlusPlus14 = Std.isCPlusPlus14(); diff --git a/clang/lib/Frontend/InitPreprocessor.cpp b/clang/lib/Frontend/InitPreprocessor.cpp index 55ec460..5e52555 100644 --- a/clang/lib/Frontend/InitPreprocessor.cpp +++ b/clang/lib/Frontend/InitPreprocessor.cpp @@ -448,7 +448,9 @@ static void InitializeStandardPredefinedMacros(const TargetInfo &TI, // value is, are implementation-defined. // (Removed in C++20.) if (!LangOpts.CPlusPlus) { - if (LangOpts.C23) + if (LangOpts.C2y) + Builder.defineMacro("__STDC_VERSION__", "202400L"); + else if (LangOpts.C23) Builder.defineMacro("__STDC_VERSION__", "202311L"); else if (LangOpts.C17) Builder.defineMacro("__STDC_VERSION__", "201710L"); diff --git a/clang/test/Driver/unknown-std.c b/clang/test/Driver/unknown-std.c index 564c633..8f9047b 100644 --- a/clang/test/Driver/unknown-std.c +++ b/clang/test/Driver/unknown-std.c @@ -18,6 +18,8 @@ // CHECK-NEXT: note: use 'gnu17' or 'gnu18' for 'ISO C 2017 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 +// CHECK-NEXT: note: use 'c2y' for 'Working Draft for ISO C2y' standard +// CHECK-NEXT: note: use 'gnu2y' for 'Working Draft for ISO C2y with GNU extensions' standard // Make sure that no other output is present. // CHECK-NOT: {{^.+$}} diff --git a/clang/www/c_status.html b/clang/www/c_status.html index 8e42b81..ccb39a1 100644 --- a/clang/www/c_status.html +++ b/clang/www/c_status.html @@ -71,7 +71,7 @@ </tr> <tr> <td><a href="#c2y">C2y</a></td> - <td><tt>(Flag currently unavailable)</tt></td> + <td><tt>-std=c2y</tt></td> <td class="partial" align="center">Partial</td> </tr> </table> @@ -1229,8 +1229,7 @@ conforms by not defining the <code>__STDC_IEC_559_COMPLEX__</code> macro. <p>Clang has support for some of the features of the C standard following C23, informally referred to as C2y.</p> -<p>Clang currently does not expose a language standard mode flag for C2y. -<!--You can use Clang in C2y mode with the <code>-std=c2y</code> option (available in Clang 19 and later).--></p> +<p>You can use Clang in C2y mode with the <code>-std=c2y</code> option (available in Clang 19 and later).</p> <details open> <summary>List of features and minimum Clang version with support</summary> |