Commit Graph

9625 Commits

Author SHA1 Message Date
Daniel Marjamäki 235ef0a01e Fixed #9420 (False positive - redundantInitialization) 2019-12-18 19:39:23 +01:00
IOBYTE ec4c979cd8 fix daca error: Internal Error: Invalid syntax (#2452)
* fix daca error: Internal Error: Invalid syntax

* fix cppcheck warnings
2019-12-18 11:48:36 +01:00
Paul Fultz II ad352daa08 Fix issue 9535: Syntax Error: AST broken, 'if' doesn't have two operands. (#2450) 2019-12-16 12:17:01 +01:00
Daniel Marjamäki a241be0ecc Fixed #9434 (False positive: Out of bounds access when using const pointer) 2019-12-15 20:10:28 +01:00
Daniel Marjamäki 36f369473e isPointerDeref: Return false for function declarations 2019-12-15 16:36:46 +01:00
Daniel Marjamäki aee9519d21 testsuite: Add x-flow tests 2019-12-15 13:57:27 +01:00
Daniel Marjamäki f614d32d6a Fixed #9519 (Syntax error on valid C++ 'enum {} (a)') 2019-12-15 08:40:04 +01:00
Daniel Marjamäki bcfc5924fa Fixed #9532 (False positive: Out of bounds access in expression 'v[0]' because 'v' is empty.) 2019-12-14 19:04:19 +01:00
Paul Fultz II 06752d75a5 Fix issue 9485: knownConditionTrueFalse false positive with integer constants (#2447)
* Fix issue 9485: knownConditionTrueFalse false positive with integer constants

* Formatting
2019-12-14 09:15:00 +01:00
IOBYTE 0e4efea530 fix #9539 (Syntax error for valid C++14 code) (#2446) 2019-12-12 20:50:20 +01:00
RobkeBaer 370196a14c Fix extern c typedef syntax error (#2438)
* Fix extern c typedef syntax error

* Fix extraWhiteSpaceError

* Move test from testgarbage to testtokenize
2019-12-12 13:51:14 +01:00
Dmitry-Me 064795a705 Remove duplicate test
This partially reverts commit 047418dda1
2019-12-11 19:17:59 +03:00
Sebastian 6f2879a59b
errorlogger.cpp: Handle empty file-name like "*" (unmatchedSuppression) (#2440)
Using "--suppress=unmatchedSuppression" did not suppress the error-id in
all files, one needed to specify "*" as file-name. This commit also
allows empty file-names to suppress "unmatchedSuppression", not only "*"
or the exact file-name.
The manual uses the following example for suppressions specified in a
file:
// suppress all uninitvar errors in all files
uninitvar

This example suggests that no "*" has to be used to get suppression in
all files. I think that the command line parameter should work in the
same way.
2019-12-11 09:07:18 +01:00
Paul Fultz II ad2f71338c Fix issue 9525: Syntax Error: AST broken, 'if' doesn't have two operands inside lambda (#2433)
* Fix issue 9525: Syntax Error: AST broken, 'if' doesn't have two operands inside lambda

* Fix incorrect matchers
2019-12-10 21:21:07 +01:00
Sebastian de4d44ae2f
opencv2.cfg: Add initial OpenCV 2.x API Library Configuration (#2439) 2019-12-10 19:34:30 +01:00
Paul Fultz II 4aa6385a97 Regression test for 9106: False positive duplicateCondition for struct member (#2434) 2019-12-09 06:51:58 +01:00
amai2012 f5df06a143 Run astyle [ci skip] 2019-12-08 11:22:19 +01:00
Paul Fultz II ea2916a3e4 Fix issue 9514: Syntax Error: AST broken, 'for' doesn't have two operands. (#2429)
* Fix issue 9514: Syntax Error: AST broken, 'for' doesn't have two operands.

* Fix typo
2019-12-07 21:16:25 +01:00
Paul Fultz II 56e17fb228 Fix issue 9524: Syntax Error: AST broken, 'if' doesn't have two operands. (#2432) 2019-12-07 21:06:45 +01:00
Dmitry-Me 047418dda1 Improve test coverage for redundant bitwise operations 2019-12-06 19:14:03 +03:00
Sebastian 95e0b0d0f9
Fix #9510: Crash in valueflow.cpp solveExprValues() (division by zero) (#2420)
`break` if divider `intval` is 0 to avoid division by 0 as suggested by @pfultz2
Trac ticket: https://trac.cppcheck.net/ticket/9510
2019-12-06 08:08:40 +01:00
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