Commit Graph

11332 Commits

Author SHA1 Message Date
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
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
versat e712df7cb4 Run astyle [ci skip] 2019-12-04 13:53:10 +01: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
Paul Fultz II 36977becba Fix issue 9196: Lambda confuses check (#2415) 2019-12-03 18:30:52 +01:00
amai2012 0e8a145d6c Run astyle 2019-12-02 22:04:22 +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 2bdb7dc236 Fix issue 9390: valueFlowTerminatingCondition bailout: Skipping function due to incomplete variable NULL (#2412)
* Fix issue 9390: valueFlowTerminatingCondition bailout: Skipping function due to incomplete variable NULL

* Uncomment keyword

* Add nullptr as well
2019-12-01 15:09:21 +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
Daniel Marjamäki 937c82efbe AST: initializer list with lambda 2019-11-27 06:44:58 +01: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 b3ed9f8231 Make iterator checks useful 2019-11-21 18:15:26 +03:00
IOBYTE df952926f8 fix syntax error for a.operator++() ? a.operator--() : 0 (#2382) 2019-11-20 22:13:32 +01:00
Dmitry-Me 28ef31c981 Fix "one past end" illegal iterator computation 2019-11-20 18:10:05 +03:00
Sebastian c990d10ffa
Check for JSON error when parsing addon .json files + fixes (#2374)
* cppcheck.cpp: Check for JSON error when parsing addon .json files

This fixes that errors in JSON files given via `--addon=*.json` are
silently ignored and maybe only a part of the JSON file is used.
Now the error message which picojson can return is checked and a
corresponding error message is returned again by getAddonInfo().

* naming.json: Fix missing comma

* CLI: Fix naming violations detected by addon naming.py via naming.json

* Addon naming: Add argument for validating names of constants

* LIB: Rename functions/variables so they are valid, loosen naming rules

* GUI: Fix naming violations
2019-11-20 15:37:09 +01:00
IOBYTE 590aeea8f8 Fix #9483 (Assertion `tok && tok->str() == ">"' failed) (#2381) 2019-11-20 07:02:25 +01: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
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 1d441f64c1 CheckUnusedVar: Quick heuristic so we don't bailout for 'auto' variables 2019-11-17 15:44:57 +01:00
Daniel Marjamäki d0daf1f90d CheckUnusedVar: Assume that assignment has 'standard behavior' by default 2019-11-17 12:33:26 +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
Daniel Marjamäki 7f57c980f0 Refactoring; shorter code 2019-11-16 11:20:26 +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
Daniel Marjamäki b9835fd4f9 Fixed #9445 (Syntax error on typeof word in C) 2019-11-15 21:20:57 +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
IOBYTE 2eb575d990 Fix #9468 (Syntax error on valid C++) (#2358) 2019-11-14 09:26:21 +01:00
IOBYTE f88ae21d8f Fix #9467 (False positive on local variable when template specialization is used) (#2357) 2019-11-13 21:34:27 +01:00
Paul Fultz II 7841430793 Fix issue 9428: FP uninitvar for pointer passed to sscanf (#2344)
* Add indirect to library cfg files

* Check indirect for non null arguments

* Reenable subfunction analysis

* Use indirect 1 when using not-null

* Parse correct string name

* Update documentation

* Make attribute optional
2019-11-13 12:46:54 +01:00
Daniel Marjamäki 49d6bfbd7b Fixed crash in harfbuzz found by daca@home 2019-11-12 18:22:11 +01:00
Daniel Marjamäki f5a6aa530d Fixed #9417 (FP uninitvar - member initialized in operator()) 2019-11-11 15:00:53 +01:00
Rikard Falkeborn 38dea4719b Fix #9166 (print proper types in invalidCast message) (#2347)
* Fix #9166 (print proper types in invalidCast message)

* Use ValueType->str()

* astyle

* Set default sign to avoid issues on different platforms
2019-11-11 07:17:50 +01:00
Daniel Marjamäki eaa5bfcadd Remove 'unsafeClassDivZero' warning. The software verification will cover this better. 2019-11-10 16:49:34 +01:00