Skip to content

Commit 3a84302

Browse files
Merge pull request #434 from microsoft/dev/gcampbell/C++23
Add support for c++23
2 parents d4636ff + c30da2f commit 3a84302

4 files changed

Lines changed: 25 additions & 17 deletions

File tree

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
},
1313
"license": "SEE LICENSE IN LICENSE.txt",
1414
"engines": {
15-
"vscode": "^1.30.0"
15+
"vscode": "^1.74.0"
1616
},
1717
"bugs": {
1818
"url": "https://github.com/Microsoft/vscode-makefile-tools/issues",
@@ -748,7 +748,7 @@
748748
"@types/glob": "^7.1.1",
749749
"glob": "^7.1.6",
750750
"module-alias": "^2.2.2",
751-
"vscode-cpptools": "^5.0.0",
751+
"vscode-cpptools": "^6.1.0",
752752
"vscode-nls": "^5.0.0",
753753
"@vscode/extension-telemetry": "^0.6.2",
754754
"vscode-jsonrpc": "^3.6.2"

src/parser.ts

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -998,7 +998,7 @@ export async function parseCustomConfigProvider(cancel: vscode.CancellationToken
998998
// If the command is compiling the same extension or uses -TC/-TP, send all the source files in one batch.
999999
if (language) {
10001000
// More standard validation and defaults, in the context of the whole command.
1001-
let standard: util.StandardVersion = parseStandard(ext.extension.getCppToolsVersion(), standardStr, language);
1001+
let standard: util.StandardVersion | undefined = parseStandard(ext.extension.getCppToolsVersion(), standardStr, language);
10021002

10031003
if (ext.extension) {
10041004
onFoundCustomConfigProviderItem({ defines, includes, forcedIncludes, standard, intelliSenseMode, compilerFullPath, compilerArgs, files, windowsSDKVersion, currentPath, line });
@@ -1014,7 +1014,7 @@ export async function parseCustomConfigProvider(cancel: vscode.CancellationToken
10141014
}
10151015

10161016
// More standard validation and defaults, in the context of each source file.
1017-
let standard: util.StandardVersion = parseStandard(ext.extension.getCppToolsVersion(), standardStr, language);
1017+
let standard: util.StandardVersion | undefined = parseStandard(ext.extension.getCppToolsVersion(), standardStr, language);
10181018

10191019
if (ext.extension) {
10201020
onFoundCustomConfigProviderItem({ defines, includes, forcedIncludes, standard, intelliSenseMode, compilerFullPath, compilerArgs, files: [file], windowsSDKVersion, currentPath, line });
@@ -1492,9 +1492,10 @@ function getTargetArchitecture(compilerArgs: string): util.TargetArchitecture {
14921492
return targetArch;
14931493
}
14941494

1495-
function parseStandard(cppVersion: cpp.Version | undefined, std: string | undefined, language: util.Language): util.StandardVersion {
1495+
export function parseStandard(cppVersion: cpp.Version | undefined, std: string | undefined, language: util.Language): util.StandardVersion | undefined {
14961496
let canUseGnu: boolean = (cppVersion !== undefined && cppVersion >= cpp.Version.v4);
1497-
let standard: util.StandardVersion;
1497+
let canUseCxx23: boolean = (cppVersion !== undefined && cppVersion >= cpp.Version.v6);
1498+
let standard: util.StandardVersion | undefined;
14981499
if (cppVersion && cppVersion >= cpp.Version.v5 && std === undefined) {
14991500
// C/C++ standard is optional for CppTools v5+ and is determined by CppTools.
15001501
return undefined;
@@ -1508,7 +1509,7 @@ function parseStandard(cppVersion: cpp.Version | undefined, std: string | undefi
15081509
return "c++17";
15091510
}
15101511
} else if (language === "cpp") {
1511-
standard = parseCppStandard(std, canUseGnu);
1512+
standard = parseCppStandard(std, canUseGnu, canUseCxx23);
15121513
if (!standard) {
15131514
logger.message(`Unknown C++ standard control flag: ${std}`, "Normal");
15141515
}
@@ -1518,7 +1519,7 @@ function parseStandard(cppVersion: cpp.Version | undefined, std: string | undefi
15181519
logger.message(`Unknown C standard control flag: ${std}`, "Normal");
15191520
}
15201521
} else if (language === undefined) {
1521-
standard = parseCppStandard(std, canUseGnu);
1522+
standard = parseCppStandard(std, canUseGnu, canUseCxx23);
15221523
if (!standard) {
15231524
standard = parseCStandard(std, canUseGnu);
15241525
}
@@ -1532,9 +1533,15 @@ function parseStandard(cppVersion: cpp.Version | undefined, std: string | undefi
15321533
return standard;
15331534
}
15341535

1535-
function parseCppStandard(std: string, canUseGnu: boolean): util.StandardVersion {
1536+
function parseCppStandard(std: string, canUseGnu: boolean, canUseCxx23: boolean): util.StandardVersion | undefined {
15361537
const isGnu: boolean = canUseGnu && std.startsWith('gnu');
1537-
if (std.endsWith('++2a') || std.endsWith('++20') || std.endsWith('++latest')) {
1538+
if (std.endsWith('++23') || std.endsWith('++2b') || std.endsWith('++latest')) {
1539+
if (canUseCxx23) {
1540+
return isGnu ? 'gnu++23' : 'c++23';
1541+
} else {
1542+
return isGnu ? 'gnu++20' : 'c++20';
1543+
}
1544+
} else if (std.endsWith('++2a') || std.endsWith('++20')) {
15381545
return isGnu ? 'gnu++20' : 'c++20';
15391546
} else if (std.endsWith('++17') || std.endsWith('++1z')) {
15401547
return isGnu ? 'gnu++17' : 'c++17';
@@ -1551,7 +1558,7 @@ function parseCppStandard(std: string, canUseGnu: boolean): util.StandardVersion
15511558
}
15521559
}
15531560

1554-
function parseCStandard(std: string, canUseGnu: boolean): util.StandardVersion {
1561+
function parseCStandard(std: string, canUseGnu: boolean): util.StandardVersion | undefined {
15551562
// GNU options from: https://gcc.gnu.org/onlinedocs/gcc/C-Dialect-Options.html#C-Dialect-Options
15561563
const isGnu: boolean = canUseGnu && std.startsWith('gnu');
15571564
if (/(c|gnu)(90|89|iso9899:(1990|199409))/.test(std)) {

src/util.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ import * as path from 'path';
1111
import * as vscode from 'vscode';
1212

1313
// C/CPP standard versions
14-
export type StandardVersion = 'c89' | 'c99' | 'c11' | 'c17' | 'c++98' | 'c++03' | 'c++11' | 'c++14' | 'c++17' | 'c++20' |
15-
'gnu89' | 'gnu99' | 'gnu11' | 'gnu17' | 'gnu++98' | 'gnu++03' | 'gnu++11' | 'gnu++14' | 'gnu++17' | 'gnu++20' | undefined;
14+
export type StandardVersion = 'c89' | 'c99' | 'c11' | 'c17' | 'c++98' | 'c++03' | 'c++11' | 'c++14' | 'c++17' | 'c++20' | 'c++23' |
15+
'gnu89' | 'gnu99' | 'gnu11' | 'gnu17' | 'gnu++98' | 'gnu++03' | 'gnu++11' | 'gnu++14' | 'gnu++17' | 'gnu++20' | 'gnu++23'
16+
undefined;
1617

1718
// Supported target architectures (for code generated by the compiler)
1819
export type TargetArchitecture = 'x86' | 'x64' | 'arm' | 'arm64' | undefined;

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4752,10 +4752,10 @@ vsce@^1.95.0:
47524752
yauzl "^2.3.1"
47534753
yazl "^2.2.2"
47544754

4755-
vscode-cpptools@^5.0.0:
4756-
version "5.0.0"
4757-
resolved "https://registry.yarnpkg.com/vscode-cpptools/-/vscode-cpptools-5.0.0.tgz#f1195736af1cfa10727482be57093a3997c8f63b"
4758-
integrity sha512-TPG6/o9+DisDj2U4AiTOihtfjEzBb/4CErYaB1JIWFMZTQE7zlNTdsgCs+l4xIS2Y34us0RMBIC6On1mBuwxww==
4755+
vscode-cpptools@^6.1.0:
4756+
version "6.1.0"
4757+
resolved "https://registry.yarnpkg.com/vscode-cpptools/-/vscode-cpptools-6.1.0.tgz#d89bb225f91da45dbee6acbf45f6940aa3926df1"
4758+
integrity sha512-+40xMmzSlvaMwWEDIjhHl9+W1RH9xaEbiFAAgLWgyL1FXxQWBguWRHgS91qBJbuFAB9H4UBuK94iFMs+7BFclA==
47594759

47604760
vscode-jsonrpc@^3.6.2:
47614761
version "3.6.2"

0 commit comments

Comments
 (0)