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 C++2c + + | ``gnu++2c`` + + Working draft for C++2c 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 parameters, 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++2c 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,11 @@ 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 : DiagGroup<"pre-c++2c-compat", [CXXPre26Compat]>; +def : DiagGroup<"pre-c++2c-compat-pedantic", [CXXPre26CompatPedantic]>; def CXX98CompatBindToTemporaryCopy : DiagGroup<"c++98-compat-bind-to-temporary-copy">; @@ -1112,11 +1117,16 @@ // 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]>; def : DiagGroup<"c++2a-extensions", [CXX20]>; def : DiagGroup<"c++2b-extensions", [CXX23]>; +def : DiagGroup<"c++2c-extensions", [CXX26]>; def DelegatingCtorCycles : DiagGroup<"delegating-ctor-cycles">; 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,6 +122,9 @@ /// isCPlusPlus23 - Language is a post-C++23 variant (or later). bool isCPlusPlus23() const { return Flags & CPlusPlus23; } + /// 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; } 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 C++2c", + LineComment | CPlusPlus | CPlusPlus11 | CPlusPlus14 | CPlusPlus17 | + CPlusPlus20 | CPlusPlus23 | CPlusPlus26 | Digraphs | HexFloat) +LANGSTANDARD_ALIAS(cxx26, "c++26") + +LANGSTANDARD(gnucxx26, "gnu++2c", + CXX, "Working draft for C++2c 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; @@ -6647,8 +6648,8 @@ .Case("c++14", "-std=c++14") .Case("c++17", "-std=c++17") .Case("c++20", "-std=c++20") - // TODO add c++23 when MSVC supports it. - .Case("c++latest", "-std=c++23") + // TODO add c++23 and c++26 when MSVC supports it. + .Case("c++latest", "-std=c++26") .Default(""); if (LanguageStandard.empty()) D.Diag(clang::diag::warn_drv_unused_argument) Index: clang/lib/Frontend/InitPreprocessor.cpp =================================================================== --- clang/lib/Frontend/InitPreprocessor.cpp +++ clang/lib/Frontend/InitPreprocessor.cpp @@ -451,7 +451,10 @@ Builder.defineMacro("__STDC_VERSION__", "199409L"); } else { // -- __cplusplus - if (LangOpts.CPlusPlus23) + if (LangOpts.CPlusPlus26) + // FIXME: Use correct value for C++26. + Builder.defineMacro("__cplusplus", "202400L"); + else if (LangOpts.CPlusPlus23) Builder.defineMacro("__cplusplus", "202302L"); // [C++20] The integer literal 202002L. else if (LangOpts.CPlusPlus20) Index: clang/test/Driver/cl-options.c =================================================================== --- clang/test/Driver/cl-options.c +++ clang/test/Driver/cl-options.c @@ -604,7 +604,7 @@ // STDCXX20: -std=c++20 // RUN: %clang_cl -fmsc-version=1900 -TP -std:c++latest -### -- %s 2>&1 | FileCheck -check-prefix=STDCXXLATEST %s -// STDCXXLATEST: -std=c++23 +// STDCXXLATEST: -std=c++26 // RUN: env CL="/Gy" %clang_cl -### -- %s 2>&1 | FileCheck -check-prefix=ENV-CL %s // ENV-CL: "-ffunction-sections" 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 C++2c' standard +// CHECK-NEXT: note: use 'gnu++2c' or 'gnu++26' for 'Working draft for C++2c 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,6 +8,15 @@ // 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 202402L +// 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 @@ -134,6 +143,14 @@ // 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 202402L +// 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 // 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++2c, 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