Tokenizer::setVarIdNew: in C code, allow that variable declaration starts with delete and throw
This commit is contained in:
parent
ea148173bb
commit
c58d02f146
|
@ -2912,7 +2912,7 @@ void Tokenizer::setVarIdNew()
|
||||||
|
|
||||||
// Variable declaration can't start with "return", etc
|
// Variable declaration can't start with "return", etc
|
||||||
if (tok2->str() == "return" || tok2->str() == "NOT" || tok2->str() == "goto" ||
|
if (tok2->str() == "return" || tok2->str() == "NOT" || tok2->str() == "goto" ||
|
||||||
tok2->str() == "delete" || tok2->str() == "throw")
|
(!isC() && (tok2->str() == "delete" || tok2->str() == "throw")))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const bool decl = setVarIdParseDeclaration(&tok2, variableId, executableScope.top());
|
const bool decl = setVarIdParseDeclaration(&tok2, variableId, executableScope.top());
|
||||||
|
|
|
@ -208,6 +208,7 @@ private:
|
||||||
TEST_CASE(varid42); // ticket #3316 (varid for array)
|
TEST_CASE(varid42); // ticket #3316 (varid for array)
|
||||||
TEST_CASE(varid43);
|
TEST_CASE(varid43);
|
||||||
TEST_CASE(varid44);
|
TEST_CASE(varid44);
|
||||||
|
TEST_CASE(varid_cpp_keywords_in_c_code);
|
||||||
TEST_CASE(varidFunctionCall1);
|
TEST_CASE(varidFunctionCall1);
|
||||||
TEST_CASE(varidFunctionCall2);
|
TEST_CASE(varidFunctionCall2);
|
||||||
TEST_CASE(varidFunctionCall3);
|
TEST_CASE(varidFunctionCall3);
|
||||||
|
@ -3266,6 +3267,21 @@ private:
|
||||||
tokenizeDebugListing(code));
|
tokenizeDebugListing(code));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void varid_cpp_keywords_in_c_code() {
|
||||||
|
const char code[] = "void f() {\n"
|
||||||
|
" delete d;\n"
|
||||||
|
" throw t;\n"
|
||||||
|
"}";
|
||||||
|
|
||||||
|
const char expected[] = "\n\n##file 0\n"
|
||||||
|
"1: void f ( ) {\n"
|
||||||
|
"2: delete d@1 ;\n"
|
||||||
|
"3: throw t@2 ;\n"
|
||||||
|
"4: }\n";
|
||||||
|
|
||||||
|
ASSERT_EQUALS(expected, tokenizeDebugListing(code,false,"test.c"));
|
||||||
|
}
|
||||||
|
|
||||||
void varidFunctionCall1() {
|
void varidFunctionCall1() {
|
||||||
const std::string code("void f() {\n"
|
const std::string code("void f() {\n"
|
||||||
" int x;\n"
|
" int x;\n"
|
||||||
|
|
Loading…
Reference in New Issue