[PATCH] D131465: C++/ObjC++: switch to gnu++17 as the default dialect

Fangrui Song via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 8 22:11:08 PDT 2022


MaskRay created this revision.
MaskRay added reviewers: clang-language-wg, probinson, rjmccall.
Herald added a subscriber: StephenFan.
Herald added a project: All.
MaskRay requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Clang's default C++ dialect is now `gnu++17` instead of `gnu++14`.

CUDA/HIP are unchanged: C++14 from D103221 <https://reviews.llvm.org/D103221>.

Depends on D131464 <https://reviews.llvm.org/D131464>

Close https://github.com/llvm/llvm-project/issues/56946


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D131465

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Basic/LangStandards.cpp
  clang/test/Preprocessor/lang-std.cpp
  clang/test/Preprocessor/lang-std.cu


Index: clang/test/Preprocessor/lang-std.cu
===================================================================
--- clang/test/Preprocessor/lang-std.cu
+++ /dev/null
@@ -1,7 +0,0 @@
-// 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
Index: clang/test/Preprocessor/lang-std.cpp
===================================================================
--- /dev/null
+++ clang/test/Preprocessor/lang-std.cpp
@@ -0,0 +1,11 @@
+/// Test default dialects.
+// 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
Index: clang/lib/Basic/LangStandards.cpp
===================================================================
--- clang/lib/Basic/LangStandards.cpp
+++ clang/lib/Basic/LangStandards.cpp
@@ -78,7 +78,7 @@
     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:
Index: clang/docs/ReleaseNotes.rst
===================================================================
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -120,6 +120,11 @@
 C++ Language Changes in Clang
 -----------------------------
 
+* Clang's default C++ dialect 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
 ^^^^^^^^^^^^^^^^^^^^^
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D131465.451043.patch
Type: text/x-patch
Size: 2335 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220809/1d6c8122/attachment.bin>


More information about the cfe-commits mailing list