(Fixed #7846) Syntax error when using C++11 braced-initializer in function last argument

Add an optional extended description…
This commit is contained in:
umanamente 2017-01-23 16:50:36 +05:00 committed by PKEuS
parent 2f609c2b9a
commit a012e5b5fb
2 changed files with 14 additions and 1 deletions

View File

@ -149,7 +149,7 @@ void TemplateSimplifier::checkComplicatedSyntaxErrorsInTemplates(const Token *to
continue;
// skip starting tokens.. ;;; typedef typename foo::bar::..
while (Token::Match(tok, "[;{}]"))
while (Token::simpleMatch(tok, ";"))
tok = tok->next();
while (Token::Match(tok, "typedef|typename"))
tok = tok->next();

View File

@ -195,6 +195,7 @@ private:
TEST_CASE(funcArgNamesDifferent);
TEST_CASE(funcArgOrderDifferent);
TEST_CASE(cpp11FunctionArgInit); // #7846 - "void foo(int declaration = {}) {"
}
void check(const char code[], const char *filename = nullptr, bool experimental = false, bool inconclusive = true, bool runSimpleChecks=true, Settings* settings = 0) {
@ -6406,6 +6407,18 @@ private:
"[test.cpp:10] -> [test.cpp:15]: (warning) Function 'func3' argument order different: declaration 'a, b, c' definition 'c, b, a'\n"
"[test.cpp:11] -> [test.cpp:16]: (warning) Function 'func4' argument order different: declaration ', b, c' definition 'c, b, a'\n", errout.str());
}
// #7846 - Syntax error when using C++11 braced-initializer in default argument
void cpp11FunctionArgInit() {
// syntax error is not expected
ASSERT_NO_THROW(check(
"\n void foo(int declaration = {}) {"
"\n for (int i = 0; i < 10; i++) {}"
"\n }"
"\n "
));
ASSERT_EQUALS("", errout.str());
}
};
REGISTER_TEST(TestOther)