From 2503a24727e5eca426f347e30db2a32c71a50108 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Wed, 10 Apr 2024 11:30:15 +0200 Subject: [PATCH 1/4] Update tokenize.cpp --- lib/tokenize.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index c99d75114d5..7c57ab3417f 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -5508,6 +5508,9 @@ bool Tokenizer::simplifyTokenList1(const char FileName[]) removeExtraTemplateKeywords(); simplifySpaceshipOperator(); + + // @.. + simplifyAt(); // Bail out if code is garbage if (mTimerResults) { @@ -5720,9 +5723,6 @@ bool Tokenizer::simplifyTokenList1(const char FileName[]) // Put ^{} statements in asm() simplifyAsm2(); - // @.. - simplifyAt(); - // When the assembly code has been cleaned up, no @ is allowed for (const Token *tok = list.front(); tok; tok = tok->next()) { if (tok->str() == "(") { @@ -9609,9 +9609,9 @@ void Tokenizer::simplifyAt() std::set var; for (Token *tok = list.front(); tok; tok = tok->next()) { - if (Token::Match(tok, "%name%|] @ %num%|%name%|(")) { + if (Token::Match(tok, "%name%|] @ %num%|%name%|%str%|(")) { const Token *end = tok->tokAt(2); - if (end->isNumber()) + if (end->isLiteral()) end = end->next(); else if (end->str() == "(") { int par = 0; @@ -9632,7 +9632,7 @@ void Tokenizer::simplifyAt() if (Token::Match(end, ": %num% ;")) end = end->tokAt(2); - if (end && end->str() == ";") { + if (Token::Match(end, "[;=]")) { if (tok->isName()) var.insert(tok->str()); tok->isAtAddress(true); From 85d940b3078c7f3eef9527cf891c4445d8041d5f Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Wed, 10 Apr 2024 11:31:35 +0200 Subject: [PATCH 2/4] Update testtokenize.cpp --- test/testtokenize.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index c60cc947901..11e21dc4806 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -936,6 +936,8 @@ class TestTokenizer : public TestFixture { ASSERT_EQUALS("int x [ 10 ] ;", tokenizeAndStringify("int x[10]@0x100;")); ASSERT_EQUALS("interrupt@ f ( ) { }", tokenizeAndStringify("@interrupt f() {}")); + + ASSERT_EQUALS("const short MyVariable = 0xF0F0 ;", tokenizeAndStringify("const short MyVariable @ \"MYOWNSECTION\" = 0xF0F0; ")); // #12602 } void inlineasm() { From 3c14cfee9bfa5ecd3f466d0ef1028bde5544b6de Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Wed, 10 Apr 2024 12:08:59 +0200 Subject: [PATCH 3/4] Format --- lib/tokenize.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 7c57ab3417f..a6a9560e06c 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -5508,7 +5508,7 @@ bool Tokenizer::simplifyTokenList1(const char FileName[]) removeExtraTemplateKeywords(); simplifySpaceshipOperator(); - + // @.. simplifyAt(); From a279a835e6462a78acfd28cbbea97ccc9304d79d Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Wed, 10 Apr 2024 12:45:49 +0200 Subject: [PATCH 4/4] Format --- test/testtokenize.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 11e21dc4806..b95c544cc37 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -936,7 +936,7 @@ class TestTokenizer : public TestFixture { ASSERT_EQUALS("int x [ 10 ] ;", tokenizeAndStringify("int x[10]@0x100;")); ASSERT_EQUALS("interrupt@ f ( ) { }", tokenizeAndStringify("@interrupt f() {}")); - + ASSERT_EQUALS("const short MyVariable = 0xF0F0 ;", tokenizeAndStringify("const short MyVariable @ \"MYOWNSECTION\" = 0xF0F0; ")); // #12602 }