diff options
author | Sergio Martins <sergio.martins@kdab.com> | 2015-08-23 23:29:30 +0100 |
---|---|---|
committer | Sergio Martins <sergio.martins@kdab.com> | 2015-08-23 23:29:30 +0100 |
commit | b049734464641531050b4142c908b5aff6657857 (patch) | |
tree | 78081c66a5706409a7f1d0d1d5334aabbac62d54 /tests/reserve-candidates | |
parent | f61ff43c636755e865ac5b62ac929240d3145d79 (diff) |
reserve-candidates: Less false positives
Don't warn when our statement is inside two foreaches, this is almost
always a false positive
Diffstat (limited to 'tests/reserve-candidates')
-rw-r--r-- | tests/reserve-candidates/main.cpp | 21 | ||||
-rw-r--r-- | tests/reserve-candidates/test.expected | 1 |
2 files changed, 21 insertions, 1 deletions
diff --git a/tests/reserve-candidates/main.cpp b/tests/reserve-candidates/main.cpp index b335ac0a..653c1677 100644 --- a/tests/reserve-candidates/main.cpp +++ b/tests/reserve-candidates/main.cpp @@ -87,6 +87,26 @@ void test_nesting() for (int i = 0; i < 10; ++i) v2 << i; // Warning } + + QVector<int> v3; + // Too many levels, this is ok, unless all of the cond expressions where literals but that's unlikely + for (int i = 0; i < 10; ++i) { + for (int i = 0; i < 10; ++i) { + for (int i = 0; i < 10; ++i) { + for (int i = 0; i < 10; ++i) { + v3 << i; // OK + } + } + } + } + + QVector<int> a,b,c,d,e; + foreach (int i, a) + foreach (int i2, b) + c << 1; // OK + + foreach (int i2, d) + e << 1; // Warning } void test_misc() @@ -95,5 +115,4 @@ void test_misc() for (int i = 0; i < 10; ) { v2 << i; // OK } - } diff --git a/tests/reserve-candidates/test.expected b/tests/reserve-candidates/test.expected index dfee157a..bfc06892 100644 --- a/tests/reserve-candidates/test.expected +++ b/tests/reserve-candidates/test.expected @@ -5,3 +5,4 @@ main.cpp:65:9: warning: Reserve candidate [-Wmore-warnings-reserve-candidates] main.cpp:69:9: warning: Reserve candidate [-Wmore-warnings-reserve-candidates] main.cpp:73:9: warning: Reserve candidate [-Wmore-warnings-reserve-candidates] main.cpp:88:13: warning: Reserve candidate [-Wmore-warnings-reserve-candidates] +main.cpp:109:9: warning: Reserve candidate [-Wmore-warnings-reserve-candidates] |