From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id C29293858C52; Tue, 8 Nov 2022 14:49:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C29293858C52 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1667918942; bh=1nWbTc7EVe37qH2h9H9S1gSMWQRAYPuHRAt8H+ix7CY=; h=From:To:Subject:Date:From; b=pE7W+Wn+aktCQZkUlnVRlg3rABcGG/XsODP3G/ta59ywdb/lCZgiz/+4C+6Kmiz8T 8NFIVC+wGklNsSkdrOJ3mqRCWTjWtuJ+DOhO8SPaRIPyeZylOm/YRkF/PjF4AXaoqM 6S/rj/jaUubnw3PTvgYdP69YoA9QIpwxEhi9bmyg= From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/107571] New: Missing fallthrough attribute diagnostics Date: Tue, 08 Nov 2022 14:49:02 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D107571 Bug ID: 107571 Summary: Missing fallthrough attribute diagnostics Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: jakub at gcc dot gnu.org Target Milestone: --- On: void foo (int n) { void g(), h(), i(); switch (n) { case 1: case 2: g(); [[fallthrough]]; case 3: // warning on fallthrough discouraged do { [[fallthrough]]; // error: next statement is not part of the same substatement execution } while (false); case 6: do { [[fallthrough]]; // error: next statement is not part of the same substatement execution } while (n--); case 7: while (false) { [[fallthrough]]; // error: next statement is not part of the same substatement execution } case 5: h(); case 4: // implementation may warn on fallthrough i(); [[fallthrough]]; // error } } mentioned in https://isocpp.org/files/papers/D2552R1.pdf we don't diagnose misplaced [[fallthrough]] in 2 spots. The original dump shows: switch (n) { case 1:; case 2:; <>>>>; <>>>>; case 3:; <>>>>; case 6:; :; <>>>>; if (<>) goto ; else goto ; :; case 7:; goto ; <>>>>; :; case 5:; <>>>>; case 4:; <>>>>; <>>>>; } so the reason we don't warn in the do { ... } while (false); case is that it disappears probably during genericize_c_loop and the while (false) case because the genericization in = that case makes the loop body followed by artificial label.=