diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 23822eb4e..825c7a73f 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -715,7 +715,25 @@ bool Tokenizer::tokenize(std::istream &code, const char FileName[]) tok->tokAt(2)->link()->next()) { Token::eraseTokens(tok, tok->tokAt(2)->link()->next()); + } + + else if (Token::Match(tok->next(), "__asm__ __volatile__ (") && + tok->tokAt(3)->link() && + tok->tokAt(3)->link()->next()) + { + Token::eraseTokens(tok, tok->tokAt(3)->link()->next()); + } + + else + continue; + + // insert "asm ( )" + tok->insertToken(")"); + tok->insertToken("("); + tok->insertToken("asm"); + + Token::createMutualLinks(tok->tokAt(2), tok->tokAt(3)); } // Remove "volatile" and "mutable" diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index f01c83ca7..de3c4e1e3 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -329,20 +329,10 @@ private: void inlineasm() { - { - const char code[] = "abc asm { mov ax,bx } def"; - ASSERT_EQUALS("abc def", tokenizeAndStringify(code)); - } - - { - const char code[] = "abc _asm { mov ax,bx } def"; - ASSERT_EQUALS("abc def", tokenizeAndStringify(code)); - } - - { - const char code[] = "abc __asm { mov ax,bx } def"; - ASSERT_EQUALS("abc def", tokenizeAndStringify(code)); - } + ASSERT_EQUALS("; asm ( ) ;", tokenizeAndStringify(";asm { mov ax,bx };")); + ASSERT_EQUALS("; asm ( ) ;", tokenizeAndStringify(";_asm { mov ax,bx };")); + ASSERT_EQUALS("; asm ( ) ;", tokenizeAndStringify(";__asm { mov ax,bx };")); + ASSERT_EQUALS("; asm ( ) ;", tokenizeAndStringify(";__asm__ __volatile__ ( \"mov ax,bx\" );")); }