From fab55287f769224239a4cf0fff01d1ed15c04852 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sun, 8 May 2022 16:03:09 +0200 Subject: [PATCH] Tokenizer: improved handling of __asm__ in function declaration --- lib/tokenize.cpp | 5 +++++ test/testtokenize.cpp | 2 ++ 2 files changed, 7 insertions(+) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 7f0d80947..531cbf35d 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -11425,6 +11425,11 @@ void Tokenizer::simplifyAsm() else continue; + if (Token::Match(tok->previous(), ") %name% %name% (")) { + tok->deleteThis(); + continue; + } + // insert "asm ( "instruction" )" tok->str("asm"); if (tok->strAt(1) != ";" && tok->strAt(1) != "{") diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 5ec205cb9..fa0e0cfea 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -994,6 +994,8 @@ private: // 'asm ( ) ;' should be in the same line ASSERT_EQUALS(";\n\nasm ( \"\"mov ax,bx\"\" ) ;", tokenizeAndStringify(";\n\n__asm__ volatile ( \"mov ax,bx\" );")); + + ASSERT_EQUALS("void func1 ( ) ;", tokenizeAndStringify("void func1() __asm__(\"...\") __attribute__();")); } // #4725 - ^{}