diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index e79a77844..abbaa5cfe 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -2518,7 +2518,8 @@ void Tokenizer::simplifyDefaultAndDeleteInsideClass() tok2 = tok2->previous(); if (Token::Match(tok2, "[;{}]") || tok2->isName()) Token::eraseTokens(tok2, end); - tok2 = end; + else + tok2 = end->previous(); } } } diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index d8f9c9bdf..1cff27280 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -3054,12 +3054,22 @@ private: } void varid37() { - const std::string code = "void blah() {" - " Bar bar(*x);" - "}"; - ASSERT_EQUALS("\n\n##file 0\n1: " - "void blah ( ) { Bar bar@1 ( * x ) ; }\n", - tokenizeDebugListing(code)); + { + const std::string code = "void blah() {" + " Bar bar(*x);" + "}"; + ASSERT_EQUALS("\n\n##file 0\n1: " + "void blah ( ) { Bar bar@1 ( * x ) ; }\n", + tokenizeDebugListing(code)); + } + { + const std::string code = "void blah() {" + " Bar bar(&x);" + "}"; + ASSERT_EQUALS("\n\n##file 0\n1: " + "void blah ( ) { Bar bar@1 ( & x ) ; }\n", + tokenizeDebugListing(code)); + } } void varid38() { @@ -5171,6 +5181,15 @@ private: TODO_ASSERT_EQUALS("struct foo { }", "struct foo { foo ( ) ; } foo :: foo ( ) = delete ;", tokenizeAndStringify(code)); } + + //ticket #3448 (segmentation fault) + { + const char *code = "struct A {" + " void bar () = delete;" + "};" + "void baz () = delete;"; + ASSERT_EQUALS("struct A { } ; void baz ( ) = delete ;", tokenizeAndStringify(code)); + } } std::string arraySize_(const std::string &code) {