Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 10c28e9

Browse files
committedFeb 15, 2022
Run C regression tests using clang and gcc when both are available
Our C front-end seeks to conform to whatever interpretation of the C standard the underlying host C compiler has. To avoid incompatibilities as documented in #2370, run regression tests using both Clang and GCC, if available on a particular system.
1 parent c558465 commit 10c28e9

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed
 

‎regression/ansi-c/CMakeLists.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,26 @@ elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
1919
"CORE"
2020
)
2121
else()
22+
find_program(CLANG_EXISTS "clang")
23+
find_program(GCC_EXISTS "gcc")
24+
if(CLANG_EXISTS AND GCC_EXISTS)
25+
add_test_pl_profile(
26+
"ansi-c-gcc"
27+
"$<TARGET_FILE:goto-cc> --native-compiler gcc"
28+
"-C;-s;ansi-c-gcc"
29+
"CORE"
30+
)
31+
add_test_pl_profile(
32+
"ansi-c-clang"
33+
"$<TARGET_FILE:goto-cc> --native-compiler clang"
34+
"-C;-s;ansi-c-clang"
35+
"CORE"
36+
)
37+
else()
2238
add_test_pl_tests(
2339
"$<TARGET_FILE:goto-cc>"
2440
)
41+
endif()
2542

2643
add_test_pl_profile(
2744
"ansi-c-c++-front-end"

‎regression/ansi-c/Makefile

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,23 @@ endif
2323
endif
2424

2525
test:
26-
@../test.pl -e -p -c $(exe) $(excluded_tests)
26+
if which gcc && which clang ; then \
27+
../test.pl -e -p -c "$(exe) --native-compiler clang" $(excluded_tests) && \
28+
../test.pl -e -p -c "$(exe) --native-compiler gcc" $(excluded_tests) ; \
29+
else \
30+
../test.pl -e -p -c $(exe) $(excluded_tests) ; \
31+
fi
2732
ifneq ($(BUILD_ENV_),MSVC)
2833
@../test.pl -e -p -c "$(exe) -xc++ -D_Bool=bool" -I test-c++-front-end -s c++-front-end $(excluded_tests)
2934
endif
3035

3136
tests.log: ../test.pl
32-
@../test.pl -e -p -c $(exe) $(excluded_tests)
37+
if which gcc && which clang ; then \
38+
../test.pl -e -p -c "$(exe) --native-compiler clang" $(excluded_tests) && \
39+
../test.pl -e -p -c "$(exe) --native-compiler gcc" $(excluded_tests) ; \
40+
else \
41+
../test.pl -e -p -c $(exe) $(excluded_tests) ; \
42+
fi
3343
ifneq ($(BUILD_ENV_),MSVC)
3444
@../test.pl -e -p -c "$(exe) -xc++ -D_Bool=bool" -I test-c++-front-end -s c++-front-end $(excluded_tests)
3545
endif

0 commit comments

Comments
 (0)
Please sign in to comment.