[clang] 91cdbd5 - clang: Switch C compilations to C17 by default.

Nick Desaulniers via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 2 09:39:56 PST 2020


Author: Nick Desaulniers
Date: 2020-03-02T09:39:26-08:00
New Revision: 91cdbd521a38495c66e30636943563ca70d3c022

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

LOG: clang: Switch C compilations to C17 by default.

Summary:
Matches GCC 8.1 (2018).

Updates documentation+release notes as well.

See also https://reviews.llvm.org/rL220244.

Reviewers: rsmith, aaron.ballman

Reviewed By: rsmith, aaron.ballman

Subscribers: aaron.ballman, dschuff, aheejin, simoncook, s.egerton, cfe-commits, hans, srhines

Tags: #clang

Differential Revision: https://reviews.llvm.org/D75383

Added: 
    

Modified: 
    clang/docs/ReleaseNotes.rst
    clang/docs/UsersManual.rst
    clang/lib/Frontend/CompilerInvocation.cpp
    clang/test/Preprocessor/init-aarch64.c
    clang/test/Preprocessor/init.c
    clang/www/compatibility.html

Removed: 
    


################################################################################
diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 831ef32c6b8a..ce121ebe6055 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -101,12 +101,10 @@ Windows Support
 C Language Changes in Clang
 ---------------------------
 
-- ...
-
-C11 Feature Support
-^^^^^^^^^^^^^^^^^^^
+- The default C language standard used when `-std=` is not specified has been
+  upgraded from gnu11 to gnu17.
 
-...
+- ...
 
 C++ Language Changes in Clang
 -----------------------------

diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index 856d5e34bbcc..f50f8888f477 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -80,7 +80,7 @@ Basic Usage
 Intro to how to use a C compiler for newbies.
 
 compile + link compile then link debug info enabling optimizations
-picking a language to use, defaults to C11 by default. Autosenses based
+picking a language to use, defaults to C17 by default. Autosenses based
 on extension. using a makefile
 
 Command Line Options
@@ -2399,10 +2399,10 @@ See :doc:`LanguageExtensions`.
 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, c99, gnu99, c11, gnu11,
