Skip to content

Commit f037329

Browse files
authored
[clang][Parser] Fix crash on malformed using declaration in constexpr function (#144286)
1 parent 38fa753 commit f037329

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,7 @@ Bug Fixes in This Version
704704
- Fixed a bug with constexpr evaluation for structs containing unions in case of C++ modules. (#GH143168)
705705
- Fixed incorrect token location when emitting diagnostics for tokens expanded from macros. (#GH143216)
706706
- Fixed an infinite recursion when checking constexpr destructors. (#GH141789)
707+
- Fixed a crash when a malformed using declaration appears in a ``constexpr`` function. (#GH144264)
707708

708709
Bug Fixes to Compiler Builtins
709710
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

clang/lib/Parse/ParseDeclCXX.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -760,6 +760,10 @@ Parser::DeclGroupPtrTy Parser::ParseUsingDeclaration(
760760

761761
Decl *AD = ParseAliasDeclarationAfterDeclarator(
762762
TemplateInfo, UsingLoc, D, DeclEnd, AS, Attrs, &DeclFromDeclSpec);
763+
764+
if (!AD)
765+
return nullptr;
766+
763767
return Actions.ConvertDeclToDeclGroup(AD, DeclFromDeclSpec);
764768
}
765769

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// RUN: %clang_cc1 -fsyntax-only -verify %s
2+
3+
// issue144264
4+
constexpr void test()
5+
{
6+
using TT = struct T[;
7+
// expected-error@-1 {{expected expression}}
8+
}

0 commit comments

Comments
 (0)