aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.misc-tests
diff options
context:
space:
mode:
authorJørgen Kvalsvik <jorgen.kvalsvik@woven-planet.global>2022-10-07 13:29:20 +0200
committerJørgen Kvalsvik <jorgen.kvalsvik@woven-planet.global>2022-10-14 10:46:28 +0200
commit98fef35ad1d017bb86f50afe69e25c128a1a1be2 (patch)
tree102bd098aff7c07a7706aa4cfc816477d98d6c1b /gcc/testsuite/gcc.misc-tests
parent4b04292b76e89b332ae70208aabf8f0e12f3a63f (diff)
downloadgcc-98fef35ad1d017bb86f50afe69e25c128a1a1be2.zip
gcc-98fef35ad1d017bb86f50afe69e25c128a1a1be2.tar.gz
gcc-98fef35ad1d017bb86f50afe69e25c128a1a1be2.tar.bz2
gcov: test line count for label in then/else block
Add a test to catch regression in line counts for labels on top of then/else blocks. Only the 'goto <label>' should contribute to the line counter for the label, not the if. gcc/testsuite/ChangeLog: * gcc.misc-tests/gcov-4.c: New testcase.
Diffstat (limited to 'gcc/testsuite/gcc.misc-tests')
-rw-r--r--gcc/testsuite/gcc.misc-tests/gcov-4.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/gcc/testsuite/gcc.misc-tests/gcov-4.c b/gcc/testsuite/gcc.misc-tests/gcov-4.c
index 498d299..da7929e 100644
--- a/gcc/testsuite/gcc.misc-tests/gcov-4.c
+++ b/gcc/testsuite/gcc.misc-tests/gcov-4.c
@@ -110,6 +110,29 @@ lab2:
return 8; /* count(1) */
}
+int
+test_goto3 (int i, int j)
+{
+ if (j) goto else_; /* count(1) */
+
+top:
+ if (i) /* count(1) */
+ {
+ i = do_something (i);
+ }
+ else
+ {
+else_: /* count(1) */
+ j = do_something (j); /* count(2) */
+ if (j) /* count(2) */
+ {
+ j = 0; /* count(1) */
+ goto top; /* count(1) */
+ }
+ }
+ return 16;
+}
+
void
call_goto ()
{
@@ -117,6 +140,7 @@ call_goto ()
goto_val += test_goto1 (1);
goto_val += test_goto2 (3);
goto_val += test_goto2 (30);
+ goto_val += test_goto3 (0, 1);
}
/* Check nested if-then-else statements. */
@@ -260,7 +284,7 @@ main()
call_unref ();
if ((for_val1 != 12)
|| (for_val2 != 87)
- || (goto_val != 15)
+ || (goto_val != 31)
|| (ifelse_val1 != 31)
|| (ifelse_val2 != 23)
|| (ifelse_val3 != 246)