Skip to content

Commit

Permalink
Merge pull request universal-ctags#962 from pragmaware/struct-initial…
Browse files Browse the repository at this point in the history
…ization

Fix bug universal-ctags#945.
  • Loading branch information
pragmaware committed May 27, 2016
2 parents 0887a54 + 926e4df commit a9c6e5b
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 1 deletion.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
Bug 945@github reported by masatake on 21/05/2016.
The code below was treated as a struct declaration instead
of variable declaration.
*/

/* Taken from linux-3.10.0-229.fc21.x86_64/net/dsa/tag_edsa.c */
struct packet_type edsa_packet_type __read_mostly = {
.type = cpu_to_be16(ETH_P_EDSA),
Expand Down
22 changes: 21 additions & 1 deletion parsers/cxx/cxx_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ boolean cxxParserParseClassStructOrUnion(
CXXTokenTypeSmallerThanSign;

if(eTagKind != CXXTagKindCLASS)
uTerminatorTypes |= CXXTokenTypeParenthesisChain;
uTerminatorTypes |= CXXTokenTypeParenthesisChain | CXXTokenTypeAssignment;

boolean bRet;

Expand Down Expand Up @@ -639,6 +639,26 @@ boolean cxxParserParseClassStructOrUnion(
return TRUE;
}

if(cxxTokenTypeIs(g_cxx.pToken,CXXTokenTypeAssignment))
{
if(g_cxx.pTokenChain->iCount > 3)
{
// struct X Y = ...;
cxxParserExtractVariableDeclarations(g_cxx.pTokenChain,0);
}

// Skip the initialization (which almost certainly contains a block)
if(!cxxParserParseUpToOneOf(CXXTokenTypeEOF | CXXTokenTypeSemicolon))
{
CXX_DEBUG_LEAVE_TEXT("Failed to parse up to EOF/semicolon");
return FALSE;
}

cxxParserNewStatement();
CXX_DEBUG_LEAVE();
return TRUE;
}

if(cxxTokenTypeIs(g_cxx.pToken,CXXTokenTypeEOF))
{
// tolerate EOF, just ignore this
Expand Down

0 comments on commit a9c6e5b

Please sign in to comment.