Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C23 dialect support #2414

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions modules/vstudio/tests/vc2010/test_compile_settings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1477,6 +1477,22 @@
]]
end

function suite.onLanguage_C23_VS2019()
p.action.set("vs2019")

cdialect 'C23'
prepare()
test.capture [[
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<LanguageStandard_C>stdclatest</LanguageStandard_C>
<ExternalWarningLevel>Level3</ExternalWarningLevel>
</ClCompile>
]]
end

function suite.onLanguage_CppLatest_VS2010()
cppdialect 'C++latest'
prepare()
Expand Down
2 changes: 2 additions & 0 deletions modules/vstudio/vs2010_vcxproj.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2064,6 +2064,8 @@
m.element("LanguageStandard_C", condition, 'stdc11')
elseif (cfg.cdialect == "C17") then
m.element("LanguageStandard_C", condition, 'stdc17')
elseif (cfg.cdialect == "C23") then
m.element("LanguageStandard_C", condition, 'stdclatest')
end
end
end
Expand Down
104 changes: 104 additions & 0 deletions modules/xcode/tests/test_xcode_project.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3445,6 +3445,58 @@
]]
end

function suite.XCBuildConfigurationProject_OnC17()
workspace("MyWorkspace")
cdialect("C17")
prepare()
xcode.XCBuildConfiguration_Project(tr, tr.configs[1])
test.capture [[
A14350AC4595EE5E57CE36EC /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(NATIVE_ARCH_ACTUAL)";
CONFIGURATION_BUILD_DIR = "$(SYMROOT)";
CONFIGURATION_TEMP_DIR = "$(OBJROOT)";
GCC_C_LANGUAGE_STANDARD = c17;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
OBJROOT = obj/Debug;
ONLY_ACTIVE_ARCH = NO;
SYMROOT = bin/Debug;
};
name = Debug;
};
]]
end

function suite.XCBuildConfigurationProject_OnC23()
workspace("MyWorkspace")
cdialect("C23")
prepare()
xcode.XCBuildConfiguration_Project(tr, tr.configs[1])
test.capture [[
A14350AC4595EE5E57CE36EC /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(NATIVE_ARCH_ACTUAL)";
CONFIGURATION_BUILD_DIR = "$(SYMROOT)";
CONFIGURATION_TEMP_DIR = "$(OBJROOT)";
GCC_C_LANGUAGE_STANDARD = c23;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
OBJROOT = obj/Debug;
ONLY_ACTIVE_ARCH = NO;
SYMROOT = bin/Debug;
};
name = Debug;
};
]]
end

function suite.XCBuildConfigurationProject_OnGnu89()
workspace("MyWorkspace")
cdialect("gnu89")
Expand Down Expand Up @@ -3549,6 +3601,58 @@
]]
end

function suite.XCBuildConfigurationProject_OnGnu17()
workspace("MyWorkspace")
cdialect("gnu17")
prepare()
xcode.XCBuildConfiguration_Project(tr, tr.configs[1])
test.capture [[
A14350AC4595EE5E57CE36EC /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(NATIVE_ARCH_ACTUAL)";
CONFIGURATION_BUILD_DIR = "$(SYMROOT)";
CONFIGURATION_TEMP_DIR = "$(OBJROOT)";
GCC_C_LANGUAGE_STANDARD = gnu17;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
OBJROOT = obj/Debug;
ONLY_ACTIVE_ARCH = NO;
SYMROOT = bin/Debug;
};
name = Debug;
};
]]
end

function suite.XCBuildConfigurationProject_OnGnu23()
workspace("MyWorkspace")
cdialect("gnu23")
prepare()
xcode.XCBuildConfiguration_Project(tr, tr.configs[1])
test.capture [[
A14350AC4595EE5E57CE36EC /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(NATIVE_ARCH_ACTUAL)";
CONFIGURATION_BUILD_DIR = "$(SYMROOT)";
CONFIGURATION_TEMP_DIR = "$(OBJROOT)";
GCC_C_LANGUAGE_STANDARD = gnu23;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
OBJROOT = obj/Debug;
ONLY_ACTIVE_ARCH = NO;
SYMROOT = bin/Debug;
};
name = Debug;
};
]]
end

