Fix 11076: Assert failure / crash with loop over init list (#4119)

This commit is contained in:
Paul Fultz II 2022-05-21 01:25:09 -05:00 committed by GitHub
parent a62fb986a5
commit feaef46436
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 0 deletions

View File

@ -2050,6 +2050,9 @@ T* getTokenArgumentFunctionImpl(T* tok, int& argn)
tok = tok->link()->previous();
if (!Token::Match(tok, "%name%|(|{"))
return nullptr;
// Skip labels
if (Token::Match(tok, "%name% :"))
return nullptr;
return tok;
}

View File

@ -6614,6 +6614,14 @@ private:
" }\n"
"}\n";
valueOfTok(code, "age");
code = "void a() {\n"
" struct b {\n"
" int d;\n"
" };\n"
" for (b c : {b{}, {}}) {}\n"
"}\n";
valueOfTok(code, "c");
}
void valueFlowHang() {