Fixed #3760: Added explicit to C++ keyword list in setVarId
Made some constant arrays static
This commit is contained in:
parent
e8cd119ebd
commit
0157f937bf
|
@ -2621,7 +2621,7 @@ void Tokenizer::setVarId()
|
||||||
notstart.insert("return");
|
notstart.insert("return");
|
||||||
notstart.insert("sizeof");
|
notstart.insert("sizeof");
|
||||||
if (!isC()) {
|
if (!isC()) {
|
||||||
const char *str[] = {"delete","friend","new","throw","using","virtual"};
|
static const char *str[] = {"delete","friend","new","throw","using","virtual","explicit"};
|
||||||
notstart.insert(str, str+(sizeof(str)/sizeof(*str)));
|
notstart.insert(str, str+(sizeof(str)/sizeof(*str)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6101,7 +6101,7 @@ bool Tokenizer::simplifyKnownVariablesSimplify(Token **tok2, Token *tok3, unsign
|
||||||
|
|
||||||
// Variable is used in function call..
|
// Variable is used in function call..
|
||||||
if (Token::Match(tok3, ("%var% ( " + structname + " %varid% ,").c_str(), varid)) {
|
if (Token::Match(tok3, ("%var% ( " + structname + " %varid% ,").c_str(), varid)) {
|
||||||
const char * const functionName[] = {
|
static const char * const functionName[] = {
|
||||||
"memcmp","memcpy","memmove","memset",
|
"memcmp","memcpy","memmove","memset",
|
||||||
"strcmp","strcpy","strncmp","strncpy","strdup"
|
"strcmp","strcpy","strncmp","strncpy","strdup"
|
||||||
};
|
};
|
||||||
|
@ -6121,7 +6121,7 @@ bool Tokenizer::simplifyKnownVariablesSimplify(Token **tok2, Token *tok3, unsign
|
||||||
|
|
||||||
// Variable is used as 2nd parameter in function call..
|
// Variable is used as 2nd parameter in function call..
|
||||||
if (Token::Match(tok3, ("%var% ( %any% , " + structname + " %varid% ,|)").c_str(), varid)) {
|
if (Token::Match(tok3, ("%var% ( %any% , " + structname + " %varid% ,|)").c_str(), varid)) {
|
||||||
const char * const functionName[] = {
|
static const char * const functionName[] = {
|
||||||
"memcmp","memcpy","memmove",
|
"memcmp","memcpy","memmove",
|
||||||
"strcmp","strcpy","strncmp","strncpy"
|
"strcmp","strcpy","strncmp","strncpy"
|
||||||
};
|
};
|
||||||
|
|
|
@ -215,6 +215,7 @@ private:
|
||||||
TEST_CASE(varid47); // function parameters
|
TEST_CASE(varid47); // function parameters
|
||||||
TEST_CASE(varid48); // #3785 - return (a*b)
|
TEST_CASE(varid48); // #3785 - return (a*b)
|
||||||
TEST_CASE(varid49); // #3799 - void f(std::vector<int>)
|
TEST_CASE(varid49); // #3799 - void f(std::vector<int>)
|
||||||
|
TEST_CASE(varid50); // #3760 - explicit
|
||||||
TEST_CASE(varid_cpp_keywords_in_c_code);
|
TEST_CASE(varid_cpp_keywords_in_c_code);
|
||||||
TEST_CASE(varidFunctionCall1);
|
TEST_CASE(varidFunctionCall1);
|
||||||
TEST_CASE(varidFunctionCall2);
|
TEST_CASE(varidFunctionCall2);
|
||||||
|
@ -3259,6 +3260,13 @@ private:
|
||||||
tokenizeDebugListing(code, false, "test.cpp"));
|
tokenizeDebugListing(code, false, "test.cpp"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void varid50() { // #3760 - explicit
|
||||||
|
const std::string code("class A { explicit A(const A&); };");
|
||||||
|
ASSERT_EQUALS("\n\n##file 0\n"
|
||||||
|
"1: class A { explicit A ( const A & ) ; } ;\n",
|
||||||
|
tokenizeDebugListing(code, false, "test.cpp"));
|
||||||
|
}
|
||||||
|
|
||||||
void varid_cpp_keywords_in_c_code() {
|
void varid_cpp_keywords_in_c_code() {
|
||||||
const char code[] = "void f() {\n"
|
const char code[] = "void f() {\n"
|
||||||
" delete d;\n"
|
" delete d;\n"
|
||||||
|
|
Loading…
Reference in New Issue