From 4d9787099b2418910eb41ffb42c5dc49644a46de Mon Sep 17 00:00:00 2001 From: Jarod42 Date: Mon, 6 Mar 2023 12:44:07 +0100 Subject: [PATCH] Fix `compileas "C"` and `"C++"` for gcc (shared with clang). --- src/tools/gcc.lua | 2 ++ tests/tools/test_gcc.lua | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/src/tools/gcc.lua b/src/tools/gcc.lua index 52076f8c4..1f85760f8 100644 --- a/src/tools/gcc.lua +++ b/src/tools/gcc.lua @@ -134,6 +134,8 @@ Off = "-fno-omit-frame-pointer" }, compileas = { + ["C"] = "-x c", + ["C++"] = "-x c++", ["Objective-C"] = "-x objective-c", ["Objective-C++"] = "-x objective-c++", } diff --git a/tests/tools/test_gcc.lua b/tests/tools/test_gcc.lua index d10746d9b..f107dff5b 100644 --- a/tests/tools/test_gcc.lua +++ b/tests/tools/test_gcc.lua @@ -1099,3 +1099,36 @@ test.excludes({ "-fvisibility-inlines-hidden" }, gcc.getcflags(cfg)) test.contains({ "-fvisibility-inlines-hidden" }, gcc.getcxxflags(cfg)) end + +-- +-- Test compileas. +-- + + function suite.cxxflags_compileasC() + compileas "C" + prepare() + test.contains({ "-x c" }, gcc.getcflags(cfg)) + test.contains({ "-x c" }, gcc.getcxxflags(cfg)) + end + + function suite.cxxflags_compileasCPP() + compileas "C++" + prepare() + test.contains({ "-x c++" }, gcc.getcflags(cfg)) + test.contains({ "-x c++" }, gcc.getcxxflags(cfg)) + end + + function suite.cxxflags_compileasObjC() + compileas "Objective-C" + prepare() + test.contains({ "-x objective-c" }, gcc.getcflags(cfg)) + test.contains({ "-x objective-c" }, gcc.getcxxflags(cfg)) + end + + function suite.cxxflags_compileasObjCPP() + compileas "Objective-C++" + + prepare() + test.contains({ "-x objective-c++" }, gcc.getcflags(cfg)) + test.contains({ "-x objective-c++" }, gcc.getcxxflags(cfg)) + end