function suite.XCBuildConfigurationProject_OnCppDefault()
workspace("MyWorkspace")
cppdialect("Default")
Expand Down
6 changes: 5 additions & 1 deletion modules/xcode/xcode_common.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1369,10 +1369,14 @@
["C90"] = "c90",
["C99"] = "c99",
["C11"] = "c11",
["C17"] = "c17",
["C23"] = "c23",
["gnu89"] = "gnu89",
["gnu90"] = "gnu90",
["gnu99"] = "gnu99",
["gnu11"] = "gnu11"
["gnu11"] = "gnu11",
["gnu17"] = "gnu17",
["gnu23"] = "gnu23",
}

function xcode.XCBuildConfiguration_CLanguageStandard(settings, cfg)
Expand Down
4 changes: 3 additions & 1 deletion src/_premake_init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -491,11 +491,13 @@
"C99",
"C11",
"C17",
"C23",
"gnu89",
"gnu90",
"gnu99",
"gnu11",
"gnu17"
"gnu17",
"gnu23",
}
}

Expand Down
4 changes: 3 additions & 1 deletion src/tools/gcc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,13 @@
["C99"] = "-std=c99",
["C11"] = "-std=c11",
["C17"] = "-std=c17",
["C23"] = "-std=c23",
["gnu89"] = "-std=gnu89",
["gnu90"] = "-std=gnu90",
["gnu99"] = "-std=gnu99",
["gnu11"] = "-std=gnu11",
["gnu17"] = "-std=gnu17"
["gnu17"] = "-std=gnu17",
["gnu23"] = "-std=gnu23",
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/tools/msc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@
msc.cflags = {
cdialect = {
["C11"] = "/std:c11",
["C17"] = "/std:c17"
["C17"] = "/std:c17",
["C23"] = "/std:clatest"
}
}

Expand Down
14 changes: 14 additions & 0 deletions tests/tools/test_gcc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -947,6 +947,13 @@ end
test.isequal({ }, gcc.getcxxflags(cfg))
end

function suite.cflags_onC23()
cdialect "C23"
prepare()
test.contains({ "-std=c23" }, gcc.getcflags(cfg))
test.isequal({ }, gcc.getcxxflags(cfg))
end

function suite.cflags_ongnu89()
cdialect "gnu89"
prepare()
Expand Down Expand Up @@ -982,6 +989,13 @@ end
test.isequal({ }, gcc.getcxxflags(cfg))
end

function suite.cflags_ongnu23()
cdialect "gnu23"
prepare()
test.contains({ "-std=gnu23" }, gcc.getcflags(cfg))
test.isequal({ }, gcc.getcxxflags(cfg))
end

function suite.cxxflags_onCppDefault()
cppdialect "Default"
prepare()
Expand Down
6 changes: 6 additions & 0 deletions tests/tools/test_msc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,12 @@ end
test.contains('/std:c17', msc.getcflags(cfg))
end

function suite.cdialectC23()
cdialect "C23"
prepare()
test.contains('/std:clatest', msc.getcflags(cfg))
end

--
-- Check handling of cppdialect.
--
Expand Down
2 changes: 2 additions & 0 deletions website/docs/cdialect.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ cdialect "value"
* `C99`: ISO C99
* `C11`: ISO C11
* `C17`: ISO C17
* `C23`: ISO C23
* `gnu89`: GNU dialect of ISO C89
* `gnu90`: GNU dialect of ISO C90
* `gnu99`: GNU dialect of ISO C99
* `gnu11`: GNU dialect of ISO C11
* `gnu17`: GNU dialect of ISO C17
* `gnu23`: GNU dialect of ISO C23

### Applies To ###

Expand Down
Loading