Skip to content

Commit

Permalink
Cxx: accept type modifiers preceding decltype keyword
Browse files Browse the repository at this point in the history
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
  • Loading branch information
masatake committed Jan 7, 2023
1 parent 884459d commit 1263b62
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions Units/parser-cxx.r/more-decltypes.d/args.ctags
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
--sort=no
--fields-C++={properties}
4 changes: 4 additions & 0 deletions Units/parser-cxx.r/more-decltypes.d/expected.tags
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@ e input.cxx /^decltype(a) const e = 1;$/;" v typeref:typename:decltype(a) const
f input.cxx /^typeof(a) const f = 2;$/;" v typeref:typename:typeof(a) const
g input.cxx /^__typeof__(a) const g = 3;$/;" v typeref:typename:__typeof__(a) const
g0 input.cxx /^__typeof(a) const g0 = 3;$/;" v typeref:typename:__typeof(a) const
h input.cxx /^static decltype(a) const h = 4;$/;" v typeref:typename:decltype(a) const file: properties:static
i input.cxx /^static typeof(a) const i = 5;$/;" v typeref:typename:typeof(a) const file: properties:static
j input.cxx /^static __typeof__(a) const j = 6;$/;" v typeref:typename:__typeof__(a) const file: properties:static
j0 input.cxx /^static __typeof(a) const j0 = 6;$/;" v typeref:typename:__typeof(a) const file: properties:static
4 changes: 4 additions & 0 deletions Units/parser-cxx.r/more-decltypes.d/input.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,7 @@ typeof(a) const f = 2;
__typeof__(a) const g = 3;
__typeof(a) const g0 = 3;

static decltype(a) const h = 4;
static typeof(a) const i = 5;
static __typeof__(a) const j = 6;
static __typeof(a) const j0 = 6;
7 changes: 6 additions & 1 deletion parsers/cxx/cxx_parser_variable.c
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,12 @@ bool cxxParserExtractVariableDeclarations(CXXTokenChain * pChain,unsigned int uF
// typeof(whatever) variable;
cxxTokenTypeIs(pTokenBefore,CXXTokenTypeParenthesisChain) &&
pTokenBefore->pPrev &&
!pTokenBefore->pPrev->pPrev &&
(!pTokenBefore->pPrev->pPrev ||
(
cxxTokenTypeIs(pTokenBefore->pPrev->pPrev,CXXTokenTypeKeyword) &&
cxxKeywordMayAppearInVariableDeclaration(pTokenBefore->pPrev->pPrev->eKeyword)
)
) &&
(
// macro
cxxTokenTypeIs(pTokenBefore->pPrev,CXXTokenTypeIdentifier) ||
Expand Down

0 comments on commit 1263b62

Please sign in to comment.