diff --git a/src/tokenize_cleanup.cpp b/src/tokenize_cleanup.cpp index 37ca0cf67a..386629c945 100644 --- a/src/tokenize_cleanup.cpp +++ b/src/tokenize_cleanup.cpp @@ -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 @@ -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; diff --git a/tests/output/cpp/30108-templates3.cpp b/tests/output/cpp/30108-templates3.cpp index 75ca08df05..df82000391 100644 --- a/tests/output/cpp/30108-templates3.cpp +++ b/tests/output/cpp/30108-templates3.cpp @@ -18,6 +18,6 @@ void test(void) return x != 0 && x >= 1 && x < 2 - && y > = 3 + && y >= 3 && y < 4; }