Commit Graph

9604 Commits

Author SHA1 Message Date
IOBYTE f637d97080 Fix 9509 (Syntax error on empty attribute list) (#2423) 2019-12-06 05:17:19 +01:00
Paul Fultz II 2978c67e6f Fix issue 9511: Syntax Error: AST broken, 'if' doesn't have two operands. (#2428) 2019-12-06 04:19:46 +01:00
IOBYTE 5979eec2c0 Fix 9518 (Syntax error on valid C++) (#2424) 2019-12-05 20:51:36 +01:00
Dmitry-Me 7da68bff7b Improve test coverage for missing destructors 2019-12-05 18:25:50 +03:00
Dmitry-Me 571de5844f Improve test coverage for functions returning bool values 2019-12-04 18:12:10 +03:00
John Marshall 297efcd049 Avoid some additional memleakOnRealloc false positives (#2422)
* Avoid some additional memleakOnRealloc false positives

checkReallocUsage() already contains code to suppress the
`p = realloc(p, size)` error message when the pointer has been
previously copied from another variable (hence there is an additional
copy of the original pointer value) within the same function, as in
the added realloc21() test case.

Extend this so that `p = *pp` and `p = ptr->foo` are also recognized
as copies from another variable with the same original pointer value,
as in the added realloc22() and realloc23() test cases.

* Rewrite as a single findmatch() expression
2019-12-04 12:13:44 +01:00
Dmitry-Me cf7ef2e703 Valid code for incrementing raw pointer (#2418) 2019-12-03 18:33:05 +01:00
Paul Fultz II 36977becba Fix issue 9196: Lambda confuses check (#2415) 2019-12-03 18:30:52 +01:00
Dmitry-Me b14a976c6c Improve test coverage for postfix increment of raw pointers 2019-12-02 18:12:14 +03:00
Paul Fultz II 78b4485670 Regression for issue 8653: valueFlowAfterCondition: compound conditional (#2416) 2019-12-02 11:35:51 +01:00
Paul Fultz II 9cb39b1d7e Fix issue 9482: False positive: Reference to temporary returned using trailing return type (#2413) 2019-12-01 15:10:02 +01:00
Paul Fultz II f77347d7b4 Fix crash 9492: Crash in FwdAnalysis::checkRecursive() (condTok is nullptr) (#2411)
* Fix crash 9492: Crash in FwdAnalysis::checkRecursive() (condTok is nullptr)

* Formatting
2019-12-01 14:53:03 +01:00
Paul Fultz II a71f58ffc2 Fix issue 9441: false positive: new(std::nothrow) and nullPointerRedundantCheck (#2403)
* Fix issue 9441: false positive: new(std::nothrow) and nullPointerRedundantCheck

* Skip new if it is a variable
2019-12-01 12:16:31 +01:00
Paul Fultz II 79a2e61721 Fix issue 6850: Valueflow: pointer alias, conditional value (#2402) 2019-11-30 09:22:03 +01:00
Paul Fultz II f9d33c07f8 Fix issue 9458: Crash with shadow variables in a lambda (#2406)
* Fix issue 9458: Crash with shadow variables in a lambda

* Format
2019-11-29 09:45:02 +01:00
IOBYTE f554a71dea fix #9495 (Crash when parsing angle brackets in template with type traits (assertion failure)) (#2407) 2019-11-29 09:44:27 +01:00
Daniel Marjamäki 676a837af6 Fixed #9335 (FP constStatement "Found a statement that begins with string constant") 2019-11-28 17:49:33 +01:00
Dmitry-Me ff36ebcff2 Improve test coverage for testing AST 2019-11-28 18:11:55 +03:00
Sebastian fd900ab8b2 testnullpointer.cpp: Add test for dereferencing returned NULL pointer (#2401)
This adds a regression test to make sure that directly dereferencing a
returned NULL pointer issues a warning.
This has been asked on Stack Overflow:
https://stackoverflow.com/q/58981369
Cppcheck 1.89 does not warn for such a code, but 1.90 dev does. So it
is a good idea to make sure it is detected in the future too I guess.
2019-11-27 19:41:36 +01:00
Dmitry-Me 8af2ee968e Fix incorrect usage of "unlikely" hint 2019-11-27 18:08:10 +03:00
Dmitry-Me 45e617f50b Fix -Wint-conversion warning 2019-11-27 18:08:10 +03:00
Daniel Marjamäki 937c82efbe AST: initializer list with lambda 2019-11-27 06:44:58 +01:00
Dmitry-Me 8f72a714d1 Fix -Wint-conversion warning 2019-11-26 18:03:47 +03:00
Sebastian c3c3d6770c
Fix #9478: Valueflow: printf does not change value (#2388)
Format-string arguments are now marked to have `in` direction, except
for `scan`-functions (like `scanf`) where these arguments are explicitly
marked to have `out` direction.
2019-11-24 01:40:31 +01:00
Daniel Marjamäki ab2274b8ad AST: lambdas and scopes in expressions 2019-11-23 21:36:36 +01:00
Daniel Marjamäki ebd32cfd73 Syntax error: if (retval==) 2019-11-23 18:50:46 +01:00
IOBYTE fb1d60bfb1 fix syntax error for num.operator std::string()[0] (#2389) 2019-11-23 17:42:24 +01:00
Dmitry-Me 5a48ac0c6e Improve test coverage for invalid use of bool parameters 2019-11-22 18:11:38 +03:00
IOBYTE df952926f8 fix syntax error for a.operator++() ? a.operator--() : 0 (#2382) 2019-11-20 22:13:32 +01:00
Dmitry-Me 98488790a1 Improve test coverage for %jd used with scanf() 2019-11-20 18:10:56 +03:00
IOBYTE 590aeea8f8 Fix #9483 (Assertion `tok && tok->str() == ">"' failed) (#2381) 2019-11-20 07:02:25 +01:00
Rikard Falkeborn f6a2034a4c Add regression tests for fixed crashes (#2379)
The invalid code in Trac tickets #8750, #8753, #8756, #8762, #8764
and #8765 previously crashed cppcheck. Now it throws a syntax error
instead. Add some tests for these tickets.
2019-11-19 21:50:53 +01:00
Armin Müller 130ebe4b85 Typos found by running "codespell" (#2380) 2019-11-19 20:02:24 +01:00
Dmitry-Me cfac54c42a Improve test coverage for %I32d used with scanf() 2019-11-19 18:05:21 +03:00
Paul Fultz II 479fbb85a2 Fix issue 9443: Internal error: Token::astOperand2() cyclic dependency. (#2376)
* Improve nested init lists

* Fix issue 9443: Internal error: Token::astOperand2() cyclic dependency.
2019-11-19 11:38:03 +01:00
Dmitry-Me 55051b777b Remove unneeded string copy 2019-11-19 10:19:13 +03:00
orbitcowboy 2ff18b76ec test std.cfg: Improved tests for strncpy and strrchr . 2019-11-18 13:53:42 +01:00
orbitcowboy d5d2915873 test std.cfg: Improved tests for strncmp and strncat. 2019-11-18 13:43:49 +01:00
Paul Fultz II ed1acc319d Fixx issue 9355: FP constParameter when returning non-const reference to struct member (#2373) 2019-11-18 06:39:50 +01:00
IOBYTE 7f6ebaa6b2 fix syntax error for VTK_LEGACY_BODY(vtkMatrix3x3::operator[], "VTK 7.0"); (#2372) 2019-11-18 06:38:53 +01:00
Daniel Marjamäki f5e3dc9a38 Improved fix for #8978 (False positive: Variable assigned value that is never used when assigning via iterator) 2019-11-17 12:08:21 +01:00
Paul Fultz II 4ebf54d090 Fix issue 9437: Dont assume init list constructor for strings (#2366)
* Fix issue 9437: Dont assume init list constuctor for strings

* Update the schema

* Add documentation
2019-11-17 03:22:04 +01:00
Daniel Marjamäki 5654630099 Fixed #8978 (False positive: Variable assigned value that is never used when assigning via iterator) 2019-11-16 19:49:54 +01:00
Daniel Marjamäki 7cd7aff60a Fixed #9285 (Misleading warning message) 2019-11-16 17:24:54 +01:00
Daniel Marjamäki bae4faa786 Fixed #9422 (FP uninitdata - writing pointer to output stream) 2019-11-16 11:47:57 +01:00
IOBYTE 754c1fff66 fix syntax error for conversion operator for type with global namespace (#2365)
* fix syntax error for conversion operator for type with global namespace

* fix syntax error when taking address of operator function

* fix syntax error for using ::operator "" _a;

* fix syntax error for template<> void operator "" _h<'a', 'b', 'c'>() {}

* fix syntax error for operator in parentheses
2019-11-16 08:03:13 +01:00
IOBYTE 3a617fa04a Fix #9472 (Syntax error on valid C++ code) (#2363)
There are probably a lot more valid code patterns that generates syntax
errors so I added "operator" to the error message to make it easier to
find them.
2019-11-15 07:03:57 +01:00
Daniel Marjamäki 7e0fc4fb00 Tokenizer: Detect more syntax errors when operator does not have operands 2019-11-14 21:18:31 +01:00
orbitcowboy dbbb7f544a test std.cfg: Improved strlen() tests. 2019-11-14 16:45:27 +01:00
orbitcowboy ea92695e54 test std.cfg: Improved sscanf() tests. 2019-11-14 16:38:30 +01:00