https://github.com/AmrDeveloper updated https://github.com/llvm/llvm-project/pull/187580
>From 7bed20f61a35a14151de2d8db263f87fe4c5a8b2 Mon Sep 17 00:00:00 2001 From: Amr Hesham <[email protected]> Date: Thu, 19 Mar 2026 21:12:03 +0100 Subject: [PATCH 1/2] [Clang][Parser] Report error when attribute missing `]]` followed by `;;` --- clang/lib/Parse/ParseDeclCXX.cpp | 7 ------- .../cxx-attributes-missing-closing-in-switch.cpp | 15 +++++++++++++++ .../Parser/cxx-attributes-missing-closing.cpp | 5 +++++ ...attributes-missing-with-semi-bfore-closing.cpp | 5 +++++ 4 files changed, 25 insertions(+), 7 deletions(-) create mode 100644 clang/test/Parser/cxx-attributes-missing-closing-in-switch.cpp create mode 100644 clang/test/Parser/cxx-attributes-missing-closing.cpp create mode 100644 clang/test/Parser/cxx-attributes-missing-with-semi-bfore-closing.cpp diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp index 274c354d59808..c759d37815903 100644 --- a/clang/lib/Parse/ParseDeclCXX.cpp +++ b/clang/lib/Parse/ParseDeclCXX.cpp @@ -4681,13 +4681,6 @@ void Parser::ParseCXX11AttributeSpecifierInternal(ParsedAttributes &Attrs, Diag(Tok, diag::err_cxx11_attribute_forbids_ellipsis) << AttrName; } - // If we hit an error and recovered by parsing up to a semicolon, eat the - // semicolon and don't issue further diagnostics about missing brackets. - if (Tok.is(tok::semi)) { - ConsumeToken(); - return; - } - SourceLocation CloseLoc = Tok.getLocation(); if (ExpectAndConsume(tok::r_square)) SkipUntil(tok::r_square); diff --git a/clang/test/Parser/cxx-attributes-missing-closing-in-switch.cpp b/clang/test/Parser/cxx-attributes-missing-closing-in-switch.cpp new file mode 100644 index 0000000000000..55b7c0477d938 --- /dev/null +++ b/clang/test/Parser/cxx-attributes-missing-closing-in-switch.cpp @@ -0,0 +1,15 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +// expected-note@+1 {{to match this '{'}} +void a(int i) { + switch(i) { + case 1: + // expected-error@+2 {{expected ']'}} + // expected-error@+3 {{expected ']'}} + [[fallthrough;; + case 2: + ; + }; + // expected-error@+2 {{expected statement}} + // expected-error@+1 {{expected '}'}} +} diff --git a/clang/test/Parser/cxx-attributes-missing-closing.cpp b/clang/test/Parser/cxx-attributes-missing-closing.cpp new file mode 100644 index 0000000000000..87219eec75422 --- /dev/null +++ b/clang/test/Parser/cxx-attributes-missing-closing.cpp @@ -0,0 +1,5 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +// expected-error@+2 2 {{expected ']'}} +// expected-error@+1 {{expected external declaration}} +[[assume0;; diff --git a/clang/test/Parser/cxx-attributes-missing-with-semi-bfore-closing.cpp b/clang/test/Parser/cxx-attributes-missing-with-semi-bfore-closing.cpp new file mode 100644 index 0000000000000..0a45413159e56 --- /dev/null +++ b/clang/test/Parser/cxx-attributes-missing-with-semi-bfore-closing.cpp @@ -0,0 +1,5 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +// expected-error@+2 {{expected ']'}} +// expected-error@+1 {{expected external declaration}} +[[fallthrough;]] >From 8efcbd6f54487ecfb4eb5e416c23bb83d3f048a3 Mon Sep 17 00:00:00 2001 From: Amr Hesham <[email protected]> Date: Fri, 20 Mar 2026 18:55:53 +0100 Subject: [PATCH 2/2] Add releasenotes --- clang/docs/ReleaseNotes.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 3d8377e958263..865dc7c864380 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -305,6 +305,8 @@ Improvements to Clang's diagnostics (``-fimplicit-module-maps``). This does not affect module maps specified explicitly via ``-fmodule-map-file=``. +- Clang now emits error when attribute is missing closing ``]]`` followed by ``;;``. (#GH187223) + Improvements to Clang's time-trace ---------------------------------- _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
