diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 33ee8a53b5f37..59d9612268d30 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -704,6 +704,7 @@ Bug Fixes in This Version - Fixed a bug with constexpr evaluation for structs containing unions in case of C++ modules. (#GH143168) - Fixed incorrect token location when emitting diagnostics for tokens expanded from macros. (#GH143216) - Fixed an infinite recursion when checking constexpr destructors. (#GH141789) +- Fixed a crash when a malformed using declaration appears in a ``constexpr`` function. (#GH144264) Bug Fixes to Compiler Builtins ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp index f31c9265a0074..a5c76501c7c18 100644 --- a/clang/lib/Parse/ParseDeclCXX.cpp +++ b/clang/lib/Parse/ParseDeclCXX.cpp @@ -760,6 +760,10 @@ Parser::DeclGroupPtrTy Parser::ParseUsingDeclaration( Decl *AD = ParseAliasDeclarationAfterDeclarator( TemplateInfo, UsingLoc, D, DeclEnd, AS, Attrs, &DeclFromDeclSpec); + + if (!AD) + return nullptr; + return Actions.ConvertDeclToDeclGroup(AD, DeclFromDeclSpec); } diff --git a/clang/test/Parser/cxx-invalid-using-decl-in-constexpr-crash.cpp b/clang/test/Parser/cxx-invalid-using-decl-in-constexpr-crash.cpp new file mode 100644 index 0000000000000..94fa8c8c820a5 --- /dev/null +++ b/clang/test/Parser/cxx-invalid-using-decl-in-constexpr-crash.cpp @@ -0,0 +1,8 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +// issue144264 +constexpr void test() +{ + using TT = struct T[; + // expected-error@-1 {{expected expression}} +}