Warning, file /sdk/clazy/tests/assert-with-side-effects/main.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 #include <QtCore/qglobal.h>
0002 #include <QtCore/QVector>
0003 #include <QtCore/QString>
0004 
0005 
0006 
0007 
0008 
0009 
0010 
0011 
0012 struct SomeStruct
0013 {
0014     bool nonConstMember() { return false; }
0015     bool constMember() const { return false; }
0016     bool m;
0017 };
0018 
0019 
0020 bool global_func() { return false; }
0021 
0022 void test()
0023 {
0024     SomeStruct s;
0025     Q_ASSERT(s.nonConstMember()); // Warning, but ok with normal agressiveness
0026     Q_ASSERT(global_func()); // Warning, but ok with normal agressiveness
0027 
0028     int i;
0029     Q_ASSERT(i = 0); // Warning
0030 }
0031 
0032 class MyVector : QVector<int>
0033 {
0034 public:
0035     MyVector()
0036     {
0037         Q_ASSERT(!isEmpty()); // OK
0038 
0039         int a, b;
0040         Q_ASSERT(a <= b); // OK
0041 
0042         SomeStruct *s;
0043         Q_ASSERT(s->m); // OK
0044         Q_ASSERT(s->constMember()); // OK
0045 
0046         QString format;
0047         int i = 0;
0048         Q_ASSERT(format.at(i) == QLatin1Char('\'')); // OK
0049         Q_ASSERT(++i); // Warning
0050     }
0051 };