Some expressions create CFGs isomorphic to those with multi-term expressions, e.g. if (a) if (b) {} is equivalent to if (a && b) {}, and there is no real recovery for this. The test is added to 1. document the behaviour and 2. detect if the cfg generation changes in a way that (correctly) splits the ifs.
Note that some arithmetic is performed between the else-if and the following if. This is not sufficient to create a new basic block, and all sorts of arithmetic and side effect is possible between terms in an arbitrary boolean expression anyway, for example if (a++ && --b). --- gcc/testsuite/gcc.misc-tests/gcov-19.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/gcc/testsuite/gcc.misc-tests/gcov-19.c b/gcc/testsuite/gcc.misc-tests/gcov-19.c index 662f4ca2864..5b5c1c275b0 100644 --- a/gcc/testsuite/gcc.misc-tests/gcov-19.c +++ b/gcc/testsuite/gcc.misc-tests/gcov-19.c @@ -146,6 +146,26 @@ mcdc004e (int a, int b, int c) } } +/* else-if is not immune to the else-less fuse. This test is also put in as a + * detection mechanism - sif this should register as 3 individual decisions + * then the test should be updated and fixed to reflect it. */ +int +mcdc004f (int a, int b, int c) +{ + if (a) /* conditions(1/2) false(0) */ + /* conditions(end) */ + { + x = 1; + } + else if (b) /* conditions(0/4) true(0 1) false(0 1) */ + /* conditions(end) */ + { + x = 2; + if (c) + x = 3; + } +} + /* mixing && and || works */ void mcdc005a (int a, int b, int c) @@ -1137,6 +1157,8 @@ int main () mcdc004e (0, 0, 0); mcdc004e (1, 1, 1); + mcdc004f (1, 1, 1); + mcdc005a (1, 0, 1); mcdc005b (1, 1, 0, 0); -- 2.30.2