Merge branch 'cxx20-warning-fixes'
Build fixes for gcc 11 and clang 12, including in C++ 20 mode. See https://github.com/wxWidgets/wxWidgets/pull/2347
This commit is contained in:
@@ -55,6 +55,7 @@ enum wxAuiNotebookOption
|
|||||||
wxAUI_NB_MIDDLE_CLICK_CLOSE
|
wxAUI_NB_MIDDLE_CLICK_CLOSE
|
||||||
};
|
};
|
||||||
|
|
||||||
|
wxALLOW_COMBINING_ENUMS(wxAuiNotebookOption, wxBorder)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -740,6 +740,17 @@ typedef short int WXTYPE;
|
|||||||
# define wxWARNING_RESTORE_MISSING_OVERRIDE()
|
# define wxWARNING_RESTORE_MISSING_OVERRIDE()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
Macros above don't work with gcc 11 due to a compiler bug, unless we also
|
||||||
|
use "override" in the function declaration -- but this breaks other
|
||||||
|
compilers, so define a specific macro for gcc 11 only.
|
||||||
|
*/
|
||||||
|
#if wxCHECK_GCC_VERSION(11, 0)
|
||||||
|
# define wxDUMMY_OVERRIDE wxOVERRIDE
|
||||||
|
#else
|
||||||
|
# define wxDUMMY_OVERRIDE
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Combination of the two variants above: should be used for deprecated
|
Combination of the two variants above: should be used for deprecated
|
||||||
functions which are defined inline and are used by wxWidgets itself.
|
functions which are defined inline and are used by wxWidgets itself.
|
||||||
@@ -1255,6 +1266,28 @@ typedef double wxDouble;
|
|||||||
/* Geometric flags */
|
/* Geometric flags */
|
||||||
/* ---------------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
/*
|
||||||
|
In C++20 operations on the elements of different enums are deprecated and
|
||||||
|
many compilers (clang 10+, gcc 11+, MSVS 2019) warn about combining them,
|
||||||
|
as a lot of existing code using them does, so we provide explicit operators
|
||||||
|
for doing this, that do the same thing as would happen without them, but
|
||||||
|
without the warnings.
|
||||||
|
*/
|
||||||
|
#if defined(__cplusplus) && (__cplusplus >= 202002L)
|
||||||
|
#define wxALLOW_COMBINING_ENUMS_IMPL(en1, en2) \
|
||||||
|
inline int operator|(en1 v1, en2 v2) \
|
||||||
|
{ return static_cast<int>(v1) | static_cast<int>(v2); } \
|
||||||
|
inline int operator+(en1 v1, en2 v2) \
|
||||||
|
{ return static_cast<int>(v1) + static_cast<int>(v2); }
|
||||||
|
|
||||||
|
#define wxALLOW_COMBINING_ENUMS(en1, en2) \
|
||||||
|
wxALLOW_COMBINING_ENUMS_IMPL(en1, en2) \
|
||||||
|
wxALLOW_COMBINING_ENUMS_IMPL(en2, en1)
|
||||||
|
#else /* !C++ 20 */
|
||||||
|
/* Don't bother doing anything in this case. */
|
||||||
|
#define wxALLOW_COMBINING_ENUMS(en1, en2)
|
||||||
|
#endif /* C++ 20 */
|
||||||
|
|
||||||
enum wxGeometryCentre
|
enum wxGeometryCentre
|
||||||
{
|
{
|
||||||
wxCENTRE = 0x0001,
|
wxCENTRE = 0x0001,
|
||||||
@@ -1380,6 +1413,16 @@ enum wxBorder
|
|||||||
/* This makes it easier to specify a 'normal' border for a control */
|
/* This makes it easier to specify a 'normal' border for a control */
|
||||||
#define wxDEFAULT_CONTROL_BORDER wxBORDER_SUNKEN
|
#define wxDEFAULT_CONTROL_BORDER wxBORDER_SUNKEN
|
||||||
|
|
||||||
|
/*
|
||||||
|
Elements of these enums can be combined with each other when using
|
||||||
|
wxSizer::Add() overload not using wxSizerFlags.
|
||||||
|
*/
|
||||||
|
wxALLOW_COMBINING_ENUMS(wxAlignment, wxDirection)
|
||||||
|
wxALLOW_COMBINING_ENUMS(wxAlignment, wxGeometryCentre)
|
||||||
|
wxALLOW_COMBINING_ENUMS(wxAlignment, wxStretch)
|
||||||
|
wxALLOW_COMBINING_ENUMS(wxDirection, wxStretch)
|
||||||
|
wxALLOW_COMBINING_ENUMS(wxDirection, wxGeometryCentre)
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------------- */
|
||||||
/* Window style flags */
|
/* Window style flags */
|
||||||
/* ---------------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------------- */
|
||||||
|
@@ -4322,8 +4322,8 @@ typedef void (wxEvtHandler::*wxPressAndTapEventFunction)(wxPressAndTapEvent&);
|
|||||||
static const wxEventTableEntry sm_eventTableEntries[]; \
|
static const wxEventTableEntry sm_eventTableEntries[]; \
|
||||||
protected: \
|
protected: \
|
||||||
wxWARNING_SUPPRESS_MISSING_OVERRIDE() \
|
wxWARNING_SUPPRESS_MISSING_OVERRIDE() \
|
||||||
const wxEventTable* GetEventTable() const; \
|
const wxEventTable* GetEventTable() const wxDUMMY_OVERRIDE; \
|
||||||
wxEventHashTable& GetEventHashTable() const; \
|
wxEventHashTable& GetEventHashTable() const wxDUMMY_OVERRIDE; \
|
||||||
wxWARNING_RESTORE_MISSING_OVERRIDE() \
|
wxWARNING_RESTORE_MISSING_OVERRIDE() \
|
||||||
static const wxEventTable sm_eventTable; \
|
static const wxEventTable sm_eventTable; \
|
||||||
static wxEventHashTable sm_eventHashTable
|
static wxEventHashTable sm_eventHashTable
|
||||||
|
@@ -395,8 +395,8 @@ public:
|
|||||||
#endif // wxUSE_PRIVATE_FONTS
|
#endif // wxUSE_PRIVATE_FONTS
|
||||||
|
|
||||||
// comparison
|
// comparison
|
||||||
bool operator==(const wxFont& font) const;
|
bool operator==(const wxFontBase& font) const;
|
||||||
bool operator!=(const wxFont& font) const { return !(*this == font); }
|
bool operator!=(const wxFontBase& font) const { return !(*this == font); }
|
||||||
|
|
||||||
// accessors: get the font characteristics
|
// accessors: get the font characteristics
|
||||||
virtual int GetPointSize() const;
|
virtual int GetPointSize() const;
|
||||||
|
@@ -33,15 +33,18 @@ public:
|
|||||||
wxDataFormat& operator=(NativeFormat format)
|
wxDataFormat& operator=(NativeFormat format)
|
||||||
{ SetId(format); return *this; }
|
{ SetId(format); return *this; }
|
||||||
|
|
||||||
// comparison (must have both versions)
|
// comparison (note that we rely on implicit conversions for comparison
|
||||||
|
// with wxDataFormatId, but have to provide them explicitly for comparison
|
||||||
|
// with NativeFormat to avoid ambiguity between comparing from it to
|
||||||
|
// wxDataFormat or vice versa)
|
||||||
bool operator==(NativeFormat format) const
|
bool operator==(NativeFormat format) const
|
||||||
{ return m_format == (NativeFormat)format; }
|
{ return m_format == (NativeFormat)format; }
|
||||||
bool operator!=(NativeFormat format) const
|
bool operator!=(NativeFormat format) const
|
||||||
{ return m_format != (NativeFormat)format; }
|
{ return m_format != (NativeFormat)format; }
|
||||||
bool operator==(wxDataFormatId format) const
|
bool operator==(const wxDataFormat& other) const
|
||||||
{ return m_type == (wxDataFormatId)format; }
|
{ return m_format == other.m_format; }
|
||||||
bool operator!=(wxDataFormatId format) const
|
bool operator!=(const wxDataFormat& other) const
|
||||||
{ return m_type != (wxDataFormatId)format; }
|
{ return m_format != other.m_format; }
|
||||||
|
|
||||||
// explicit and implicit conversions to NativeFormat which is one of
|
// explicit and implicit conversions to NativeFormat which is one of
|
||||||
// standard data types (implicit conversion is useful for preserving the
|
// standard data types (implicit conversion is useful for preserving the
|
||||||
|
@@ -368,8 +368,6 @@ private:
|
|||||||
|
|
||||||
class WXDLLIMPEXP_BASE wxObject
|
class WXDLLIMPEXP_BASE wxObject
|
||||||
{
|
{
|
||||||
wxDECLARE_ABSTRACT_CLASS(wxObject);
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
wxObject() { m_refData = NULL; }
|
wxObject() { m_refData = NULL; }
|
||||||
virtual ~wxObject() { UnRef(); }
|
virtual ~wxObject() { UnRef(); }
|
||||||
@@ -392,6 +390,7 @@ public:
|
|||||||
|
|
||||||
bool IsKindOf(const wxClassInfo *info) const;
|
bool IsKindOf(const wxClassInfo *info) const;
|
||||||
|
|
||||||
|
virtual wxClassInfo *GetClassInfo() const;
|
||||||
|
|
||||||
// Turn on the correct set of new and delete operators
|
// Turn on the correct set of new and delete operators
|
||||||
|
|
||||||
@@ -453,6 +452,8 @@ protected:
|
|||||||
virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const;
|
virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const;
|
||||||
|
|
||||||
wxObjectRefData *m_refData;
|
wxObjectRefData *m_refData;
|
||||||
|
|
||||||
|
static wxClassInfo ms_classInfo;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline wxObject *wxCheckDynamicCast(wxObject *obj, wxClassInfo *classInfo)
|
inline wxObject *wxCheckDynamicCast(wxObject *obj, wxClassInfo *classInfo)
|
||||||
|
@@ -345,6 +345,8 @@ enum wxTextBoxAttrPosition
|
|||||||
wxTEXT_BOX_ATTR_POSITION_MASK = 0x00F0
|
wxTEXT_BOX_ATTR_POSITION_MASK = 0x00F0
|
||||||
};
|
};
|
||||||
|
|
||||||
|
wxALLOW_COMBINING_ENUMS(wxTextAttrUnits, wxTextAttrValueFlags)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@class wxTextAttrDimension
|
@class wxTextAttrDimension
|
||||||
|
|
||||||
|
@@ -140,7 +140,7 @@ WXDLLIMPEXP_BASE wxObject *wxCreateDynamicObject(const wxString& name);
|
|||||||
#define wxDECLARE_ABSTRACT_CLASS(name) \
|
#define wxDECLARE_ABSTRACT_CLASS(name) \
|
||||||
public: \
|
public: \
|
||||||
wxWARNING_SUPPRESS_MISSING_OVERRIDE() \
|
wxWARNING_SUPPRESS_MISSING_OVERRIDE() \
|
||||||
virtual wxClassInfo *GetClassInfo() const; \
|
virtual wxClassInfo *GetClassInfo() const wxDUMMY_OVERRIDE; \
|
||||||
wxWARNING_RESTORE_MISSING_OVERRIDE() \
|
wxWARNING_RESTORE_MISSING_OVERRIDE() \
|
||||||
static wxClassInfo ms_classInfo
|
static wxClassInfo ms_classInfo
|
||||||
|
|
||||||
|
@@ -295,7 +295,7 @@ struct wxFormatStringArgumentFinder<wxScopedCharBuffer>
|
|||||||
: public wxFormatStringArgumentFinder<const wxScopedCharBuffer&> {
|
: public wxFormatStringArgumentFinder<const wxScopedCharBuffer&> {
|
||||||
#ifdef wxNO_IMPLICIT_WXSTRING_ENCODING
|
#ifdef wxNO_IMPLICIT_WXSTRING_ENCODING
|
||||||
private:
|
private:
|
||||||
wxFormatStringArgumentFinder<wxScopedCharBuffer>(); // Disabled
|
wxFormatStringArgumentFinder() wxMEMBER_DELETE;
|
||||||
#endif // wxNO_IMPLICIT_WXSTRING_ENCODING
|
#endif // wxNO_IMPLICIT_WXSTRING_ENCODING
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -308,7 +308,7 @@ struct wxFormatStringArgumentFinder<wxCharBuffer>
|
|||||||
: public wxFormatStringArgumentFinder<const wxCharBuffer&> {
|
: public wxFormatStringArgumentFinder<const wxCharBuffer&> {
|
||||||
#ifdef wxNO_IMPLICIT_WXSTRING_ENCODING
|
#ifdef wxNO_IMPLICIT_WXSTRING_ENCODING
|
||||||
private:
|
private:
|
||||||
wxFormatStringArgumentFinder<wxCharBuffer>(); // Disabled
|
wxFormatStringArgumentFinder() wxMEMBER_DELETE;
|
||||||
#endif // wxNO_IMPLICIT_WXSTRING_ENCODING
|
#endif // wxNO_IMPLICIT_WXSTRING_ENCODING
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -409,7 +409,7 @@ struct wxFormatStringSpecifier<const T*>
|
|||||||
template<> struct wxFormatStringSpecifier<T> \
|
template<> struct wxFormatStringSpecifier<T> \
|
||||||
{ \
|
{ \
|
||||||
private: \
|
private: \
|
||||||
wxFormatStringSpecifier<T>(); /* Disabled */ \
|
wxFormatStringSpecifier() wxMEMBER_DELETE; \
|
||||||
};
|
};
|
||||||
|
|
||||||
wxFORMAT_STRING_SPECIFIER(bool, wxFormatString::Arg_Int)
|
wxFORMAT_STRING_SPECIFIER(bool, wxFormatString::Arg_Int)
|
||||||
@@ -689,42 +689,37 @@ struct wxArgNormalizerWchar<const wchar_t*>
|
|||||||
template<>
|
template<>
|
||||||
struct wxArgNormalizer<const char*> {
|
struct wxArgNormalizer<const char*> {
|
||||||
private:
|
private:
|
||||||
wxArgNormalizer<const char*>(const char*, const wxFormatString *,
|
wxArgNormalizer(const char*, const wxFormatString *, unsigned);
|
||||||
unsigned);
|
|
||||||
const char *get() const;
|
const char *get() const;
|
||||||
};
|
};
|
||||||
template<>
|
template<>
|
||||||
struct wxArgNormalizer<char*> {
|
struct wxArgNormalizer<char*> {
|
||||||
private:
|
private:
|
||||||
wxArgNormalizer<char*>(const char*, const wxFormatString *, unsigned);
|
wxArgNormalizer(const char*, const wxFormatString *, unsigned);
|
||||||
char *get() const;
|
char *get() const;
|
||||||
};
|
};
|
||||||
template<>
|
template<>
|
||||||
struct wxArgNormalizer<const std::string> {
|
struct wxArgNormalizer<const std::string> {
|
||||||
private:
|
private:
|
||||||
wxArgNormalizer<const std::string>(const std::string&,
|
wxArgNormalizer(const std::string&, const wxFormatString *, unsigned);
|
||||||
const wxFormatString *, unsigned);
|
|
||||||
std::string get() const;
|
std::string get() const;
|
||||||
};
|
};
|
||||||
template<>
|
template<>
|
||||||
struct wxArgNormalizer<std::string> {
|
struct wxArgNormalizer<std::string> {
|
||||||
private:
|
private:
|
||||||
wxArgNormalizer<std::string>(std::string&,
|
wxArgNormalizer(std::string&, const wxFormatString *, unsigned);
|
||||||
const wxFormatString *, unsigned);
|
|
||||||
std::string get() const;
|
std::string get() const;
|
||||||
};
|
};
|
||||||
template<>
|
template<>
|
||||||
struct wxArgNormalizer<wxCharBuffer> {
|
struct wxArgNormalizer<wxCharBuffer> {
|
||||||
private:
|
private:
|
||||||
wxArgNormalizer<wxCharBuffer>(wxCharBuffer&,
|
wxArgNormalizer(wxCharBuffer&, const wxFormatString *, unsigned);
|
||||||
const wxFormatString *, unsigned);
|
|
||||||
std::string get() const;
|
std::string get() const;
|
||||||
};
|
};
|
||||||
template<>
|
template<>
|
||||||
struct wxArgNormalizer<wxScopedCharBuffer> {
|
struct wxArgNormalizer<wxScopedCharBuffer> {
|
||||||
private:
|
private:
|
||||||
wxArgNormalizer<wxScopedCharBuffer>(wxScopedCharBuffer&,
|
wxArgNormalizer(wxScopedCharBuffer&, const wxFormatString *, unsigned);
|
||||||
const wxFormatString *, unsigned);
|
|
||||||
std::string get() const;
|
std::string get() const;
|
||||||
};
|
};
|
||||||
#endif // wxNO_IMPLICIT_WXSTRING_ENCODING
|
#endif // wxNO_IMPLICIT_WXSTRING_ENCODING
|
||||||
|
@@ -17,7 +17,7 @@
|
|||||||
// wxToolBar style flags
|
// wxToolBar style flags
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
enum
|
enum wxToolBarStyleFlags
|
||||||
{
|
{
|
||||||
// lay out the toolbar horizontally
|
// lay out the toolbar horizontally
|
||||||
wxTB_HORIZONTAL = wxHORIZONTAL, // == 0x0004
|
wxTB_HORIZONTAL = wxHORIZONTAL, // == 0x0004
|
||||||
@@ -61,6 +61,8 @@ enum
|
|||||||
wxTB_DEFAULT_STYLE = wxTB_HORIZONTAL
|
wxTB_DEFAULT_STYLE = wxTB_HORIZONTAL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
wxALLOW_COMBINING_ENUMS(wxToolBarStyleFlags, wxBorder)
|
||||||
|
|
||||||
#if wxUSE_TOOLBAR
|
#if wxUSE_TOOLBAR
|
||||||
#include "wx/tbarbase.h" // the base class for all toolbars
|
#include "wx/tbarbase.h" // the base class for all toolbars
|
||||||
|
|
||||||
|
@@ -425,7 +425,7 @@ bool wxFontBase::SetNativeFontInfoUserDesc(const wxString& info)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxFontBase::operator==(const wxFont& font) const
|
bool wxFontBase::operator==(const wxFontBase& font) const
|
||||||
{
|
{
|
||||||
// either it is the same font, i.e. they share the same common data or they
|
// either it is the same font, i.e. they share the same common data or they
|
||||||
// have different ref datas but still describe the same font
|
// have different ref datas but still describe the same font
|
||||||
|
@@ -58,9 +58,7 @@ enum {
|
|||||||
TAR_NUMFIELDS
|
TAR_NUMFIELDS
|
||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
static const int TAR_BLOCKSIZE = 512;
|
||||||
TAR_BLOCKSIZE = 512
|
|
||||||
};
|
|
||||||
|
|
||||||
// checksum type
|
// checksum type
|
||||||
enum {
|
enum {
|
||||||
|
@@ -317,7 +317,7 @@ selection_handler( GtkWidget *WXUNUSED(widget),
|
|||||||
// use UTF8_STRING format if requested in Unicode build but just plain
|
// use UTF8_STRING format if requested in Unicode build but just plain
|
||||||
// STRING one in ANSI or if explicitly asked in Unicode
|
// STRING one in ANSI or if explicitly asked in Unicode
|
||||||
#if wxUSE_UNICODE
|
#if wxUSE_UNICODE
|
||||||
if (format == wxDataFormat(wxDF_UNICODETEXT))
|
if (format == wxDF_UNICODETEXT)
|
||||||
{
|
{
|
||||||
gtk_selection_data_set_text(
|
gtk_selection_data_set_text(
|
||||||
selection_data,
|
selection_data,
|
||||||
|
@@ -387,6 +387,33 @@
|
|||||||
|
|
||||||
#include "allheaders.h"
|
#include "allheaders.h"
|
||||||
|
|
||||||
|
// Check that using wx macros doesn't result in -Wsuggest-override or
|
||||||
|
// equivalent warnings in classes using and not using "override".
|
||||||
|
struct Base : wxEvtHandler
|
||||||
|
{
|
||||||
|
virtual ~Base() { }
|
||||||
|
|
||||||
|
virtual void Foo() { }
|
||||||
|
};
|
||||||
|
|
||||||
|
struct DerivedWithoutOverride : Base
|
||||||
|
{
|
||||||
|
void OnIdle(wxIdleEvent&) { }
|
||||||
|
|
||||||
|
wxDECLARE_DYNAMIC_CLASS_NO_COPY(DerivedWithoutOverride);
|
||||||
|
wxDECLARE_EVENT_TABLE();
|
||||||
|
};
|
||||||
|
|
||||||
|
struct DerivedWithOverride : Base
|
||||||
|
{
|
||||||
|
virtual void Foo() wxOVERRIDE { }
|
||||||
|
|
||||||
|
void OnIdle(wxIdleEvent&) { }
|
||||||
|
|
||||||
|
wxDECLARE_DYNAMIC_CLASS_NO_COPY(DerivedWithOverride);
|
||||||
|
wxDECLARE_EVENT_TABLE();
|
||||||
|
};
|
||||||
|
|
||||||
#ifdef GCC_TURN_OFF
|
#ifdef GCC_TURN_OFF
|
||||||
// Just using REQUIRE() below triggers -Wparentheses, so avoid it.
|
// Just using REQUIRE() below triggers -Wparentheses, so avoid it.
|
||||||
GCC_TURN_OFF(parentheses)
|
GCC_TURN_OFF(parentheses)
|
||||||
|
Reference in New Issue
Block a user