[clang] [clang][Parser] Fix crash on invalid attribute in constexpr function (PR #144286)
Iris Shi via cfe-commits
cfe-commits at lists.llvm.org
Sun Jun 15 22:49:25 PDT 2025
https://github.com/el-ev updated https://github.com/llvm/llvm-project/pull/144286
>From 45b05320cfe0106a54f31d7d5d5d6ed0e23faff3 Mon Sep 17 00:00:00 2001
From: Iris Shi <0.0 at owo.li>
Date: Mon, 16 Jun 2025 09:37:17 +0800
Subject: [PATCH 1/2] [clang][Parser] Fix crash on invalid attribute in
constexpr function
---
clang/lib/Parse/ParseDeclCXX.cpp | 4 ++++
clang/test/Parser/cxx-invalid-attr-in-constexpr-crash.cpp | 8 ++++++++
2 files changed, 12 insertions(+)
create mode 100644 clang/test/Parser/cxx-invalid-attr-in-constexpr-crash.cpp
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-attr-in-constexpr-crash.cpp b/clang/test/Parser/cxx-invalid-attr-in-constexpr-crash.cpp
new file mode 100644
index 0000000000000..82104779ca67e
--- /dev/null
+++ b/clang/test/Parser/cxx-invalid-attr-in-constexpr-crash.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// issue144264
+constexpr void test()
+{
+ using TT = struct T[deprecated{};
+ // expected-error at -1 {{use of undeclared identifier 'deprecated'}}
+}
>From fbc207ff1f6de0acb91ddc01565080bdcf70da98 Mon Sep 17 00:00:00 2001
From: Iris Shi <0.0 at owo.li>
Date: Mon, 16 Jun 2025 12:32:41 +0800
Subject: [PATCH 2/2] update release notes
---
clang/docs/ReleaseNotes.rst | 1 +
1 file changed, 1 insertion(+)
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 33ee8a53b5f37..f429abed7336f 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 an invalid attribute is applied to a using declaration in a ``constexpr`` function. (#GH144264)
Bug Fixes to Compiler Builtins
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
More information about the cfe-commits
mailing list