Skip to content

Commit 1e58f14

Browse files
committed
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 diffblue#2370, run regression tests using both Clang and GCC, if available on a particular system.
1 parent e1f2e22 commit 1e58f14

File tree

5 files changed

+40
-5
lines changed

5 files changed

+40
-5
lines changed

regression/ansi-c/CMakeLists.txt

+23
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,32 @@ 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-clang"
27+
"$<TARGET_FILE:goto-cc> --native-compiler clang"
28+
"-C;-s;ansi-c-clang"
29+
"CORE"
30+
)
31+
add_test_pl_profile(
32+
"ansi-c-gcc"
33+
"$<TARGET_FILE:goto-cc> --native-compiler gcc"
34+
"-C;-X;fake-gcc-version;-s;ansi-c-gcc"
35+
"CORE"
36+
)
37+
add_test_pl_profile(
38+
"ansi-c-fake-gcc"
39+
"$<TARGET_FILE:goto-cc>"
40+
"-C;-I;fake-gcc-version;-s;ansi-c-fake-gcc"
41+
"CORE"
42+
)
43+
else()
2244
add_test_pl_tests(
2345
"$<TARGET_FILE:goto-cc>"
2446
)
47+
endif()
2548

2649
add_test_pl_profile(
2750
"ansi-c-c++-front-end"

regression/ansi-c/Makefile

+14-2
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,25 @@ 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) -X fake-gcc-version && \
29+
../test.pl -e -p -c $(exe) $(excluded_tests) -I fake-gcc-version ; \
30+
else \
31+
../test.pl -e -p -c $(exe) $(excluded_tests) ; \
32+
fi
2733
ifneq ($(BUILD_ENV_),MSVC)
2834
@../test.pl -e -p -c "$(exe) -xc++ -D_Bool=bool" -I test-c++-front-end -s c++-front-end $(excluded_tests)
2935
endif
3036

3137
tests.log: ../test.pl
32-
@../test.pl -e -p -c $(exe) $(excluded_tests)
38+
if which gcc && which clang ; then \
39+
../test.pl -e -p -c "$(exe) --native-compiler clang" $(excluded_tests) && \
40+
../test.pl -e -p -c "$(exe) --native-compiler gcc" $(excluded_tests) -X fake-gcc-version && \
41+
../test.pl -e -p -c $(exe) $(excluded_tests) -I fake-gcc-version ; \
42+
else \
43+
../test.pl -e -p -c $(exe) $(excluded_tests) ; \
44+
fi
3345
ifneq ($(BUILD_ENV_),MSVC)
3446
@../test.pl -e -p -c "$(exe) -xc++ -D_Bool=bool" -I test-c++-front-end -s c++-front-end $(excluded_tests)
3547
endif

regression/ansi-c/gcc_version1/test-gcc-4.desc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
CORE gcc-only
1+
CORE gcc-only fake-gcc-version
22
gcc-4.c
33
--native-compiler ./fake-gcc-4
44
^EXIT=0$

regression/ansi-c/gcc_version1/test-gcc-5.desc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
CORE gcc-only
1+
CORE gcc-only fake-gcc-version
22
gcc-5.c
33
--native-compiler ./fake-gcc-5
44
^EXIT=0$

regression/ansi-c/gcc_version1/test-gcc-7.desc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
CORE gcc-only
1+
CORE gcc-only fake-gcc-version
22
gcc-7.c
33
--native-compiler ./fake-gcc-7
44
^EXIT=0$

0 commit comments

Comments
 (0)