Skip to content

Commit

Permalink
Merge pull request #1817 from pragmaware/fix-1813-and-cleanup
Browse files Browse the repository at this point in the history
CXX: Fix bug 1813
  • Loading branch information
pragmaware authored Aug 11, 2018
2 parents f428ed1 + eb73acb commit 7a6202b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
16 changes: 10 additions & 6 deletions parsers/cxx/cxx_parser_block.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,6 @@ bool cxxParserParseBlockHandleOpeningBracket(void)
return bRet;
}

int iScopes;
// FIXME: Why the invalid cork queue entry index is CORK_NIL?
int iCorkQueueIndex = CORK_NIL;

// In C++ mode check for lambdas
CXXToken * pParenthesis;

Expand All @@ -140,11 +136,15 @@ bool cxxParserParseBlockHandleOpeningBracket(void)
return true;
}

int iScopes;
int iCorkQueueIndex = CORK_NIL;

CXXFunctionSignatureInfo oInfo;

if(eScopeType != CXXScopeTypeFunction)
{
// very likely a function definition
// (but may be also a toplevel block, like "extern "C" { ... }")
iScopes = cxxParserExtractFunctionSignatureBeforeOpeningBracket(&oInfo,&iCorkQueueIndex);

// FIXME: Handle syntax (5) of list initialization:
Expand All @@ -156,8 +156,6 @@ bool cxxParserParseBlockHandleOpeningBracket(void)
// (note that {}-style initializers have been handled above and thus are excluded)

iScopes = 0;

oInfo.uFlags = 0;
}

cxxParserNewStatement();
Expand All @@ -168,6 +166,12 @@ bool cxxParserParseBlockHandleOpeningBracket(void)
return false;
}

if(iScopes < 1)
{
CXX_DEBUG_LEAVE_TEXT("The block was not a function");
return true;
}

unsigned long uEndPosition = getInputLineNumber();

// If the function contained a "try" keyword before the opening bracket
Expand Down
6 changes: 4 additions & 2 deletions parsers/cxx/cxx_parser_function.c
Original file line number Diff line number Diff line change
Expand Up @@ -1422,7 +1422,7 @@ int cxxParserEmitFunctionTags(
CXX_DEBUG_PRINT("Identifier is '%s'",vStringValue(pIdentifier->pszWord));

tagEntryInfo * tag;

if(
(uTagKind == CXXTagKindFUNCTION) &&
(g_cxx.uKeywordState & CXXParserKeywordStateSeenFriend) &&
Expand All @@ -1437,7 +1437,7 @@ int cxxParserEmitFunctionTags(
// {
// inline friend void y(){ ... }
// }
//
//
// Here y() is implicitly defined as a function in the namespace contaning X
// (so it is NOT X::y()).

Expand Down Expand Up @@ -1639,6 +1639,8 @@ int cxxParserEmitFunctionTags(
// and push all the necessary scopes for the next block. It returns the number
// of scopes pushed.
//
// When the returned number of scopes is 0 then no function has been found.
//
int cxxParserExtractFunctionSignatureBeforeOpeningBracket(
CXXFunctionSignatureInfo * pInfo,
int * piCorkQueueIndex
Expand Down

0 comments on commit 7a6202b

Please sign in to comment.