Avoid using "do { ... } while ( wxFalse )" pseudo-loop.
This loop can't be optimized away by the compiler because wxFalse is an extern variable which can't be known to be always false. Additionally, this creates many false positives from Coverity as it assumes that the loop can be executed more than once. Define wxSTATEMENT_MACRO_BEGIN/END macros abstracting the exact solution used and replace wxFalse with "(void)0, 0" for now as this seems to placate MSVC (which warns about using a bare "0" as a condition) while still allowing the loop to be completely optimized away. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@73101 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -11,6 +11,8 @@
|
||||
#ifndef _WX_CHECKEDDELETE_H_
|
||||
#define _WX_CHECKEDDELETE_H_
|
||||
|
||||
#include "wx/cpp.h"
|
||||
|
||||
// TODO: provide wxCheckedDelete[Array]() template functions too
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -26,28 +28,17 @@
|
||||
still force a semicolon after the macro
|
||||
*/
|
||||
|
||||
#ifdef __WATCOMC__
|
||||
#define wxFOR_ONCE(name) for(int name=0; name<1; name++)
|
||||
#define wxPRE_NO_WARNING_SCOPE(name) wxFOR_ONCE(wxMAKE_UNIQUE_NAME(name))
|
||||
#define wxPOST_NO_WARNING_SCOPE(name)
|
||||
#else
|
||||
#define wxPRE_NO_WARNING_SCOPE(name) do
|
||||
#define wxPOST_NO_WARNING_SCOPE(name) while ( wxFalse )
|
||||
#endif
|
||||
|
||||
#define wxCHECKED_DELETE(ptr) \
|
||||
wxPRE_NO_WARNING_SCOPE(scope_var1) \
|
||||
{ \
|
||||
wxSTATEMENT_MACRO_BEGIN \
|
||||
typedef char complete[sizeof(*ptr)]; \
|
||||
delete ptr; \
|
||||
} wxPOST_NO_WARNING_SCOPE(scope_var1)
|
||||
wxSTATEMENT_MACRO_END
|
||||
|
||||
#define wxCHECKED_DELETE_ARRAY(ptr) \
|
||||
wxPRE_NO_WARNING_SCOPE(scope_var2) \
|
||||
{ \
|
||||
wxSTATEMENT_MACRO_BEGIN \
|
||||
typedef char complete[sizeof(*ptr)]; \
|
||||
delete [] ptr; \
|
||||
} wxPOST_NO_WARNING_SCOPE(scope_var2)
|
||||
wxSTATEMENT_MACRO_END
|
||||
|
||||
|
||||
#endif // _WX_CHECKEDDELETE_H_
|
||||
|
Reference in New Issue
Block a user