[PATCH] D158804: [Clang] Fix crash in Parser::ParseDirectDeclarator by adding check that token is not an annotation token
Shafik Yaghmour via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Sep 12 11:20:14 PDT 2023
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6eadc8f16e03: [Clang] Fix crash in Parser::ParseDirectDeclarator by adding check that token… (authored by shafik).
Herald added a project: clang.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D158804/new/
https://reviews.llvm.org/D158804
Files:
clang/docs/ReleaseNotes.rst
clang/lib/Parse/ParseDecl.cpp
clang/test/Parser/gh64836.cpp
Index: clang/test/Parser/gh64836.cpp
===================================================================
--- /dev/null
+++ clang/test/Parser/gh64836.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -xobjective-c++-header %s
+
+template <typename, typename>
+class C {};
+
+class B {
+ p // expected-error {{unknown type name 'p'}}
+ private: // expected-error {{'private' is a keyword in Objective-C++}}
+ void f() {} // expected-error {{expected '(' for function-style cast or type construction}}
+ C<int, decltype(f)> c; // expected-error {{use of undeclared identifier 'f'}}
+ // expected-error at -1 {{expected member name}}
+};
Index: clang/lib/Parse/ParseDecl.cpp
===================================================================
--- clang/lib/Parse/ParseDecl.cpp
+++ clang/lib/Parse/ParseDecl.cpp
@@ -6667,7 +6667,7 @@
// Objective-C++: Detect C++ keywords and try to prevent further errors by
// treating these keyword as valid member names.
if (getLangOpts().ObjC && getLangOpts().CPlusPlus &&
- Tok.getIdentifierInfo() &&
+ !Tok.isAnnotation() && Tok.getIdentifierInfo() &&
Tok.getIdentifierInfo()->isCPlusPlusKeyword(getLangOpts())) {
Diag(getMissingDeclaratorIdLoc(D, Tok.getLocation()),
diag::err_expected_member_name_or_semi_objcxx_keyword)
Index: clang/docs/ReleaseNotes.rst
===================================================================
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -218,6 +218,8 @@
(`#65156 <https://github.com/llvm/llvm-project/issues/65156>`_)
- Clang no longer considers the loss of ``__unaligned`` qualifier from objects as
an invalid conversion during method function overload resolution.
+- Fix parser crash when dealing with ill-formed objective C++ header code. Fixes
+ (`#64836 <https://github.com/llvm/llvm-project/issues/64836>`_)
Bug Fixes to Compiler Builtins
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D158804.556597.patch
Type: text/x-patch
Size: 1966 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230912/f6afb851/attachment.bin>
More information about the cfe-commits
mailing list