public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug objc/103639] [11 Regression] switch case with break in fast enumeration loop generates wrong code Date: Mon, 24 Jan 2022 09:21:03 +0000 [thread overview] Message-ID: <bug-103639-4-h88kMMXUjb@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-103639-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103639 --- Comment #18 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-11 branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>: https://gcc.gnu.org/g:27cfe1068239cdafb727de36ec7d9ae19ff5c141 commit r11-9497-g27cfe1068239cdafb727de36ec7d9ae19ff5c141 Author: Jakub Jelinek <jakub@redhat.com> Date: Sat Jan 1 06:29:36 2022 +0100 objc: Fix handling of break stmt inside of switch inside of ObjC foreach [PR103639] The r11-3302-g3696a50beeb73f changes broke the following ObjC testcase. in_statement is either 0 (not in a looping statement), various IN_* flags for various kinds of looping statements (or OpenMP structured blocks) or those flags ored with IN_SWITCH_STMT when a switch appears inside of those contexts. This is because break binds to switch in that last case, but continue binds to the looping construct in that case. The c_finish_bc_stmt function performs diagnostics on incorrect break/continue uses and then checks if in_statement & IN_OBJC_FOREACH and in that case jumps to the label provided by the caller, otherwise emits a BREAK_STMT or CONTINUE_STMT. This is incorrect if we have ObjC foreach with switch nested in it and break inside of that, in_statement in that case is IN_OBJC_FOREACH | IN_SWITCH_STMT and is_break is true. We want to handle it like other breaks inside of switch, i.e. emit a BREAK_STMT. The following patch fixes that. 2022-01-01 Jakub Jelinek <jakub@redhat.com> PR objc/103639 * c-typeck.c (c_finish_bc_stmt): For break inside of switch inside of ObjC foreach, emit normal BREAK_STMT rather than goto to label. 2022-01-01 Iain Sandoe <iain@sandoe.co.uk> PR objc/103639 * objc.dg/pr103639.m: New test. (cherry picked from commit 222dbebefbbc07f78e51d82ba605988ef57e5fc9)
next prev parent reply other threads:[~2022-01-24 9:21 UTC|newest] Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-12-09 20:59 [Bug objc/103639] New: [REGRESSION] GCC 11.2 (or even earlier) breaks switch case with break in fast enumeration loop js-gcc at webkeks dot org 2021-12-09 21:05 ` [Bug objc/103639] " js-gcc at webkeks dot org 2021-12-09 21:11 ` js-gcc at webkeks dot org 2021-12-09 21:42 ` pinskia at gcc dot gnu.org 2021-12-09 21:44 ` js-gcc at webkeks dot org 2021-12-10 1:40 ` egallager at gcc dot gnu.org 2021-12-10 8:17 ` iains at gcc dot gnu.org 2021-12-10 8:41 ` [Bug objc/103639] [11/12 Regression] switch case with break in fast enumeration loop generates wrong code iains at gcc dot gnu.org 2021-12-10 9:52 ` iains at gcc dot gnu.org 2021-12-10 20:43 ` pinskia at gcc dot gnu.org 2021-12-29 15:19 ` jakub at gcc dot gnu.org 2021-12-29 15:31 ` jakub at gcc dot gnu.org 2021-12-29 15:36 ` iains at gcc dot gnu.org 2021-12-29 16:22 ` jakub at gcc dot gnu.org 2021-12-29 19:59 ` iains at gcc dot gnu.org 2021-12-29 20:29 ` iains at gcc dot gnu.org 2021-12-29 20:30 ` jakub at gcc dot gnu.org 2021-12-29 20:35 ` iains at gcc dot gnu.org 2022-01-01 5:32 ` cvs-commit at gcc dot gnu.org 2022-01-04 9:11 ` [Bug objc/103639] [11 " rguenth at gcc dot gnu.org 2022-01-24 9:21 ` cvs-commit at gcc dot gnu.org [this message] 2022-01-24 9:29 ` jakub at gcc dot gnu.org 2022-01-24 9:31 ` jakub at gcc dot gnu.org
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=bug-103639-4-h88kMMXUjb@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /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: linkBe 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).