Skip to content

Commit 3678c8d

Browse files
committed
C23 dialect support
1 parent baa0e37 commit 3678c8d

File tree

10 files changed

+157
-4
lines changed

10 files changed

+157
-4
lines changed

modules/vstudio/tests/vc2010/test_compile_settings.lua

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1477,6 +1477,22 @@
14771477
]]
14781478
end
14791479

1480+
function suite.onLanguage_C23_VS2019()
1481+
p.action.set("vs2019")
1482+
1483+
cdialect 'C23'
1484+
prepare()
1485+
test.capture [[
1486+
<ClCompile>
1487+
<PrecompiledHeader>NotUsing</PrecompiledHeader>
1488+
<WarningLevel>Level3</WarningLevel>
1489+
<Optimization>Disabled</Optimization>
1490+
<LanguageStandard_C>stdclatest</LanguageStandard_C>
1491+
<ExternalWarningLevel>Level3</ExternalWarningLevel>
1492+
</ClCompile>
1493+
]]
1494+
end
1495+
14801496
function suite.onLanguage_CppLatest_VS2010()
14811497
cppdialect 'C++latest'
14821498
prepare()

modules/vstudio/vs2010_vcxproj.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2064,6 +2064,8 @@
20642064
m.element("LanguageStandard_C", condition, 'stdc11')
20652065
elseif (cfg.cdialect == "C17") then
20662066
m.element("LanguageStandard_C", condition, 'stdc17')
2067+
elseif (cfg.cdialect == "C23") then
2068+
m.element("LanguageStandard_C", condition, 'stdclatest')
20672069
end
20682070
end
20692071
end

modules/xcode/tests/test_xcode_project.lua

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3445,6 +3445,58 @@
34453445
]]
34463446
end
34473447

3448+
function suite.XCBuildConfigurationProject_OnC17()
3449+
workspace("MyWorkspace")
3450+
cdialect("C17")
3451+
prepare()
3452+
xcode.XCBuildConfiguration_Project(tr, tr.configs[1])
3453+
test.capture [[
3454+
A14350AC4595EE5E57CE36EC /* Debug */ = {
3455+
isa = XCBuildConfiguration;
3456+
buildSettings = {
3457+
ARCHS = "$(NATIVE_ARCH_ACTUAL)";
3458+
CONFIGURATION_BUILD_DIR = "$(SYMROOT)";
3459+
CONFIGURATION_TEMP_DIR = "$(OBJROOT)";
3460+
GCC_C_LANGUAGE_STANDARD = c17;
3461+
GCC_OPTIMIZATION_LEVEL = 0;
3462+
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
3463+
GCC_WARN_ABOUT_RETURN_TYPE = YES;
3464+
GCC_WARN_UNUSED_VARIABLE = YES;
3465+
OBJROOT = obj/Debug;
3466+
ONLY_ACTIVE_ARCH = NO;
3467+
SYMROOT = bin/Debug;
3468+
};
3469+
name = Debug;
3470+
};
3471+
]]
3472+
end
3473+
3474+
function suite.XCBuildConfigurationProject_OnC23()
3475+
workspace("MyWorkspace")
3476+
cdialect("C23")
3477+
prepare()
3478+
xcode.XCBuildConfiguration_Project(tr, tr.configs[1])
3479+
test.capture [[
3480+
A14350AC4595EE5E57CE36EC /* Debug */ = {
3481+
isa = XCBuildConfiguration;
3482+
buildSettings = {
3483+
ARCHS = "$(NATIVE_ARCH_ACTUAL)";
3484+
CONFIGURATION_BUILD_DIR = "$(SYMROOT)";
3485+
CONFIGURATION_TEMP_DIR = "$(OBJROOT)";
3486+
GCC_C_LANGUAGE_STANDARD = c23;
3487+
GCC_OPTIMIZATION_LEVEL = 0;
3488+
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
3489+
GCC_WARN_ABOUT_RETURN_TYPE = YES;
3490+
GCC_WARN_UNUSED_VARIABLE = YES;
3491+
OBJROOT = obj/Debug;
3492+
ONLY_ACTIVE_ARCH = NO;
3493+
SYMROOT = bin/Debug;
3494+
};
3495+
name = Debug;
3496+
};
3497+
]]
3498+
end
3499+
34483500
function suite.XCBuildConfigurationProject_OnGnu89()
34493501
workspace("MyWorkspace")
34503502
cdialect("gnu89")
@@ -3549,6 +3601,58 @@
35493601
]]
35503602
end
35513603

