Add c++23 standard (#2476)
This commit is contained in:
Родитель
549637b4f6
Коммит
ecdc6ab238
|
@ -4,6 +4,7 @@
|
|||
Improvements:
|
||||
- Fix build Error: EMFILE: too many open files. [#2288](https://github.com/microsoft/vscode-cmake-tools/issues/2288) [@FrogTheFrog](https://github.com/FrogTheFrog)
|
||||
- Add commands to get preset names. [PR #2433](https://github.com/microsoft/vscode-cmake-tools/pull/2433)
|
||||
- Add c++23 support. [#2475](https://github.com/microsoft/vscode-cmake-tools/issues/2475) [@sweemer](https://github.com/sweemer)
|
||||
|
||||
Bug Fixes:
|
||||
- `Clean All Projects` menu item builds rather than cleans. [#2460](https://github.com/microsoft/vscode-cmake-tools/issues/2460)
|
||||
|
|
|
@ -2078,7 +2078,7 @@
|
|||
"p-limit": "^3.1.0",
|
||||
"rimraf": "^3.0.2",
|
||||
"tmp": "^0.2.1",
|
||||
"vscode-cpptools": "^5.0.0",
|
||||
"vscode-cpptools": "^6.1.0",
|
||||
"vscode-extension-telemetry": "^0.1.7",
|
||||
"vscode-nls": "^5.0.0",
|
||||
"vscode-tas-client": "^0.1.22",
|
||||
|
|
|
@ -22,7 +22,7 @@ const localize: nls.LocalizeFunc = nls.loadMessageBundle();
|
|||
const log = createLogger('cpptools');
|
||||
|
||||
type Architecture = 'x86' | 'x64' | 'arm' | 'arm64' | undefined;
|
||||
type StandardVersion = "c89" | "c99" | "c11" | "c17" | "c++98" | "c++03" | "c++11" | "c++14" | "c++17" | "c++20" | "gnu89" | "gnu99" | "gnu11" | "gnu17" | "gnu++98" | "gnu++03" | "gnu++11" | "gnu++14" | "gnu++17" | "gnu++20" | undefined;
|
||||
type StandardVersion = "c89" | "c99" | "c11" | "c17" | "c++98" | "c++03" | "c++11" | "c++14" | "c++17" | "c++20" | "c++23" | "gnu89" | "gnu99" | "gnu11" | "gnu17" | "gnu++98" | "gnu++03" | "gnu++11" | "gnu++14" | "gnu++17" | "gnu++20" | "gnu++23" | undefined;
|
||||
|
||||
export interface DiagnosticsCpptools {
|
||||
isReady: boolean;
|
||||
|
@ -63,9 +63,15 @@ interface TargetDefaults {
|
|||
defines: string[];
|
||||
}
|
||||
|
||||
function parseCppStandard(std: string, can_use_gnu: boolean): StandardVersion {
|
||||
function parseCppStandard(std: string, can_use_gnu: boolean, can_use_cxx23: boolean): StandardVersion {
|
||||
const is_gnu = can_use_gnu && std.startsWith('gnu');
|
||||
if (std.endsWith('++2a') || std.endsWith('++2b') || std.endsWith('++20') || std.endsWith('++latest')) {
|
||||
if (std.endsWith('++23') || std.endsWith('++2b') || std.endsWith('++latest')) {
|
||||
if (can_use_cxx23) {
|
||||
return is_gnu ? 'gnu++23' : 'c++23';
|
||||
} else {
|
||||
return is_gnu ? 'gnu++20' : 'c++20';
|
||||
}
|
||||
} else if (std.endsWith('++20') || std.endsWith('++2a')) {
|
||||
return is_gnu ? 'gnu++20' : 'c++20';
|
||||
} else if (std.endsWith('++17') || std.endsWith('++1z')) {
|
||||
return is_gnu ? 'gnu++17' : 'c++17';
|
||||
|
@ -148,6 +154,7 @@ function parseTargetArch(target: string): Architecture {
|
|||
export function parseCompileFlags(cptVersion: cpt.Version, args: string[], lang?: string): CompileFlagInformation {
|
||||
const require_standard_target = (cptVersion < cpt.Version.v5);
|
||||
const can_use_gnu_std = (cptVersion >= cpt.Version.v4);
|
||||
const can_use_cxx23 = (cptVersion >= cpt.Version.v6);
|
||||
const iter = args[Symbol.iterator]();
|
||||
const extraDefinitions: string[] = [];
|
||||
let standard: StandardVersion;
|
||||
|
@ -196,7 +203,7 @@ export function parseCompileFlags(cptVersion: cpt.Version, args: string[], lang?
|
|||
} else if (value.startsWith('-std=') || lower.startsWith('-std:') || lower.startsWith('/std:')) {
|
||||
const std = value.substring(5);
|
||||
if (lang === 'CXX' || lang === 'OBJCXX' || lang === 'CUDA') {
|
||||
const s = parseCppStandard(std, can_use_gnu_std);
|
||||
const s = parseCppStandard(std, can_use_gnu_std, can_use_cxx23);
|
||||
if (!s) {
|
||||
log.warning(localize('unknown.control.gflag.cpp', 'Unknown C++ standard control flag: {0}', value));
|
||||
} else {
|
||||
|
@ -210,7 +217,7 @@ export function parseCompileFlags(cptVersion: cpt.Version, args: string[], lang?
|
|||
standard = s;
|
||||
}
|
||||
} else if (lang === undefined) {
|
||||
let s = parseCppStandard(std, can_use_gnu_std);
|
||||
let s = parseCppStandard(std, can_use_gnu_std, can_use_cxx23);
|
||||
if (!s) {
|
||||
s = parseCStandard(std, can_use_gnu_std);
|
||||
}
|
||||
|
|
|
@ -19,10 +19,21 @@ suite('CppTools tests', () => {
|
|||
const cpptoolsVersion3 = Version.v3;
|
||||
const cpptoolsVersion4 = Version.v4;
|
||||
const cpptoolsVersion5 = Version.v5;
|
||||
const cpptoolsVersion6 = Version.v6;
|
||||
|
||||
// Verify CppTools API version 6
|
||||
let info = parseCompileFlags(cpptoolsVersion6, ['-std=c++23']);
|
||||
expect(info.standard).to.eql('c++23');
|
||||
info = parseCompileFlags(cpptoolsVersion6, ['-std=c++2b']);
|
||||
expect(info.standard).to.eql('c++23');
|
||||
info = parseCompileFlags(cpptoolsVersion6, ['-std=gnu++23']);
|
||||
expect(info.standard).to.eql('gnu++23');
|
||||
|
||||
// Verify CppTools API version 5
|
||||
let info = parseCompileFlags(cpptoolsVersion5, ['-target', 'arm-arm-none-eabi']);
|
||||
info = parseCompileFlags(cpptoolsVersion5, ['-target', 'arm-arm-none-eabi']);
|
||||
expect(info.targetArch).to.eql(undefined);
|
||||
info = parseCompileFlags(cpptoolsVersion5, ['-std=c++23']);
|
||||
expect(info.standard).to.eql('c++20');
|
||||
info = parseCompileFlags(cpptoolsVersion5, ['-std=gnu++14']);
|
||||
expect(info.standard).to.eql('gnu++14');
|
||||
info = parseCompileFlags(cpptoolsVersion5, []);
|
||||
|
|
|
@ -6128,10 +6128,10 @@ vsce@^1.95.0:
|
|||
yauzl "^2.3.1"
|
||||
yazl "^2.2.2"
|
||||
|
||||
vscode-cpptools@^5.0.0:
|
||||
version "5.0.0"
|
||||
resolved "https://registry.yarnpkg.com/vscode-cpptools/-/vscode-cpptools-5.0.0.tgz#f1195736af1cfa10727482be57093a3997c8f63b"
|
||||
integrity sha512-TPG6/o9+DisDj2U4AiTOihtfjEzBb/4CErYaB1JIWFMZTQE7zlNTdsgCs+l4xIS2Y34us0RMBIC6On1mBuwxww==
|
||||
vscode-cpptools@^6.1.0:
|
||||
version "6.1.0"
|
||||
resolved "https://registry.yarnpkg.com/vscode-cpptools/-/vscode-cpptools-6.1.0.tgz#d89bb225f91da45dbee6acbf45f6940aa3926df1"
|
||||
integrity sha512-+40xMmzSlvaMwWEDIjhHl9+W1RH9xaEbiFAAgLWgyL1FXxQWBguWRHgS91qBJbuFAB9H4UBuK94iFMs+7BFclA==
|
||||
|
||||
vscode-extension-telemetry@^0.1.7:
|
||||
version "0.1.7"
|
||||
|
|
Загрузка…
Ссылка в новой задаче