Index: clang/docs/CommandGuide/clang.rst =================================================================== --- clang/docs/CommandGuide/clang.rst +++ clang/docs/CommandGuide/clang.rst @@ -201,6 +201,14 @@ ISO C++ 2023 with amendments and GNU extensions + | ``c++2c`` + + Working draft for ISO C++ 2026 + + | ``gnu++2c`` + + Working draft for ISO C++ 2026 with GNU extensions + The default C++ language standard is ``gnu++17``. Supported values for the OpenCL language are: Index: clang/docs/ReleaseNotes.rst =================================================================== --- clang/docs/ReleaseNotes.rst +++ clang/docs/ReleaseNotes.rst @@ -109,6 +109,10 @@ functions. Which include allowing non-literal types as return values and paremeters, allow calling of non-constexpr functions and constructors. +C++2c Feature Support +^^^^^^^^^^^^^^^^^^^^^ +- Compiler flags -std=c++2c and -std=gnu++2c have been added for experimental C++26 implementation work. + Resolutions to C++ Defect Reports ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - Implemented `DR2397 `_ which allows ``auto`` specifier for pointers Index: clang/include/clang/Basic/DiagnosticGroups.td =================================================================== --- clang/include/clang/Basic/DiagnosticGroups.td +++ clang/include/clang/Basic/DiagnosticGroups.td @@ -307,6 +307,9 @@ def CXXPre23Compat : DiagGroup<"pre-c++23-compat">; def CXXPre23CompatPedantic : DiagGroup<"pre-c++23-compat-pedantic", [CXXPre23Compat]>; +def CXXPre26Compat : DiagGroup<"pre-c++26-compat">; +def CXXPre26CompatPedantic : + DiagGroup<"pre-c++26-compat-pedantic", [CXXPre26Compat]>; def CXX98CompatBindToTemporaryCopy : DiagGroup<"c++98-compat-bind-to-temporary-copy">; @@ -1112,6 +1115,10 @@ // earlier C++ versions. def CXX23 : DiagGroup<"c++23-extensions">; +// A warning group for warnings about using C++26 features as extensions in +// earlier C++ versions. +def CXX26 : DiagGroup<"c++26-extensions">; + def : DiagGroup<"c++0x-extensions", [CXX11]>; def : DiagGroup<"c++1y-extensions", [CXX14]>; def : DiagGroup<"c++1z-extensions", [CXX17]>; Index: clang/include/clang/Basic/LangOptions.def =================================================================== --- clang/include/clang/Basic/LangOptions.def +++ clang/include/clang/Basic/LangOptions.def @@ -98,6 +98,7 @@ LANGOPT(CPlusPlus17 , 1, 0, "C++17") LANGOPT(CPlusPlus20 , 1, 0, "C++20") LANGOPT(CPlusPlus23 , 1, 0, "C++23") +LANGOPT(CPlusPlus26 , 1, 0, "C++26") LANGOPT(ObjC , 1, 0, "Objective-C") BENIGN_LANGOPT(ObjCDefaultSynthProperties , 1, 0, "Objective-C auto-synthesized properties") Index: clang/include/clang/Basic/LangStandard.h =================================================================== --- clang/include/clang/Basic/LangStandard.h +++ clang/include/clang/Basic/LangStandard.h @@ -56,11 +56,12 @@ CPlusPlus17 = (1 << 8), CPlusPlus20 = (1 << 9), CPlusPlus23 = (1 << 10), - Digraphs = (1 << 11), - GNUMode = (1 << 12), - HexFloat = (1 << 13), - OpenCL = (1 << 14), - HLSL = (1 << 15) + CPlusPlus26 = (1 << 11), + Digraphs = (1 << 12), + GNUMode = (1 << 13), + HexFloat = (1 << 14), + OpenCL = (1 << 15), + HLSL = (1 << 16) }; /// LangStandard - Information about the properties of a particular language @@ -121,7 +122,10 @@ /// isCPlusPlus23 - Language is a post-C++23 variant (or later). bool isCPlusPlus23() const { return Flags & CPlusPlus23; } - /// hasDigraphs - Language supports digraphs. + /// isCPlusPlus26 - Language is a post-C++26 variant (or later). + bool isCPlusPlus26() const { return Flags & CPlusPlus26; } + + // hasDigraphs - Language supports digraphs. bool hasDigraphs() const { return Flags & Digraphs; } /// isGNUMode - Language includes GNU extensions. Index: clang/include/clang/Basic/LangStandards.def =================================================================== --- clang/include/clang/Basic/LangStandards.def +++ clang/include/clang/Basic/LangStandards.def @@ -163,6 +163,18 @@ CPlusPlus20 | CPlusPlus23 | Digraphs | HexFloat | GNUMode) LANGSTANDARD_ALIAS_DEPR(gnucxx23, "gnu++2b") +LANGSTANDARD(cxx26, "c++2c", + CXX, "Working draft for ISO C++ 2026 DIS", + LineComment | CPlusPlus | CPlusPlus11 | CPlusPlus14 | CPlusPlus17 | + CPlusPlus20 | CPlusPlus23 | CPlusPlus26 | Digraphs | HexFloat) +LANGSTANDARD_ALIAS(cxx26, "c++26") + +LANGSTANDARD(gnucxx26, "gnu++2c", + CXX, "Working draft for ISO C++ 2026 DIS with GNU extensions", + LineComment | CPlusPlus | CPlusPlus11 | CPlusPlus14 | CPlusPlus17 | + CPlusPlus20 | CPlusPlus23 | CPlusPlus26 | Digraphs | HexFloat | GNUMode) +LANGSTANDARD_ALIAS(gnucxx26, "gnu++26") + // OpenCL LANGSTANDARD(opencl10, "cl1.0", OpenCL, "OpenCL 1.0", Index: clang/lib/Basic/LangOptions.cpp =================================================================== --- clang/lib/Basic/LangOptions.cpp +++ clang/lib/Basic/LangOptions.cpp @@ -118,6 +118,7 @@ Opts.CPlusPlus17 = Std.isCPlusPlus17(); Opts.CPlusPlus20 = Std.isCPlusPlus20(); Opts.CPlusPlus23 = Std.isCPlusPlus23(); + Opts.CPlusPlus26 = Std.isCPlusPlus26(); Opts.GNUMode = Std.isGNUMode(); Opts.GNUCVersion = 0; Opts.HexFloats = Std.hasHexFloats(); Index: clang/lib/Driver/Driver.cpp =================================================================== --- clang/lib/Driver/Driver.cpp +++ clang/lib/Driver/Driver.cpp @@ -1397,6 +1397,7 @@ !Args.hasArg(options::OPT_fmodules) && Std && (Std->containsValue("c++20") || Std->containsValue("c++2a") || Std->containsValue("c++23") || Std->containsValue("c++2b") || + Std->containsValue("c++26") || Std->containsValue("c++2c") || Std->containsValue("c++latest")); // Process -fmodule-header{=} flags. Index: clang/lib/Driver/ToolChains/Clang.cpp =================================================================== --- clang/lib/Driver/ToolChains/Clang.cpp +++ clang/lib/Driver/ToolChains/Clang.cpp @@ -3674,6 +3674,7 @@ IsCXX && Std && (Std->containsValue("c++2a") || Std->containsValue("c++20") || Std->containsValue("c++2b") || Std->containsValue("c++23") || + Std->containsValue("c++2c") || Std->containsValue("c++26") || Std->containsValue("c++latest")); bool HaveModules = HaveStdCXXModules; Index: clang/lib/Frontend/InitPreprocessor.cpp =================================================================== --- clang/lib/Frontend/InitPreprocessor.cpp +++ clang/lib/Frontend/InitPreprocessor.cpp @@ -451,8 +451,11 @@ Builder.defineMacro("__STDC_VERSION__", "199409L"); } else { // -- __cplusplus - // FIXME: Use correct value for C++23. - if (LangOpts.CPlusPlus23) + if (LangOpts.CPlusPlus26) + // FIXME: Use correct value for C++26. + Builder.defineMacro("__cplusplus", "202102L"); + // FIXME: Use correct value for C++23, and update C++26 to be 'one more'. + else if (LangOpts.CPlusPlus23) Builder.defineMacro("__cplusplus", "202101L"); // [C++20] The integer literal 202002L. else if (LangOpts.CPlusPlus20) Index: clang/test/Driver/unknown-std.cpp =================================================================== --- clang/test/Driver/unknown-std.cpp +++ clang/test/Driver/unknown-std.cpp @@ -19,6 +19,8 @@ // CHECK-NEXT: note: use 'gnu++20' for 'ISO C++ 2020 DIS with GNU extensions' standard // CHECK-NEXT: note: use 'c++23' for 'ISO C++ 2023 DIS' standard // CHECK-NEXT: note: use 'gnu++23' for 'ISO C++ 2023 DIS with GNU extensions' standard +// CHECK-NEXT: note: use 'c++2c' or 'c++26' for 'Working draft for ISO C++ 2026 DIS' standard +// CHECK-NEXT: note: use 'gnu++2c' or 'gnu++26' for 'Working draft for ISO C++ 2026 DIS with GNU extensions' standard // CUDA-NEXT: note: use 'cuda' for 'NVIDIA CUDA(tm)' standard // Make sure that no other output is present. Index: clang/test/Preprocessor/init.c =================================================================== --- clang/test/Preprocessor/init.c +++ clang/test/Preprocessor/init.c @@ -8,8 +8,18 @@ // BLOCKS:#define __BLOCKS__ 1 // BLOCKS:#define __block __attribute__((__blocks__(byref))) // +// RUN: %clang_cc1 -x c++ -fgnuc-version=4.2.1 -std=c++26 -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix CXX26 %s +// RUN: %clang_cc1 -x c++ -fgnuc-version=4.2.1 -std=c++2c -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix CXX26 %s +// +// CXX26:#define __GNUG__ 4 +// CXX26:#define __GXX_EXPERIMENTAL_CXX0X__ 1 +// CXX26:#define __GXX_RTTI 1 +// CXX26:#define __GXX_WEAK__ 1 +// CXX26:#define __cplusplus 202102L +// CXX26:#define __private_extern__ extern // // RUN: %clang_cc1 -x c++ -fgnuc-version=4.2.1 -std=c++23 -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix CXX2B %s +// RUN: %clang_cc1 -x c++ -fgnuc-version=4.2.1 -std=c++2b -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix CXX2B %s // // CXX2B:#define __GNUG__ 4 // CXX2B:#define __GXX_EXPERIMENTAL_CXX0X__ 1 @@ -133,7 +143,16 @@ // RUN: %clang_cc1 -ffreestanding -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix FREESTANDING %s // FREESTANDING:#define __STDC_HOSTED__ 0 // +// RUN: %clang_cc1 -x c++ -fgnuc-version=4.2.1 -std=gnu++26 -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix GXX26 %s +// RUN: %clang_cc1 -x c++ -fgnuc-version=4.2.1 -std=gnu++2c -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix GXX26 %s +// +// GXX26:#define __GNUG__ 4 +// GXX26:#define __GXX_WEAK__ 1 +// GXX26:#define __cplusplus 202102L +// GXX26:#define __private_extern__ extern +// // RUN: %clang_cc1 -x c++ -fgnuc-version=4.2.1 -std=gnu++23 -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix GXX2B %s +// RUN: %clang_cc1 -x c++ -fgnuc-version=4.2.1 -std=gnu++2b -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix GXX2B %s // // GXX2B:#define __GNUG__ 4 // GXX2B:#define __GXX_WEAK__ 1 Index: clang/www/OpenProjects.html =================================================================== --- clang/www/OpenProjects.html +++ clang/www/OpenProjects.html @@ -123,7 +123,7 @@ -
  • Continue work on C++20, C++23, and C2x support: +
  • Continue work on C++20, C++23, C++26, and C2x support: There are still several C++20 features to complete, and work has begun on supporting the latest language standards. Please see the C++ status report page to find out what is Index: clang/www/cxx_status.html =================================================================== --- clang/www/cxx_status.html +++ clang/www/cxx_status.html @@ -65,6 +65,11 @@ -std=c++23 Partial + + C++2c + -std=c++2c + Partial +

    The Clang community is continually striving to improve C++ standards @@ -1560,6 +1565,25 @@ +

    C++2c implementation status

    + + +

    Clang has support for some of the features of the C++ standard following +C++23, informally referred to as C++26.

    + +

    You can use Clang in C++2c mode with the -std=c++2c option.

    + +
    +List of features and minimum Clang version with support + + + + + + +
    Language FeatureC++26 ProposalAvailable in Clang?
    +
    +

    Defect reports

    Clang generally aims to implement resolutions to Defect Reports (bug fixes