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
This commit is contained in:
Nick Desaulniers 2020-03-02 09:33:14 -08:00
parent b9f37e9ace
commit 91cdbd521a
6 changed files with 21 additions and 23 deletions

View File

@ -101,13 +101,11 @@ Windows Support
C Language Changes in Clang
---------------------------
- The default C language standard used when `-std=` is not specified has been
upgraded from gnu11 to gnu17.
- ...
C11 Feature Support
^^^^^^^^^^^^^^^^^^^
...
C++ Language Changes in Clang
-----------------------------

View File

@ -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.

View File

@ -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:

View File

@ -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

View File

@ -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

View File

@ -83,7 +83,7 @@
<!-- ======================================================================= -->
<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 different
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>