-c17, gnu17, and various aliases for those modes. If no -std option is
-specified, clang defaults to gnu11 mode. Many C99 and C11 features are
+clang supports the -std option, which changes what language mode clang uses.
+The supported modes for C are c89, gnu89, c99, gnu99, c11, gnu11, c17, gnu17,
+c2x, gnu2x, 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.

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index 9cc41c9d96f8..8638d4300b21 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -2263,7 +2263,7 @@ void CompilerInvocation::setLangDefaults(LangOptions &Opts, InputKind IK,
       if (T.isPS4())
         LangStd = LangStandard::lang_gnu99;
       else
-        LangStd = LangStandard::lang_gnu11;
+        LangStd = LangStandard::lang_gnu17;
 #endif
       break;
     case Language::ObjC:

diff  --git a/clang/test/Preprocessor/init-aarch64.c b/clang/test/Preprocessor/init-aarch64.c
index 380e5e2d7261..df2a6128989b 100644
--- a/clang/test/Preprocessor/init-aarch64.c
+++ b/clang/test/Preprocessor/init-aarch64.c
@@ -236,7 +236,7 @@
 // AARCH64-NEXT: #define __STDC_HOSTED__ 1
 // AARCH64-NEXT: #define __STDC_UTF_16__ 1
 // AARCH64-NEXT: #define __STDC_UTF_32__ 1
-// AARCH64_C: #define __STDC_VERSION__ 201112L
+// AARCH64_C: #define __STDC_VERSION__ 201710L
 // AARCH64-NEXT: #define __STDC__ 1
 // AARCH64-NEXT: #define __UINT16_C_SUFFIX__ 
 // AARCH64-NEXT: #define __UINT16_FMTX__ "hX"
@@ -646,7 +646,7 @@
 // AARCH64-MSVC: #define __STDC_HOSTED__ 0
 // AARCH64-MSVC: #define __STDC_UTF_16__ 1
 // AARCH64-MSVC: #define __STDC_UTF_32__ 1
-// AARCH64-MSVC: #define __STDC_VERSION__ 201112L
+// AARCH64-MSVC: #define __STDC_VERSION__ 201710L
 // AARCH64-MSVC: #define __STDC__ 1
 // AARCH64-MSVC: #define __UINT16_C_SUFFIX__
 // AARCH64-MSVC: #define __UINT16_MAX__ 65535

diff  --git a/clang/test/Preprocessor/init.c b/clang/test/Preprocessor/init.c
index f38f87ddef8e..e987a3b3b93d 100644
--- a/clang/test/Preprocessor/init.c
+++ b/clang/test/Preprocessor/init.c
@@ -117,7 +117,7 @@
 // RUN: %clang_cc1 -E -dM -triple=x86_64-apple-darwin < /dev/null | FileCheck -match-full-lines -check-prefix C-DEFAULT %s
 // RUN: %clang_cc1 -E -dM -triple=armv7a-apple-darwin < /dev/null | FileCheck -match-full-lines -check-prefix C-DEFAULT %s
 //
-// C-DEFAULT:#define __STDC_VERSION__ 201112L
+// C-DEFAULT:#define __STDC_VERSION__ 201710L
 //
 // RUN: %clang_cc1 -ffreestanding -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix FREESTANDING %s
 // FREESTANDING:#define __STDC_HOSTED__ 0
@@ -2098,7 +2098,7 @@
 // MIPS32BE:#define __SIZE_WIDTH__ 32
 // MIPS32BE-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 8U
 // MIPS32BE:#define __STDC_HOSTED__ 0
-// MIPS32BE-C:#define __STDC_VERSION__ 201112L
+// MIPS32BE-C:#define __STDC_VERSION__ 201710L
 // MIPS32BE:#define __STDC__ 1
 // MIPS32BE:#define __UINT16_C_SUFFIX__
 // MIPS32BE:#define __UINT16_MAX__ 65535
@@ -2557,7 +2557,7 @@
 // MIPSN32BE: #define __STDC_HOSTED__ 0
 // MIPSN32BE: #define __STDC_UTF_16__ 1
 // MIPSN32BE: #define __STDC_UTF_32__ 1
-// MIPSN32BE-C: #define __STDC_VERSION__ 201112L
+// MIPSN32BE-C: #define __STDC_VERSION__ 201710L
 // MIPSN32BE: #define __STDC__ 1
 // MIPSN32BE: #define __UINT16_C_SUFFIX__
 // MIPSN32BE: #define __UINT16_FMTX__ "hX"
@@ -2864,7 +2864,7 @@
 // MIPSN32EL: #define __STDC_HOSTED__ 0
 // MIPSN32EL: #define __STDC_UTF_16__ 1
 // MIPSN32EL: #define __STDC_UTF_32__ 1
-// MIPSN32EL: #define __STDC_VERSION__ 201112L
+// MIPSN32EL: #define __STDC_VERSION__ 201710L
 // MIPSN32EL: #define __STDC__ 1
 // MIPSN32EL: #define __UINT16_C_SUFFIX__
 // MIPSN32EL: #define __UINT16_FMTX__ "hX"
@@ -5390,7 +5390,7 @@
 // PPC-DARWIN:#define __SIZE_TYPE__ long unsigned int
 // PPC-DARWIN:#define __SIZE_WIDTH__ 32
 // PPC-DARWIN:#define __STDC_HOSTED__ 0
-// PPC-DARWIN:#define __STDC_VERSION__ 201112L
+// PPC-DARWIN:#define __STDC_VERSION__ 201710L
 // PPC-DARWIN:#define __STDC__ 1
 // PPC-DARWIN:#define __UINT16_C_SUFFIX__
 // PPC-DARWIN:#define __UINT16_MAX__ 65535
@@ -6602,7 +6602,7 @@
 // X86_64-CLOUDABI:#define __STDC_ISO_10646__ 201206L
 // X86_64-CLOUDABI:#define __STDC_UTF_16__ 1
 // X86_64-CLOUDABI:#define __STDC_UTF_32__ 1
-// X86_64-CLOUDABI:#define __STDC_VERSION__ 201112L
+// X86_64-CLOUDABI:#define __STDC_VERSION__ 201710L
 // X86_64-CLOUDABI:#define __STDC__ 1
 // X86_64-CLOUDABI:#define __UINT16_C_SUFFIX__
 // X86_64-CLOUDABI:#define __UINT16_FMTX__ "hX"
@@ -7601,7 +7601,7 @@
 // WEBASSEMBLY-NOT:#define __STDC_NO_THREADS__
 // WEBASSEMBLY-NEXT:#define __STDC_UTF_16__ 1
 // WEBASSEMBLY-NEXT:#define __STDC_UTF_32__ 1
-// WEBASSEMBLY-NEXT:#define __STDC_VERSION__ 201112L
+// WEBASSEMBLY-NEXT:#define __STDC_VERSION__ 201710L
 // WEBASSEMBLY-NEXT:#define __STDC__ 1
 // WEBASSEMBLY-NEXT:#define __UINT16_C_SUFFIX__
 // WEBASSEMBLY-NEXT:#define __UINT16_FMTX__ "hX"
@@ -8166,7 +8166,7 @@
 // RISCV32: #define __STDC_HOSTED__ 0
 // RISCV32: #define __STDC_UTF_16__ 1
 // RISCV32: #define __STDC_UTF_32__ 1
-// RISCV32: #define __STDC_VERSION__ 201112L
+// RISCV32: #define __STDC_VERSION__ 201710L
 // RISCV32: #define __STDC__ 1
 // RISCV32: #define __UINT16_C_SUFFIX__
 // RISCV32: #define __UINT16_MAX__ 65535
@@ -8373,7 +8373,7 @@
 // RISCV64: #define __STDC_HOSTED__ 0
 // RISCV64: #define __STDC_UTF_16__ 1
 // RISCV64: #define __STDC_UTF_32__ 1
-// RISCV64: #define __STDC_VERSION__ 201112L
+// RISCV64: #define __STDC_VERSION__ 201710L
 // RISCV64: #define __STDC__ 1
 // RISCV64: #define __UINT16_C_SUFFIX__
 // RISCV64: #define __UINT16_MAX__ 65535

diff  --git a/clang/www/compatibility.html b/clang/www/compatibility.html
index 9f8ee4bdc012..a593155951da 100755
--- a/clang/www/compatibility.html
+++ b/clang/www/compatibility.html
@@ -83,7 +83,7 @@ <h2 id="c">C compatibility</h2>
 <!-- ======================================================================= -->
 <h3 id="inline">C99 inline functions</h3>
 <!-- ======================================================================= -->
-<p>By default, Clang builds C code in GNU C11 mode, so it uses standard C99
+<p>By default, Clang builds C code in GNU C17 mode, so it uses standard C99
 semantics for the <code>inline</code> keyword. These semantics are 
diff erent
 from those in GNU C89 mode, which is the default mode in versions of GCC
 prior to 5.0. For example, consider the following code:</p>


        


More information about the cfe-commits mailing list