From: "Jørgen Kvalsvik" <jorgen.kvalsvik@woven-planet.global>
To: gcc-patches@gcc.gnu.org
Cc: richard.guenther@gmail.com, mliska@suse.cz,
"Jørgen Kvalsvik" <jorgen.kvalsvik@woven-planet.global>
Subject: [PATCH 2/2] gcov: test line count for label in then/else block
Date: Tue, 11 Oct 2022 14:43:03 +0200 [thread overview]
Message-ID: <20221011124303.99673-2-jorgen.kvalsvik@woven-planet.global> (raw)
In-Reply-To: <20221011124303.99673-1-jorgen.kvalsvik@woven-planet.global>
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:
---
gcc/testsuite/gcc.misc-tests/gcov-4.c | 26 +++++++++++++++++++++++++-
1 file changed, 25 insertions(+), 1 deletion(-)
diff --git a/gcc/testsuite/gcc.misc-tests/gcov-4.c b/gcc/testsuite/gcc.misc-tests/gcov-4.c
index 498d299b66b..da7929ef7fc 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)
--
2.34.0
next prev parent reply other threads:[~2022-10-11 12:43 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-11 12:43 [PATCH 1/2] gcov: test switch/break line counts Jørgen Kvalsvik
2022-10-11 12:43 ` Jørgen Kvalsvik [this message]
2022-10-13 11:40 ` [PATCH 2/2] gcov: test line count for label in then/else block Richard Biener
2022-10-11 13:55 ` [PATCH 1/2] gcov: test switch/break line counts Michael Matz
2022-10-11 13:57 ` Jørgen Kvalsvik
2022-10-11 14:00 ` Michael Matz
2022-10-13 11:39 ` Richard Biener
2022-10-14 10:09 ` Jørgen Kvalsvik
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221011124303.99673-2-jorgen.kvalsvik@woven-planet.global \
--to=jorgen.kvalsvik@woven-planet.global \
--cc=gcc-patches@gcc.gnu.org \
--cc=mliska@suse.cz \
--cc=richard.guenther@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).