diff --git a/lib/checkuninitvar.cpp b/lib/checkuninitvar.cpp index 0e019dbd5..af1c963b5 100644 --- a/lib/checkuninitvar.cpp +++ b/lib/checkuninitvar.cpp @@ -596,8 +596,10 @@ private: return tok.tokAt(3); } - else if (Token::simpleMatch(tok.previous(), ">>") || Token::simpleMatch(tok.next(), "=")) + else if (Token::Match(tok.previous(), "<<|>>") || Token::simpleMatch(tok.next(), "=")) { + // TODO: Don't bail out for "<<" and ">>" if these are + // just computations ExecutionPath::bailOutVar(checks, tok.varId()); return &tok; } diff --git a/test/testuninitvar.cpp b/test/testuninitvar.cpp index 27bb47110..6112fa552 100644 --- a/test/testuninitvar.cpp +++ b/test/testuninitvar.cpp @@ -322,6 +322,13 @@ private: "}\n"); ASSERT_EQUALS("", errout.str()); + checkUninitVar("int a(FArchive &arc) {\n" // #3060 (initialization through operator<<) + " int *p;\n" + " arc << p;\n" + " return *p;\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); + checkUninitVar("int a()\n" "{\n" " int ret;\n"