Fixed #8976 (Crash on `using mystring = std::string;`) (#1663)

* Fixed #8976 (Crash on `using mystring = std::string;`)

* templateSimplifier: move test case to correct file.
This commit is contained in:
IOBYTE 2019-02-12 03:39:01 -05:00 committed by Daniel Marjamäki
parent 03c9477028
commit 9dc5dbe1ab
2 changed files with 10 additions and 1 deletions

View File

@ -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();
}
}
}

View File

@ -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)