From 590f1f1d660d0c2e42afb095e47d06827c70fd6e Mon Sep 17 00:00:00 2001 From: PKEuS Date: Mon, 28 Sep 2015 15:42:00 +0200 Subject: [PATCH] Fixed handling of __asm...__endasm (#6970) --- lib/tokenize.cpp | 2 +- test/testtokenize.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 5d660b291..7d5ce246d 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -9216,7 +9216,7 @@ void Tokenizer::simplifyAsm() else if (Token::Match(tok, "_asm|__asm")) { const Token *tok2 = tok; - while (tok2 && tok2->linenr() == tok->linenr() && (tok2->isNumber() || tok2->isName() || tok2->str() == ",")) + while (tok2 && (tok2->isNumber() || tok2->isName() || tok2->str() == "," || tok2->str() == ":")) tok2 = tok2->next(); if (!tok2 || tok2->str() == ";" || tok2->linenr() != tok->linenr()) { instruction = tok->next()->stringifyList(tok2); diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index a153186e6..ac62e65e8 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -1036,6 +1036,7 @@ private: ASSERT_EQUALS("asm ( \"\"ddd\"\" ) ;", tokenizeAndStringify(" __asm __volatile (\"ddd\") ;")); ASSERT_EQUALS("asm ( \"\"mov ax,bx\"\" ) ;", tokenizeAndStringify("__asm__ volatile ( \"mov ax,bx\" );")); ASSERT_EQUALS("asm ( \"mov ax , bx\" ) ; int a ;", tokenizeAndStringify("asm { mov ax,bx } int a;")); + ASSERT_EQUALS("asm\n\n( \"mov ax , bx __endasm\" ) ;", tokenizeAndStringify("__asm\nmov ax,bx\n__endasm;")); // 'asm ( ) ;' should be in the same line ASSERT_EQUALS(";\n\nasm ( \"\"mov ax,bx\"\" ) ;", tokenizeAndStringify(";\n\n__asm__ volatile ( \"mov ax,bx\" );", true));