aboutsummaryrefslogtreecommitdiffstats
path: root/tests/container-inside-loop/main.cpp
blob: cfaaa57b64a0bd2070513f360651c82424b34df9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <QtCore/QVector>
#include <QtCore/QString>

struct A { A() {} };

extern void receivesByRef(QVector<int> &);
extern void receivesByRef2(const QString &, QVector<int> &);
extern void receivesByPtr(QVector<int> *);

void test()
{
    QVector<int> v1; // OK
    for (int i = 0; i < 10; i++) {
        A a; // OK
        QVector<int> v2; // Warning
        v2.append(i);
        QVector<int>().append(i); // OK (bogus but that's not what we're after)
    }
}

void test1()
{
    QVector<int> v;
    while (true) {
        QVector<int> v1(v); // OK
    }

    while (true) {
        QVector<int> v1; // OK
        receivesByRef(v1);
    }

    while (true) {
        QVector<int> v1; // OK
        receivesByRef2(QString(), v1);
    }

    while (true) {
        QVector<int> v1; // OK
        receivesByPtr(&v1);
    }
}