From f25b8cf66256ac2ccf9104381313c08356e9af5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sat, 7 May 2022 19:40:03 +0200 Subject: [PATCH] Tokenizer: handle when __asm__ directive is provided for function --- 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..ca2992fec 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -11425,6 +11425,11 @@ void Tokenizer::simplifyAsm() else continue; + if (Token::simpleMatch(tok->previous(), ")")) { + 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..1c191b32f 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__(\"...\");")); } // #4725 - ^{}