llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Oleksandr T. (a-tarasyuk) <details> <summary>Changes</summary> Fixes #<!-- -->108687 --- Full diff: https://github.com/llvm/llvm-project/pull/108701.diff 3 Files Affected: - (modified) clang/docs/ReleaseNotes.rst (+1-1) - (modified) clang/lib/Parse/ParseDeclCXX.cpp (+2) - (modified) clang/test/SemaCXX/static-assert-cxx26.cpp (+3) ``````````diff diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 79b154ef1aef5e..27dde935ad19b9 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -388,7 +388,7 @@ Bug Fixes to C++ Support - Fixed a crash in the typo correction of an invalid CTAD guide. (#GH107887) - Fixed a crash when clang tries to subtitute parameter pack while retaining the parameter pack. #GH63819, #GH107560 - +- Fix a crash when a static assert declaration has an invalid close location. (#GH108687) Bug Fixes to AST Handling ^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp index 6370da1fab0042..d02601172fe239 100644 --- a/clang/lib/Parse/ParseDeclCXX.cpp +++ b/clang/lib/Parse/ParseDeclCXX.cpp @@ -1110,6 +1110,8 @@ Decl *Parser::ParseStaticAssertDeclaration(SourceLocation &DeclEnd) { } T.consumeClose(); + if (T.getCloseLocation().isInvalid()) + return nullptr; DeclEnd = Tok.getLocation(); ExpectAndConsumeSemi(diag::err_expected_semi_after_static_assert, TokName); diff --git a/clang/test/SemaCXX/static-assert-cxx26.cpp b/clang/test/SemaCXX/static-assert-cxx26.cpp index 7d896d8b365b74..95ffa8cd68cf7c 100644 --- a/clang/test/SemaCXX/static-assert-cxx26.cpp +++ b/clang/test/SemaCXX/static-assert-cxx26.cpp @@ -415,3 +415,6 @@ static_assert( // expected-note@-1 {{read of dereferenced one-past-the-end pointer is not allowed in a constant expression}} ); } + +static_assert(true, "" // expected-note {{to match this '('}} + // expected-error {{expected ')'}} `````````` </details> https://github.com/llvm/llvm-project/pull/108701 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits