From 123256af285883c2c2b21bae5575e18fb8f71beb Mon Sep 17 00:00:00 2001 From: Orgad Shaneh Date: Mon, 1 Aug 2022 08:03:45 +0300 Subject: Support c17 and c2x values for cLanguageVersion Compiler version sources: https://en.wikipedia.org/wiki/C17_(C_standard_revision) https://en.wikipedia.org/wiki/C2x https://en.wikipedia.org/wiki/Xcode#Xcode_11.0_-_14.x_(since_SwiftUI_framework) Change-Id: I3bdb54334e0cbf326a5d25d31c45f331cbb36c55 Reviewed-by: Christian Kandeler --- changelogs/changes-1.23.1.md | 2 ++ doc/reference/modules/cpp-module.qdoc | 2 +- share/qbs/modules/cpp/gcc.js | 20 ++++++++++++++++++-- share/qbs/modules/cpp/iar.js | 2 +- share/qbs/modules/cpp/sdcc.js | 12 ++++++------ 5 files changed, 28 insertions(+), 10 deletions(-) diff --git a/changelogs/changes-1.23.1.md b/changelogs/changes-1.23.1.md index ef533e38e..430a33bfe 100644 --- a/changelogs/changes-1.23.1.md +++ b/changelogs/changes-1.23.1.md @@ -3,7 +3,9 @@ # Other modules * Fixed protobuf linking on macOS 11. +* Added support for c17 and c2x values in cpp.cLanguageVersion # Contributors * Christian Kandeler * Ivan Komissarov +* Orgad Shaneh diff --git a/doc/reference/modules/cpp-module.qdoc b/doc/reference/modules/cpp-module.qdoc index 6eea7d9e3..540516135 100644 --- a/doc/reference/modules/cpp-module.qdoc +++ b/doc/reference/modules/cpp-module.qdoc @@ -837,7 +837,7 @@ If the value is left undefined, the compiler default will be used. If the list contains more than one value, the highest version is chosen. - Possible values include: \c{"c89"}, \c{"c99"}, \c{"c11"}. + Possible values include: \c{"c89"}, \c{"c99"}, \c{"c11"}, \c{"c17"}, \c{"c2x"}. \nodefaultvalue */ diff --git a/share/qbs/modules/cpp/gcc.js b/share/qbs/modules/cpp/gcc.js index 7e8e768b0..25fe06861 100644 --- a/share/qbs/modules/cpp/gcc.js +++ b/share/qbs/modules/cpp/gcc.js @@ -695,6 +695,22 @@ function standardFallbackValueOrDefault(toolchain, compilerVersion, languageVers {"name": "gcc", "version": "4.7"} ] }, + "c17": { + "fallback": "c11", + "toolchains": [ + {"name": "xcode", "version": "10.2"}, + {"name": "clang", "version": "7.0"}, + {"name": "gcc", "version": "8.1"} + ] + }, + "c2x": { + "fallback": "c17", + "toolchains": [ + {"name": "xcode", "version": "11.4"}, + {"name": "clang", "version": "9.0"}, + {"name": "gcc", "version": "9.0"} + ] + }, "c++14": { "fallback": "c++1y", "toolchains": [ @@ -714,7 +730,7 @@ function standardFallbackValueOrDefault(toolchain, compilerVersion, languageVers "c++20": { "fallback": "c++2a", "toolchains": [ - {"name": "xcode"}, // ?? + {"name": "xcode", "version": "12.5"}, {"name": "clang", "version": "11.0"}, {"name": "gcc", "version": "10.1"} ] @@ -884,7 +900,7 @@ function compilerFlags(project, product, input, output, explicitlyDependsOn) { switch (tag) { case "c": case "objc": - var knownValues = ["c11", "c99", "c90", "c89"]; + var knownValues = ["c2x", "c17", "c11", "c99", "c90", "c89"]; return Cpp.languageVersion(input.cpp.cLanguageVersion, knownValues, "C"); case "cpp": case "objcpp": diff --git a/share/qbs/modules/cpp/iar.js b/share/qbs/modules/cpp/iar.js index 5f56b79f6..632f9af17 100644 --- a/share/qbs/modules/cpp/iar.js +++ b/share/qbs/modules/cpp/iar.js @@ -573,7 +573,7 @@ function compilerFlags(project, product, input, outputs, explicitlyDependsOn) { args.push("--c89"); break; default: - // Default C language version is C11/C99 that + // Default C language version is C18/C11/C99 that // depends on the IAR version. break; } diff --git a/share/qbs/modules/cpp/sdcc.js b/share/qbs/modules/cpp/sdcc.js index 8b502bd8a..928ded5cf 100644 --- a/share/qbs/modules/cpp/sdcc.js +++ b/share/qbs/modules/cpp/sdcc.js @@ -286,18 +286,18 @@ function compilerFlags(project, product, input, outputs, explicitlyDependsOn) { // C language version flags. if (tag === "c") { - var knownValues = ["c11", "c99", "c89"]; + var knownValues = ["c2x", "c17", "c11", "c99", "c89"]; var cLanguageVersion = Cpp.languageVersion( input.cpp.cLanguageVersion, knownValues, "C"); switch (cLanguageVersion) { + case "c17": + cLanguageVersion = "c11"; + // fall through case "c89": - args.push("--std-c89"); - break; case "c99": - args.push("--std-c99"); - break; case "c11": - args.push("--std-c11"); + case "c2x": + args.push("--std-" + cLanguageVersion); break; } } -- cgit v1.2.3