#8913 SIGSEGV in CheckUnusedVar::checkFunctionVariableUsage - C++/CLI code

This commit is contained in:
amai2012 2019-04-19 13:55:25 +02:00
parent ae3e53f391
commit 28bc3cad92
2 changed files with 12 additions and 1 deletions

View File

@ -9140,7 +9140,7 @@ void Tokenizer::findGarbageCode() const
if (Token::Match(tok, "> %cop%"))
continue;
}
if (Token::Match(tok, "%or%|%oror%|==|!=|+|-|/|!|>=|<=|~|++|--|::|sizeof|throw|decltype|typeof {|if|else|try|catch|while|do|for|return|switch|break|namespace"))
if (Token::Match(tok, "%or%|%oror%|==|!=|+|-|/|!|>=|<=|~|^|++|--|::|sizeof|throw|decltype|typeof {|if|else|try|catch|while|do|for|return|switch|break|namespace"))
syntaxError(tok);
if (Token::Match(tok, "( %any% )") && tok->next()->isKeyword() && !Token::simpleMatch(tok->next(), "void"))
syntaxError(tok);

View File

@ -245,6 +245,7 @@ private:
TEST_CASE(syntaxErrorLastToken); // Make sure syntax errors are detected and reported
TEST_CASE(syntaxErrorCase);
TEST_CASE(syntaxErrorFuzzerCliType1);
TEST_CASE(cliCode);
TEST_CASE(enumTrailingComma);
TEST_CASE(nonGarbageCode1); // #8346
@ -1662,6 +1663,16 @@ private:
ASSERT_THROW(checkCode("void f() { x= y{ } name5 y[ ] + y ^ name5 ^ name5 for ( ( y y y && y y y && name5 ++ int )); }"), InternalError); // #9069
}
void cliCode() {
// #8913
ASSERT_THROW(checkCode("public ref class LibCecSharp : public CecCallbackMethods {\n"
"array<CecAdapter ^> ^ FindAdapters(String ^ path) {} \n"
"bool GetDeviceInformation(String ^ port, LibCECConfiguration ^configuration, uint32_t timeoutMs) {\n"
"bool bReturn(false);\n"
"}\n"
"};\n"), InternalError);
}
void enumTrailingComma() {
ASSERT_THROW(checkCode("enum ssl_shutdown_t {ssl_shutdown_none = 0,ssl_shutdown_close_notify = , } ;"), InternalError); // #8079
}