fix daca crash in intel-compute-runtime (#3132)

This commit is contained in:
IOBYTE 2021-02-15 02:12:29 -05:00 committed by GitHub
parent e219596797
commit 7ab84bef0c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View File

@ -2308,7 +2308,7 @@ bool Tokenizer::simplifyUsing()
const ScopeInfo3 * memberFuncScope = nullptr;
const Token * memberFuncEnd = nullptr;
bool skip = false; // don't erase type aliases we can't parse
for (Token* tok1 = startToken; tok1 != endToken; tok1 = tok1->next()) {
for (Token* tok1 = startToken; tok1 && tok1 != endToken; tok1 = tok1->next()) {
if ((Token::Match(tok1, "{|}|namespace|class|struct|union") && tok1->strAt(-1) != "using") ||
Token::Match(tok1, "using namespace %name% ;|::")) {
setScopeInfo(tok1, &currentScope1);

View File

@ -64,6 +64,7 @@ private:
TEST_CASE(simplifyUsing15);
TEST_CASE(simplifyUsing16);
TEST_CASE(simplifyUsing17);
TEST_CASE(simplifyUsing18);
TEST_CASE(simplifyUsing8970);
TEST_CASE(simplifyUsing8971);
@ -457,6 +458,11 @@ private:
ASSERT_EQUALS(expected, tok(code, false));
}
void simplifyUsing18() {
const char code[] = "{ { { using a = a; using a; } } }";
tok(code, false); // don't crash
}
void simplifyUsing8970() {
const char code[] = "using V = std::vector<int>;\n"
"struct A {\n"