From 8b1ffefd748f9604e60023a65c135a490d38227f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=E4ki?= Date: Fri, 14 May 2010 18:40:15 +0200 Subject: [PATCH] Fixed #1682 (Internal error) --- lib/tokenize.cpp | 3 +++ test/testsimplifytokens.cpp | 12 ++++++++++++ 2 files changed, 15 insertions(+) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 3fe35182f..536ad084e 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -2900,6 +2900,9 @@ void Tokenizer::simplifySizeof() if (tok->str() != "sizeof") continue; + if (Token::simpleMatch(tok->next(), "sizeof")) + continue; + // sizeof "text" if (Token::Match(tok->next(), "%str%")) { diff --git a/test/testsimplifytokens.cpp b/test/testsimplifytokens.cpp index b26a7ab9f..235125a92 100644 --- a/test/testsimplifytokens.cpp +++ b/test/testsimplifytokens.cpp @@ -73,6 +73,7 @@ private: TEST_CASE(sizeof16); TEST_CASE(sizeof17); TEST_CASE(sizeof18); + TEST_CASE(sizeofsizeof); TEST_CASE(casting); TEST_CASE(strlen1); @@ -1251,6 +1252,17 @@ private: } } + void sizeofsizeof() + { + // ticket #1682 + const char code[] = "void f()\n" + "{\n" + " sizeof sizeof 1;\n" + "}\n"; + ASSERT_EQUALS("void f ( ) { sizeof sizeof ( 1 ) ; }", tok(code)); + ASSERT_EQUALS("", errout.str()); + } + void casting() { {