From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 584BB385841B; Tue, 8 Nov 2022 22:40:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 584BB385841B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1667947248; bh=LDjra8Dv5CBN/I9wALzkIdXkcpNScKnnI6l4qEffPN4=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Ap5afi9ssB6e3mK7MEz4b1AT19/xUtqpxprI2cKSWJjzPhxRwac/wQ05bLNDaB4Tv NTWt2puq36pCsFvnD+xu7NcZz0RnKwtxZNt1dgEUZCvhmmY6pp/VTFm5ZaVLqeYzvQ zlk1o7g//ZMBxH82tnBquX2azv27BAR+ieApEscA= From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/107571] Missing fallthrough attribute diagnostics Date: Tue, 08 Nov 2022 22:40:48 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub at gcc dot gnu.org X-Bugzilla-Status: NEW 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: cc Message-ID: In-Reply-To: References: 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 Jakub Jelinek changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jsm28 at gcc dot gnu.org --- Comment #2 from Jakub Jelinek --- And looking at the C wording in n2596.pdf, seems it is different again: "The next block item(6.8.2) that would be encountered after a fallthrough declaration shall be a case label or default label associated with the smal= lest enclosing switch statement." So, if my understanding is well, int j =3D 0; switch (n) { case 1: for (int i =3D 0; i < 1; ++i) { [[fallthrough]]; // Invalid in both C and C++ } case 2: while (++j < 2) { [[fallthrough]]; // Invalid in both C and C++ } case 3: do { [[fallthrough]]; // Invalid in both C and C++ } while (0); case 4: if (1) { [[fallthrough]]; // Invalid in C, valid in C++? } case 5: for (int i =3D 0; i < 1; ++i) [[fallthrough]]; // Invalid in C++, dunno about C case 6: while (++j < 2) [[fallthrough]]; // Invalid in C++, dunno about C case 7: do [[fallthrough]]; // Invalid in C++, dunno about C while (0); case 8: if (1) [[fallthrough]]; // Dunno about either C or C++ case 9: { [[fallthrough]]; // Invalid in C, valid in C++? } default: break; }=