Skip to content

Commit

Permalink
Bail on template detection if we back up into a return and there is a
Browse files Browse the repository at this point in the history
boolean op in the angles.
  • Loading branch information
bengardner committed Nov 24, 2010
1 parent ef6ccba commit cbb8025
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
7 changes: 3 additions & 4 deletions src/tokenize_cleanup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,7 @@ static void check_template(chunk_t *start)
}
else
{
/* We may have something like "a< ... >", which is a template use
/* We may have something like "a< ... >", which is a template where
* '...' may consist of anything except braces {}, a semicolon, and
* unbalanced parens.
* if we are inside an 'if' statement and hit a CT_BOOL, then it isn't a
Expand All @@ -801,12 +801,11 @@ static void check_template(chunk_t *start)
if ((pc->type == CT_SEMICOLON) ||
(pc->type == CT_BRACE_OPEN) ||
(pc->type == CT_BRACE_CLOSE) ||
(pc->type == CT_SQUARE_CLOSE) ||
(pc->type == CT_SEMICOLON))
(pc->type == CT_SQUARE_CLOSE))
{
break;
}
if (pc->type == CT_IF)
if ((pc->type == CT_IF) || (pc->type == CT_RETURN))
{
in_if = true;
break;
Expand Down
2 changes: 1 addition & 1 deletion tests/output/cpp/30108-templates3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ void test(void)
return x != 0
&& x >= 1
&& x < 2
&& y > = 3
&& y >= 3
&& y < 4;
}

0 comments on commit cbb8025

Please sign in to comment.