-
Notifications
You must be signed in to change notification settings - Fork 14k
[clang][Parser] Fix crash on malformed using declaration in constexpr function #144286
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-clang Author: Iris Shi (el-ev) Changes
Full diff: https://github.com/llvm/llvm-project/pull/144286.diff 2 Files Affected:
diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp
index f31c9265a0074..ed401c894f71c 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@-1 {{use of undeclared identifier 'deprecated'}}
+}
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
70b7c41
to
4c2a772
Compare
Please add a release note. |
4c2a772
to
fbc207f
Compare
Added. |
9760461
to
6e10acb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like the test coverage was dropped in a recent commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Next time please add more details in the summary, this is key for reviewers so that they can digest the PR without leaving for more context. Even in very simple PRs it is good to do.
For this one something along the lines of Parser::ParseUsingDeclaration was not that the result of ParseAliasDeclarationAfterDeclarator was not a nullptr. The fix is to check the result and return nullptr
Thank you for your kind suggestions. |
[[deprecated]]
insideconstexpr
function #144264