Skip to content

Run C regression tests using clang and gcc when both are available #6670

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

Merged
merged 2 commits into from
Feb 26, 2022
Merged
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
31 changes: 28 additions & 3 deletions regression/ansi-c/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,34 @@ elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
"CORE"
)
else()
add_test_pl_tests(
"$<TARGET_FILE:goto-cc>"
)
find_program(CLANG_EXISTS "clang")
find_program(GCC_EXISTS "gcc")
if(CLANG_EXISTS)
add_test_pl_profile(
"ansi-c-clang"
"$<TARGET_FILE:goto-cc> --native-compiler clang"
"-C;-s;ansi-c-clang"
"CORE"
)
endif()
if(GCC_EXISTS)
add_test_pl_profile(
"ansi-c-gcc"
"$<TARGET_FILE:goto-cc> --native-compiler gcc"
"-C;-X;fake-gcc-version;-s;ansi-c-gcc"
"CORE"
)
add_test_pl_profile(
"ansi-c-fake-gcc"
"$<TARGET_FILE:goto-cc>"
"-C;-I;fake-gcc-version;-s;ansi-c-fake-gcc"
"CORE"
)
elseif(NOT CLANG_EXISTS)
add_test_pl_tests(
"$<TARGET_FILE:goto-cc>"
)
endif()

add_test_pl_profile(
"ansi-c-c++-front-end"
Expand Down
20 changes: 18 additions & 2 deletions regression/ansi-c/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,29 @@ endif
endif

test:
@../test.pl -e -p -c $(exe) $(excluded_tests)
if which clang ; then \
../test.pl -e -p -c "$(exe) --native-compiler clang" $(excluded_tests) ; \
fi
if which gcc ; then \
../test.pl -e -p -c "$(exe) --native-compiler gcc" $(excluded_tests) -X fake-gcc-version && \
../test.pl -e -p -c $(exe) $(excluded_tests) -I fake-gcc-version ; \
elif ! which clang ; then \
../test.pl -e -p -c $(exe) $(excluded_tests) ; \
fi
ifneq ($(BUILD_ENV_),MSVC)
@../test.pl -e -p -c "$(exe) -xc++ -D_Bool=bool" -I test-c++-front-end -s c++-front-end $(excluded_tests)
endif

tests.log: ../test.pl
@../test.pl -e -p -c $(exe) $(excluded_tests)
if which clang ; then \
../test.pl -e -p -c "$(exe) --native-compiler clang" $(excluded_tests) ; \
fi
if which gcc ; then \
../test.pl -e -p -c "$(exe) --native-compiler gcc" $(excluded_tests) -X fake-gcc-version && \
../test.pl -e -p -c $(exe) $(excluded_tests) -I fake-gcc-version ; \
elif ! which clang ; then \
../test.pl -e -p -c $(exe) $(excluded_tests) ; \
fi
ifneq ($(BUILD_ENV_),MSVC)
@../test.pl -e -p -c "$(exe) -xc++ -D_Bool=bool" -I test-c++-front-end -s c++-front-end $(excluded_tests)
endif
Expand Down
2 changes: 1 addition & 1 deletion regression/ansi-c/gcc_version1/test-gcc-4.desc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CORE gcc-only
CORE gcc-only fake-gcc-version
gcc-4.c
--native-compiler ./fake-gcc-4
^EXIT=0$
Expand Down
2 changes: 1 addition & 1 deletion regression/ansi-c/gcc_version1/test-gcc-5.desc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CORE gcc-only
CORE gcc-only fake-gcc-version
gcc-5.c
--native-compiler ./fake-gcc-5
^EXIT=0$
Expand Down
2 changes: 1 addition & 1 deletion regression/ansi-c/gcc_version1/test-gcc-7.desc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CORE gcc-only
CORE gcc-only fake-gcc-version
gcc-7.c
--native-compiler ./fake-gcc-7
^EXIT=0$
Expand Down
4 changes: 1 addition & 3 deletions src/ansi-c/c_typecheck_expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3092,9 +3092,7 @@ exprt c_typecheck_baset::do_special_functions(
{
// clang returns 4 for _Bool, gcc treats these as 'int'.
type_number =
config.ansi_c.preprocessor == configt::ansi_ct::preprocessort::CLANG
? 4u
: 1u;
config.ansi_c.mode == configt::ansi_ct::flavourt::CLANG ? 4u : 1u;
}
else
{
Expand Down