From e64ce2e812d7b2291f1c11fb4162b4634c120e07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Wed, 9 Jun 2010 21:28:15 +0200 Subject: [PATCH] Fixed #1781 (false positive: uninitialized variable when using asm statement in macro) --- lib/tokenize.cpp | 7 +++++++ test/testtokenize.cpp | 1 + 2 files changed, 8 insertions(+) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 1492814f2..f7c527292 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -1687,6 +1687,13 @@ bool Tokenizer::tokenize(std::istream &code, const char FileName[], const std::s Token::eraseTokens(tok, tok->tokAt(3)->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 if (Token::simpleMatch(tok->next(), "__asm")) { const Token *tok2 = tok->next(); diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 983205050..25f9e28d0 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -418,6 +418,7 @@ private: ASSERT_EQUALS("; asm ( ) ;", tokenizeAndStringify(";__asm__ __volatile__ ( \"mov ax,bx\" );")); ASSERT_EQUALS("; asm ( ) ;", tokenizeAndStringify(";__asm _emit 12h ;")); ASSERT_EQUALS("; asm ( ) ;", tokenizeAndStringify(";__asm mov a, b ;")); + ASSERT_EQUALS("; asm ( ) ;", tokenizeAndStringify(";asm volatile (\"fnstcw %0\" : \"= m\" (old_cw));")); }