diff options
author | Furkan Usta <furkanusta17@gmail.com> | 2022-08-17 09:44:17 +0200 |
---|---|---|
committer | Kadir Cetinkaya <kadircet@google.com> | 2022-08-17 10:06:39 +0200 |
commit | 4dd71b3cb9473e960d06f5c4c60f0817bd5b9cf6 (patch) | |
tree | c77a2b6745175313cb06004b641e0486c2ea82b0 /clang/lib/Parse/ParseDecl.cpp | |
parent | 88d3c1db453189c3c76b5b83e4d47b2c7f4adf1f (diff) | |
download | llvm-4dd71b3cb9473e960d06f5c4c60f0817bd5b9cf6.zip llvm-4dd71b3cb9473e960d06f5c4c60f0817bd5b9cf6.tar.gz llvm-4dd71b3cb9473e960d06f5c4c60f0817bd5b9cf6.tar.bz2 |
[clang] Give priority to Class context while parsing declarations
Fixes https://github.com/clangd/clangd/issues/290.
Reviewed By: kadircet
Differential Revision: https://reviews.llvm.org/D130363
Diffstat (limited to 'clang/lib/Parse/ParseDecl.cpp')
-rw-r--r-- | clang/lib/Parse/ParseDecl.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp index 39ba93e..769809c 100644 --- a/clang/lib/Parse/ParseDecl.cpp +++ b/clang/lib/Parse/ParseDecl.cpp @@ -3266,13 +3266,14 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS, return; } - if (getCurScope()->getFnParent() || getCurScope()->getBlockParent()) - CCC = Sema::PCC_LocalDeclarationSpecifiers; - else if (TemplateInfo.Kind != ParsedTemplateInfo::NonTemplate) + // Class context can appear inside a function/block, so prioritise that. + if (TemplateInfo.Kind != ParsedTemplateInfo::NonTemplate) CCC = DSContext == DeclSpecContext::DSC_class ? Sema::PCC_MemberTemplate : Sema::PCC_Template; else if (DSContext == DeclSpecContext::DSC_class) CCC = Sema::PCC_Class; + else if (getCurScope()->getFnParent() || getCurScope()->getBlockParent()) + CCC = Sema::PCC_LocalDeclarationSpecifiers; else if (CurParsedObjCImpl) CCC = Sema::PCC_ObjCImplementation; |