3604+
function suite.XCBuildConfigurationProject_OnGnu17()
3605+
workspace("MyWorkspace")
3606+
cdialect("gnu17")
3607+
prepare()
3608+
xcode.XCBuildConfiguration_Project(tr, tr.configs[1])
3609+
test.capture [[
3610+
A14350AC4595EE5E57CE36EC /* Debug */ = {
3611+
isa = XCBuildConfiguration;
3612+
buildSettings = {
3613+
ARCHS = "$(NATIVE_ARCH_ACTUAL)";
3614+
CONFIGURATION_BUILD_DIR = "$(SYMROOT)";
3615+
CONFIGURATION_TEMP_DIR = "$(OBJROOT)";
3616+
GCC_C_LANGUAGE_STANDARD = gnu17;
3617+
GCC_OPTIMIZATION_LEVEL = 0;
3618+
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
3619+
GCC_WARN_ABOUT_RETURN_TYPE = YES;
3620+
GCC_WARN_UNUSED_VARIABLE = YES;
3621+
OBJROOT = obj/Debug;
3622+
ONLY_ACTIVE_ARCH = NO;
3623+
SYMROOT = bin/Debug;
3624+
};
3625+
name = Debug;
3626+
};
3627+
]]
3628+
end
3629+
3630+
function suite.XCBuildConfigurationProject_OnGnu23()
3631+
workspace("MyWorkspace")
3632+
cdialect("gnu23")
3633+
prepare()
3634+
xcode.XCBuildConfiguration_Project(tr, tr.configs[1])
3635+
test.capture [[
3636+
A14350AC4595EE5E57CE36EC /* Debug */ = {
3637+
isa = XCBuildConfiguration;
3638+
buildSettings = {
3639+
ARCHS = "$(NATIVE_ARCH_ACTUAL)";
3640+
CONFIGURATION_BUILD_DIR = "$(SYMROOT)";
3641+
CONFIGURATION_TEMP_DIR = "$(OBJROOT)";
3642+
GCC_C_LANGUAGE_STANDARD = gnu23;
3643+
GCC_OPTIMIZATION_LEVEL = 0;
3644+
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
3645+
GCC_WARN_ABOUT_RETURN_TYPE = YES;
3646+
GCC_WARN_UNUSED_VARIABLE = YES;
3647+
OBJROOT = obj/Debug;
3648+
ONLY_ACTIVE_ARCH = NO;
3649+
SYMROOT = bin/Debug;
3650+
};
3651+
name = Debug;
3652+
};
3653+
]]
3654+
end
3655+
35523656
function suite.XCBuildConfigurationProject_OnCppDefault()
35533657
workspace("MyWorkspace")
35543658
cppdialect("Default")

modules/xcode/xcode_common.lua

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1369,10 +1369,14 @@
13691369
["C90"] = "c90",
13701370
["C99"] = "c99",
13711371
["C11"] = "c11",
1372+
["C17"] = "c17",
1373+
["C23"] = "c23",
13721374
["gnu89"] = "gnu89",
13731375
["gnu90"] = "gnu90",
13741376
["gnu99"] = "gnu99",
1375-
["gnu11"] = "gnu11"
1377+
["gnu11"] = "gnu11",
1378+
["gnu17"] = "gnu17",
1379+
["gnu23"] = "gnu23",
13761380
}
13771381

13781382
function xcode.XCBuildConfiguration_CLanguageStandard(settings, cfg)

src/_premake_init.lua

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,11 +491,13 @@
491491
"C99",
492492
"C11",
493493
"C17",
494+
"C23",
494495
"gnu89",
495496
"gnu90",
496497
"gnu99",
497498
"gnu11",
498-
"gnu17"
499+
"gnu17",
500+
"gnu23",
499501
}
500502
}
501503

src/tools/gcc.lua

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,11 +172,13 @@
172172
["C99"] = "-std=c99",
173173
["C11"] = "-std=c11",
174174
["C17"] = "-std=c17",
175+
["C23"] = "-std=c23",
175176
["gnu89"] = "-std=gnu89",
176177
["gnu90"] = "-std=gnu90",
177178
["gnu99"] = "-std=gnu99",
178179
["gnu11"] = "-std=gnu11",
179-
["gnu17"] = "-std=gnu17"
180+
["gnu17"] = "-std=gnu17",
181+
["gnu23"] = "-std=gnu23",
180182
}
181183
}
182184

src/tools/msc.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,8 @@
179179
msc.cflags = {
180180
cdialect = {
181181
["C11"] = "/std:c11",
182-
["C17"] = "/std:c17"
182+
["C17"] = "/std:c17",
183+
["C23"] = "/std:clatest"
183184
}
184185
}
185186

tests/tools/test_gcc.lua

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -947,6 +947,13 @@ end
947947
test.isequal({ }, gcc.getcxxflags(cfg))
948948
end
949949

950+
function suite.cflags_onC23()
951+
cdialect "C23"
952+
prepare()
953+
test.contains({ "-std=c23" }, gcc.getcflags(cfg))
954+
test.isequal({ }, gcc.getcxxflags(cfg))
955+
end
956+
950957
function suite.cflags_ongnu89()
951958
cdialect "gnu89"
952959
prepare()
@@ -982,6 +989,13 @@ end
982989
test.isequal({ }, gcc.getcxxflags(cfg))
983990
end
984991

992+
function suite.cflags_ongnu23()
993+
cdialect "gnu23"
994+
prepare()
995+
test.contains({ "-std=gnu23" }, gcc.getcflags(cfg))
996+
test.isequal({ }, gcc.getcxxflags(cfg))
997+
end
998+
985999
function suite.cxxflags_onCppDefault()
9861000
cppdialect "Default"
9871001
prepare()

tests/tools/test_msc.lua

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,12 @@ end
390390
test.contains('/std:c17', msc.getcflags(cfg))
391391
end
392392

393+
function suite.cdialectC23()
394+
cdialect "C23"
395+
prepare()
396+
test.contains('/std:clatest', msc.getcflags(cfg))
397+
end
398+
393399
--
394400
-- Check handling of cppdialect.
395401
--

website/docs/cdialect.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@ cdialect "value"
1414
* `C99`: ISO C99
1515
* `C11`: ISO C11
1616
* `C17`: ISO C17
17+
* `C23`: ISO C23
1718
* `gnu89`: GNU dialect of ISO C89
1819
* `gnu90`: GNU dialect of ISO C90
1920
* `gnu99`: GNU dialect of ISO C99
2021
* `gnu11`: GNU dialect of ISO C11
2122
* `gnu17`: GNU dialect of ISO C17
23+
* `gnu23`: GNU dialect of ISO C23
2224

2325
### Applies To ###
2426

0 commit comments

Comments
 (0)