Fixed #7203 (Better syntax error, handle array declaration with @)
This commit is contained in:
parent
c37b807613
commit
04d3672bde
|
@ -441,6 +441,7 @@ unsigned int CppCheck::checkFile(const std::string& filename, const std::string
|
||||||
ErrorLogger::ErrorMessage::FileLocation loc;
|
ErrorLogger::ErrorMessage::FileLocation loc;
|
||||||
if (e.token) {
|
if (e.token) {
|
||||||
loc.line = e.token->linenr();
|
loc.line = e.token->linenr();
|
||||||
|
loc.col = e.token->col();
|
||||||
const std::string fixedpath = Path::toNativeSeparators(mTokenizer.list.file(e.token));
|
const std::string fixedpath = Path::toNativeSeparators(mTokenizer.list.file(e.token));
|
||||||
loc.setfile(fixedpath);
|
loc.setfile(fixedpath);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -3817,11 +3817,12 @@ bool Tokenizer::simplifyTokenList1(const char FileName[])
|
||||||
// When the assembly code has been cleaned up, no @ is allowed
|
// When the assembly code has been cleaned up, no @ is allowed
|
||||||
for (const Token *tok = list.front(); tok; tok = tok->next()) {
|
for (const Token *tok = list.front(); tok; tok = tok->next()) {
|
||||||
if (tok->str() == "(") {
|
if (tok->str() == "(") {
|
||||||
|
const Token *tok1 = tok;
|
||||||
tok = tok->link();
|
tok = tok->link();
|
||||||
if (!tok)
|
if (!tok)
|
||||||
syntaxError(nullptr);
|
syntaxError(tok1);
|
||||||
} else if (tok->str() == "@") {
|
} else if (tok->str() == "@") {
|
||||||
syntaxError(nullptr);
|
syntaxError(tok);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9408,6 +9409,12 @@ void Tokenizer::simplifyAt()
|
||||||
Token::eraseTokens(tok,tok->tokAt(5));
|
Token::eraseTokens(tok,tok->tokAt(5));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// array declaration
|
||||||
|
if (Token::Match(tok, "] @ %num% ;")) {
|
||||||
|
tok->isAtAddress(true);
|
||||||
|
Token::eraseTokens(tok,tok->tokAt(3));
|
||||||
|
}
|
||||||
|
|
||||||
// keywords in compiler from cosmic software for STM8
|
// keywords in compiler from cosmic software for STM8
|
||||||
// TODO: Should use platform configuration.
|
// TODO: Should use platform configuration.
|
||||||
if (Token::Match(tok, "@ builtin|eeprom|far|inline|interrupt|near|noprd|nostack|nosvf|packed|stack|svlreg|tiny|vector")) {
|
if (Token::Match(tok, "@ builtin|eeprom|far|inline|interrupt|near|noprd|nostack|nosvf|packed|stack|svlreg|tiny|vector")) {
|
||||||
|
|
|
@ -1073,6 +1073,8 @@ private:
|
||||||
ASSERT_EQUALS("bool x ;", tokenizeAndStringify("bool x@123:1;"));
|
ASSERT_EQUALS("bool x ;", tokenizeAndStringify("bool x@123:1;"));
|
||||||
ASSERT_EQUALS("char PORTB ; bool PB3 ;", tokenizeAndStringify("char PORTB @ 0x10; bool PB3 @ PORTB:3;\n"));
|
ASSERT_EQUALS("char PORTB ; bool PB3 ;", tokenizeAndStringify("char PORTB @ 0x10; bool PB3 @ PORTB:3;\n"));
|
||||||
|
|
||||||
|
ASSERT_EQUALS("int x [ 10 ] ;", tokenizeAndStringify("int x[10]@0x100;"));
|
||||||
|
|
||||||
ASSERT_EQUALS("interrupt@ f ( ) { }", tokenizeAndStringify("@interrupt f() {}"));
|
ASSERT_EQUALS("interrupt@ f ( ) { }", tokenizeAndStringify("@interrupt f() {}"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue