[clang] fd24750 - Revert "C++/ObjC++: switch to gnu++17 as the default standard"

Nikita Popov via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 8 00:51:25 PDT 2022


Author: Nikita Popov
Date: 2022-09-08T09:45:50+02:00
New Revision: fd2475049e882e6c70a745cbe0799749ba184910

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

LOG: Revert "C++/ObjC++: switch to gnu++17 as the default standard"

This reverts commit e321c8dd2cea8365045ed44ae1c3c00c6a977d2e.

This causes many failures in llvm-test-suite, for example:

    /home/npopov/repos/llvm-test-suite/build-O3/tools/timeit --summary MultiSource/Applications/lambda-0.1.3/CMakeFiles/lambda.dir/token_stream.cc.o.time /home/npopov/repos/llvm-project/build/bin/clang++ -DNDEBUG -I/home/npopov/repos/llvm-test-suite/MultiSource/Applications/lambda-0.1.3 -O3   -w -Werror=date-time -MD -MT MultiSource/Applications/lambda-0.1.3/CMakeFiles/lambda.dir/token_stream.cc.o -MF MultiSource/Applications/lambda-0.1.3/CMakeFiles/lambda.dir/token_stream.cc.o.d -o MultiSource/Applications/lambda-0.1.3/CMakeFiles/lambda.dir/token_stream.cc.o -c /home/npopov/repos/llvm-test-suite/MultiSource/Applications/lambda-0.1.3/token_stream.cc
    /home/npopov/repos/llvm-test-suite/MultiSource/Applications/lambda-0.1.3/token_stream.cc:192:2: error: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
            register char chr;
            ^~~~~~~~~

Added: 
    clang/test/Preprocessor/lang-std.cu

Modified: 
    clang/docs/ReleaseNotes.rst
    clang/lib/Basic/LangStandards.cpp
    clang/test/lit.cfg.py
    clang/test/lit.site.cfg.py.in

Removed: 
    clang/test/Preprocessor/lang-std.cpp


################################################################################
diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 425135d746b99..b370d23856c21 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -200,10 +200,6 @@ C++ Language Changes in Clang
 
 - Implemented DR692, DR1395 and DR1432. Use the ``-fclang-abi-compat=15`` option
   to get the old partial ordering behavior regarding packs.
-- Clang's default C++/ObjC++ standard is now ``gnu++17`` instead of ``gnu++14``.
-  This means Clang will by default accept code using features from C++17 and
-  conforming GNU extensions. Projects incompatible with C++17 can add
-  ``-std=gnu++14`` to their build settings to restore the previous behaviour.
 
 C++20 Feature Support
 ^^^^^^^^^^^^^^^^^^^^^

diff  --git a/clang/lib/Basic/LangStandards.cpp b/clang/lib/Basic/LangStandards.cpp
index 92e8ab347dda1..a21898dd3c627 100644
--- a/clang/lib/Basic/LangStandards.cpp
+++ b/clang/lib/Basic/LangStandards.cpp
@@ -75,9 +75,10 @@ LangStandard::Kind clang::getDefaultLanguageStandard(clang::Language Lang,
     if (CLANG_DEFAULT_STD_CXX != LangStandard::lang_unspecified)
       return CLANG_DEFAULT_STD_CXX;
 
-    if (T.isPS())
+    if (T.isDriverKit())
+      return LangStandard::lang_gnucxx17;
+    else
       return LangStandard::lang_gnucxx14;
-    return LangStandard::lang_gnucxx17;
   case Language::RenderScript:
     return LangStandard::lang_c99;
   case Language::HIP:

diff  --git a/clang/test/Preprocessor/lang-std.cpp b/clang/test/Preprocessor/lang-std.cpp
deleted file mode 100644
index 538f1b1976dad..0000000000000
--- a/clang/test/Preprocessor/lang-std.cpp
+++ /dev/null
@@ -1,14 +0,0 @@
-// UNSUPPORTED: default-std-cxx, ps4, ps5
-/// Test default standards when CLANG_DEFAULT_STD_CXX is unspecified.
-/// PS4/PS5 default to gnu++14.
-
-// RUN: %clang_cc1 -dM -E %s | FileCheck --check-prefix=CXX17 %s
-// RUN: %clang_cc1 -dM -E -x cuda %s | FileCheck --check-prefix=CXX14 %s
-// RUN: %clang_cc1 -dM -E -x hip %s | FileCheck --check-prefix=CXX14 %s
-
-// RUN: %clang_cc1 -dM -E -x cuda -std=c++14 %s | FileCheck --check-prefix=CXX14 %s
-// RUN: %clang_cc1 -dM -E -x hip -std=c++98 %s | FileCheck --check-prefix=CXX98 %s
-
-// CXX98: #define __cplusplus 199711L
-// CXX14: #define __cplusplus 201402L
-// CXX17: #define __cplusplus 201703L

diff  --git a/clang/test/Preprocessor/lang-std.cu b/clang/test/Preprocessor/lang-std.cu
new file mode 100644
index 0000000000000..4f35af01aaf5f
--- /dev/null
+++ b/clang/test/Preprocessor/lang-std.cu
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -dM -E -x hip %s | FileCheck -check-prefix=CXX14 %s
+// RUN: %clang_cc1 -dM -E %s | FileCheck -check-prefix=CXX14 %s
+// RUN: %clang_cc1 -dM -E -std=c++98 -x hip %s | FileCheck -check-prefix=CXX98 %s
+// RUN: %clang_cc1 -dM -E -std=c++98 %s | FileCheck -check-prefix=CXX98 %s
+
+// CXX98: #define __cplusplus 199711L
+// CXX14: #define __cplusplus 201402L

diff  --git a/clang/test/lit.cfg.py b/clang/test/lit.cfg.py
index 7fa46e3d99fca..792216595d3fe 100644
--- a/clang/test/lit.cfg.py
+++ b/clang/test/lit.cfg.py
@@ -131,9 +131,6 @@ def have_host_jit_feature_support(feature_name):
 if config.clang_enable_opaque_pointers:
     config.available_features.add('enable-opaque-pointers')
 
-if config.clang_default_std_cxx != '':
-    config.available_features.add('default-std-cxx')
-
 # Set available features we allow tests to conditionalize on.
 #
 if config.clang_default_cxx_stdlib != '':

diff  --git a/clang/test/lit.site.cfg.py.in b/clang/test/lit.site.cfg.py.in
index 8c62d61c57b40..9c903b2d31cb8 100644
--- a/clang/test/lit.site.cfg.py.in
+++ b/clang/test/lit.site.cfg.py.in
@@ -24,7 +24,6 @@ config.have_zlib = @LLVM_ENABLE_ZLIB@
 config.clang_arcmt = @CLANG_ENABLE_ARCMT@
 config.clang_default_pie_on_linux = @CLANG_DEFAULT_PIE_ON_LINUX@
 config.clang_enable_opaque_pointers = @CLANG_ENABLE_OPAQUE_POINTERS_INTERNAL@
-config.clang_default_std_cxx = "@CLANG_DEFAULT_STD_CXX@"
 config.clang_default_cxx_stdlib = "@CLANG_DEFAULT_CXX_STDLIB@"
 config.clang_staticanalyzer = @CLANG_ENABLE_STATIC_ANALYZER@
 config.clang_staticanalyzer_z3 = @LLVM_WITH_Z3@


        


More information about the cfe-commits mailing list