diff --git a/test/cfg/runtests.sh b/test/cfg/runtests.sh index 878a90fd1..7a251223a 100755 --- a/test/cfg/runtests.sh +++ b/test/cfg/runtests.sh @@ -45,6 +45,22 @@ ${CPPCHECK} ${CPPCHECK_OPT} --inconclusive --platform=win32W ${DIR}windows.cpp ${CPPCHECK} ${CPPCHECK_OPT} --inconclusive --platform=win64 ${DIR}windows.cpp # wxwidgets.cpp -# Syntax check via g++ is disabled because wx headers are not always present. -#${CXX} ${CXX_OPT} ${DIR}wxwidgets.cpp -${CPPCHECK} ${CPPCHECK_OPT} --inconclusive --library=wxwidgets ${DIR}wxwidgets.cpp +set +e +WXCONFIG=`wx-config --cxxflags` +WXCONFIG_RETURNCODE=$? +set -e +if [ $WXCONFIG_RETURNCODE -ne 0 ]; then + echo "wx-config does not work, skipping syntax check for wxWidgets tests." +else + set +e + echo -e "#include \n#include \n#include \n" | ${CXX} ${CXX_OPT} ${WXCONFIG} -x c++ - + WXCHECK_RETURNCODE=$? + set -e + if [ $WXCHECK_RETURNCODE -ne 0 ]; then + echo "wxWidgets not completely present (with GUI classes) or not working, skipping syntax check with ${CXX}." + else + echo "wxWidgets found, checking syntax with ${CXX} now." + ${CXX} ${CXX_OPT} ${WXCONFIG} -Wno-deprecated-declarations ${DIR}wxwidgets.cpp + fi +fi +${CPPCHECK} ${CPPCHECK_OPT} --inconclusive --library=wxwidgets -f ${DIR}wxwidgets.cpp diff --git a/test/cfg/wxwidgets.cpp b/test/cfg/wxwidgets.cpp index 991c5b433..a95596139 100644 --- a/test/cfg/wxwidgets.cpp +++ b/test/cfg/wxwidgets.cpp @@ -7,7 +7,15 @@ // No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0 // +#include +#include #include +#include +#include +#include +#include +#include +#include void validCode() { @@ -16,20 +24,28 @@ void validCode() wxLogGeneric(wxLOG_Message, "test %d", 0); wxLogMessage("test %s", "str"); - wxSpinCtrl::SetBase(10); - wxSpinCtrl::SetBase(16); - wxString translation1 = _("text"); wxString translation2 = wxGetTranslation("text"); wxString translation3 = wxGetTranslation("string", "domain"); } +#if wxUSE_GUI==1 +void validGuiCode() +{ +#if wxUSE_SPINCTRL==1 + extern wxSpinCtrl spinCtrlInstance; + spinCtrlInstance.SetBase(10); + spinCtrlInstance.SetBase(16); +#endif +} +#endif + void nullPointer() { // cppcheck-suppress nullPointer - wxLogGeneric(wxLOG_Message, NULL); + wxLogGeneric(wxLOG_Message, (char*)NULL); // cppcheck-suppress nullPointer - wxLogMessage(NULL); + wxLogMessage((char*)NULL); } void ignoredReturnValue() @@ -40,10 +56,13 @@ void ignoredReturnValue() void invalidFunctionArg() { +#if wxUSE_SPINCTRL==1 + extern wxSpinCtrl spinCtrlInstance; // cppcheck-suppress invalidFunctionArg - wxSpinCtrl::SetBase(0); + spinCtrlInstance.SetBase(0); // cppcheck-suppress invalidFunctionArg - wxSpinCtrl::SetBase(5); + spinCtrlInstance.SetBase(5); +#endif } void uninitvar() @@ -61,14 +80,20 @@ void uninitvar() void deprecatedFunctions(wxApp &a, const wxString &s, wxArtProvider *artProvider, wxCalendarCtrl &calenderCtrl, wxComboCtrl &comboCtrl) { +#ifdef __WXOSX__ // cppcheck-suppress MacOpenFileCalled a.MacOpenFile(s); +#endif // cppcheck-suppress InsertCalled wxArtProvider::Insert(artProvider); +#if defined(__WXMSW__) || defined(__WXGTK__) + // EnableYearChange() is not available on these GUI systems +#else // cppcheck-suppress EnableYearChangeCalled calenderCtrl.EnableYearChange(false); // cppcheck-suppress EnableYearChangeCalled calenderCtrl.EnableYearChange(/*default=yes*/); +#endif // cppcheck-suppress GetTextIndentCalled // cppcheck-suppress ignoredReturnValue comboCtrl.GetTextIndent();