qt.cfg: Add configuration and tests for macro Q_NULLPTR (#1651)

Qt defines `Q_NULLPTR` with `nullptr` if it is available, otherwise with `NULL`.
Since there seems to be no (sane) way to configure it the same way in the library configuration it is just defined with `NULL`.
This commit is contained in:
Sebastian 2019-02-07 12:27:25 +01:00 committed by GitHub
parent 3b98f08ac2
commit 5fe7aad5e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 3 deletions

View File

@ -1286,6 +1286,7 @@
<define name="Q_ENUMS(X)" value=""/>
<define name="Q_FLAGS(X)" value=""/>
<define name="Q_INTERFACES(X)" value=""/>
<define name="Q_NULLPTR" value="NULL"/>
<define name="Q_OBJECT" value=""/>
<define name="Q_PROPERTY(X)" value=""/>
<define name="Q_Q(Class)" value="Class * const q = q_func()"/>

View File

@ -38,10 +38,14 @@ public:
~MacroTest1();
};
void validCode()
void validCode(int * pIntPtr)
{
if (QFile::exists("test"))
{}
if (QFile::exists("test")) {
}
if (pIntPtr != Q_NULLPTR) {
*pIntPtr = 5;
}
}
void ignoredReturnValue()
@ -52,3 +56,17 @@ void ignoredReturnValue()
// cppcheck-suppress ignoredReturnValue
file1.exists();
}
void nullPointer(int * pIntPtr)
{
int * pNullPtr = Q_NULLPTR;
// cppcheck-suppress nullPointer
*pNullPtr = 1;
if (pIntPtr != Q_NULLPTR) {
*pIntPtr = 2;
} else {
// cppcheck-suppress nullPointerRedundantCheck
*pIntPtr = 3;
}
}