aboutsummaryrefslogtreecommitdiffstats
path: root/tests/inefficient-qlist-soft/main.cpp
blob: da287a594403438a5254a26abcb7cb0228ff51a5 (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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#include <QtCore/QList>










struct SmallType {
    char a[8];
};


struct BigType {
    char a[9];
};


void foo()
{
    QList<BigType> bigT; // Warning
    QList<SmallType> smallT; // OK
}

class A {
public:
    void foo()
    {
        m_big.clear();
    }

    QList<BigType> m_big; // OK
};

void foo1(QList<BigType> big2)
{
    QList<BigType> bigt; // OK
    bigt = big2;
}

QList<BigType> foo2()
{
    QList<BigType> bigt; // OK
    return bigt;
}

static QList<BigType> s_big;
extern void takesBig(QList<BigType>);
void foo3()
{
    QList<BigType> bigt; // OK
    s_big = bigt;
    s_big = QList<BigType>(); // OK

    QList<BigType> bigt2; // OK
    takesBig(bigt2);
}
extern QList<BigType> returnsBig();
void foo4()
{
    QList<BigType> b; // Warning
    for (auto a : b) {}

    QList<BigType> b2 = returnsBig(); // OK
    QList<BigType> b3 = { BigType() }; // Warning
    QList<BigType> b4 = b2; // Ok
}

struct A1
{
    QList<BigType> a();
};

struct B1
{
    A1 b();
};

void foo5()
{
    QList<BigType> b5 = B1().b().a();
}

void test_bug358740()
{
    QList<int> list; // OK
    int a, b;
}