From 9dc5dbe1ab29a8d0db26e710cadfbcc1791516a7 Mon Sep 17 00:00:00 2001 From: IOBYTE Date: Tue, 12 Feb 2019 03:39:01 -0500 Subject: [PATCH] Fixed #8976 (Crash on `using mystring = std::string;`) (#1663) * Fixed #8976 (Crash on `using mystring = std::string;`) * templateSimplifier: move test case to correct file. --- lib/templatesimplifier.cpp | 2 +- test/testsimplifyusing.cpp | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/templatesimplifier.cpp b/lib/templatesimplifier.cpp index 074af7de1..a14599ccb 100644 --- a/lib/templatesimplifier.cpp +++ b/lib/templatesimplifier.cpp @@ -3029,9 +3029,9 @@ bool TemplateSimplifier::simplifyUsing() Token::eraseTokens(usingStart, usingEnd->next()); usingStart->deleteThis(); } else { + // this is the only code being checked so leave ';' Token::eraseTokens(usingStart, usingEnd); usingStart->deleteThis(); - usingEnd->deleteThis(); } } } diff --git a/test/testsimplifyusing.cpp b/test/testsimplifyusing.cpp index 5c40d6705..102d1dcf4 100644 --- a/test/testsimplifyusing.cpp +++ b/test/testsimplifyusing.cpp @@ -61,6 +61,7 @@ private: TEST_CASE(simplifyUsing8970); TEST_CASE(simplifyUsing8971); + TEST_CASE(simplifyUsing8976); } std::string tok(const char code[], bool simplify = true, Settings::PlatformType type = Settings::Native, bool debugwarnings = true) { @@ -452,6 +453,14 @@ private: ASSERT_EQUALS(expected, tok(code, false)); } + void simplifyUsing8976() { + const char code[] = "using mystring = std::string;"; + + const char exp[] = ";"; + + ASSERT_EQUALS(exp, tok(code)); + } + }; REGISTER_TEST(TestSimplifyUsing)