Author: Iris Shi
Date: 2025-06-16T23:17:47+08:00
New Revision: f0373295e82315f95a97ce1b34c78ff46f475863

URL: 
https://github.com/llvm/llvm-project/commit/f0373295e82315f95a97ce1b34c78ff46f475863
DIFF: 
https://github.com/llvm/llvm-project/commit/f0373295e82315f95a97ce1b34c78ff46f475863.diff

LOG: [clang][Parser] Fix crash on malformed using declaration in constexpr 
function (#144286)

Added: 
    clang/test/Parser/cxx-invalid-using-decl-in-constexpr-crash.cpp

Modified: 
    clang/docs/ReleaseNotes.rst
    clang/lib/Parse/ParseDeclCXX.cpp

Removed: 
    


################################################################################
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}}
+}


        
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to