Skip to content

Commit

Permalink
Add some warnings as errors in macOS (surge-synthesizer#1734)
Browse files Browse the repository at this point in the history
Turn on the following for macOS, also clearning up
quite a few clang errorss on freebsd apparently

 -Werror=inconsistent-missing-override
 -Werror=logical-op-parentheses
 -Werror=dynamic-class-memaccess
 -Werror=undefined-bool-conversion

This addresses surge-synthesizer#1731
  • Loading branch information
baconpaul authored Apr 16, 2020
1 parent 6eaf2b2 commit c2c229b
Show file tree
Hide file tree
Showing 26 changed files with 112 additions and 97 deletions.
13 changes: 9 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,11 @@ if( APPLE )
-msse2
"-D_aligned_malloc(x,a)=malloc(x)"
"-D_aligned_free(x)=free(x)"
-Wno-deprecated-declarations
-Werror=inconsistent-missing-override
-Werror=logical-op-parentheses
-Werror=dynamic-class-memaccess
-Werror=undefined-bool-conversion
)
set(OS_INCLUDE_DIRECTORIES
src/mac
Expand Down Expand Up @@ -486,11 +491,11 @@ if( BUILD_VST3 )
if( APPLE )
target_sources(surge-vst3 PRIVATE vst3sdk/public.sdk/source/main/macmain.cpp)
elseif( UNIX AND NOT APPLE )
target_sources(surge-vst3 PUBLIC
target_sources(surge-vst3 PRIVATE
vst3sdk/public.sdk/source/main/linuxmain.cpp
src/linux/LinuxVST3Helpers.cpp)
elseif( WIN32 )
target_sources(surge-vst3 PUBLIC vst3sdk/public.sdk/source/main/dllmain.cpp)
target_sources(surge-vst3 PRIVATE vst3sdk/public.sdk/source/main/dllmain.cpp)
target_link_options( surge-vst3 PUBLIC "/DEF:..\\resources\\windows-vst3\\surge.def" )
endif()

Expand Down Expand Up @@ -735,8 +740,8 @@ if( BUILD_HEADLESS )

find_package(LibSndFile ${PACKAGE_OPTION})
if(NOT LIBSNDFILE_FOUND)
message(WARNING "LibSndFile not installed; building without wav support")
message(WARNING "You can 'brew install libsndfile' or 'apt-get install libsndfile1-dev'")
message("-- LibSndFile not installed; building without wav support")
message("-- You can 'brew install libsndfile' or 'apt-get install libsndfile1-dev'")
else()
target_compile_definitions(surge-headless
PRIVATE
Expand Down
32 changes: 19 additions & 13 deletions libs/xml/tinyxml.h
Original file line number Diff line number Diff line change
Expand Up @@ -603,19 +603,25 @@ class TiXmlNode : public TiXmlBase
/// Returns true if this node has no children.
bool NoChildren() const { return !firstChild; }

const TiXmlDocument* ToDocument() const { return ( this && type == DOCUMENT ) ? (const TiXmlDocument*) this : 0; } ///< Cast to a more defined type. Will return null not of the requested type.
const TiXmlElement* ToElement() const { return ( this && type == ELEMENT ) ? (const TiXmlElement*) this : 0; } ///< Cast to a more defined type. Will return null not of the requested type.
const TiXmlComment* ToComment() const { return ( this && type == COMMENT ) ? (const TiXmlComment*) this : 0; } ///< Cast to a more defined type. Will return null not of the requested type.
const TiXmlUnknown* ToUnknown() const { return ( this && type == UNKNOWN ) ? (const TiXmlUnknown*) this : 0; } ///< Cast to a more defined type. Will return null not of the requested type.
const TiXmlText* ToText() const { return ( this && type == TEXT ) ? (const TiXmlText*) this : 0; } ///< Cast to a more defined type. Will return null not of the requested type.
const TiXmlDeclaration* ToDeclaration() const { return ( this && type == DECLARATION ) ? (const TiXmlDeclaration*) this : 0; } ///< Cast to a more defined type. Will return null not of the requested type.

TiXmlDocument* ToDocument() { return ( this && type == DOCUMENT ) ? (TiXmlDocument*) this : 0; } ///< Cast to a more defined type. Will return null not of the requested type.
TiXmlElement* ToElement() { return ( this && type == ELEMENT ) ? (TiXmlElement*) this : 0; } ///< Cast to a more defined type. Will return null not of the requested type.
TiXmlComment* ToComment() { return ( this && type == COMMENT ) ? (TiXmlComment*) this : 0; } ///< Cast to a more defined type. Will return null not of the requested type.
TiXmlUnknown* ToUnknown() { return ( this && type == UNKNOWN ) ? (TiXmlUnknown*) this : 0; } ///< Cast to a more defined type. Will return null not of the requested type.
TiXmlText* ToText() { return ( this && type == TEXT ) ? (TiXmlText*) this : 0; } ///< Cast to a more defined type. Will return null not of the requested type.
TiXmlDeclaration* ToDeclaration() { return ( this && type == DECLARATION ) ? (TiXmlDeclaration*) this : 0; } ///< Cast to a more defined type. Will return null not of the requested type.
#if INEEDTHISAND
#define THISAND this &&
#else
#define THISAND
#endif

const TiXmlDocument* ToDocument() const { return ( THISAND type == DOCUMENT ) ? (const TiXmlDocument*) this : 0; } ///< Cast to a more defined type. Will return null not of the requested type.
const TiXmlElement* ToElement() const { return ( THISAND type == ELEMENT ) ? (const TiXmlElement*) this : 0; } ///< Cast to a more defined type. Will return null not of the requested type.
const TiXmlComment* ToComment() const { return ( THISAND type == COMMENT ) ? (const TiXmlComment*) this : 0; } ///< Cast to a more defined type. Will return null not of the requested type.
const TiXmlUnknown* ToUnknown() const { return ( THISAND type == UNKNOWN ) ? (const TiXmlUnknown*) this : 0; } ///< Cast to a more defined type. Will return null not of the requested type.
const TiXmlText* ToText() const { return ( THISAND type == TEXT ) ? (const TiXmlText*) this : 0; } ///< Cast to a more defined type. Will return null not of the requested type.
const TiXmlDeclaration* ToDeclaration() const { return ( THISAND type == DECLARATION ) ? (const TiXmlDeclaration*) this : 0; } ///< Cast to a more defined type. Will return null not of the requested type.

TiXmlDocument* ToDocument() { return ( THISAND type == DOCUMENT ) ? (TiXmlDocument*) this : 0; } ///< Cast to a more defined type. Will return null not of the requested type.
TiXmlElement* ToElement() { return ( THISAND type == ELEMENT ) ? (TiXmlElement*) this : 0; } ///< Cast to a more defined type. Will return null not of the requested type.
TiXmlComment* ToComment() { return ( THISAND type == COMMENT ) ? (TiXmlComment*) this : 0; } ///< Cast to a more defined type. Will return null not of the requested type.
TiXmlUnknown* ToUnknown() { return ( THISAND type == UNKNOWN ) ? (TiXmlUnknown*) this : 0; } ///< Cast to a more defined type. Will return null not of the requested type.
TiXmlText* ToText() { return ( THISAND type == TEXT ) ? (TiXmlText*) this : 0; } ///< Cast to a more defined type. Will return null not of the requested type.
TiXmlDeclaration* ToDeclaration() { return ( THISAND type == DECLARATION ) ? (TiXmlDeclaration*) this : 0; } ///< Cast to a more defined type. Will return null not of the requested type.

/** Create an exact duplicate of this node and return it. The memory must be deleted
by the caller.
Expand Down
8 changes: 4 additions & 4 deletions src/common/Parameter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -911,7 +911,7 @@ std::string Parameter::tempoSyncNotationValue(float f)
else
{
char tmp[1024];
snprintf(tmp, 1024, "1/%0.d", (int)d, d );
snprintf(tmp, 1024, "1/%d", (int)d );
nn = tmp;
}
}
Expand Down Expand Up @@ -1405,14 +1405,14 @@ void Parameter::morph(Parameter* a, Parameter* b, float x)
{
if ((a->valtype == vt_float) && (b->valtype == vt_float) && (a->ctrltype == b->ctrltype))
{
memcpy(this, a, sizeof(Parameter));
memcpy((void*)this, (void*)a, sizeof(Parameter));
val.f = (1 - x) * a->val.f + x * b->val.f;
}
else
{
if (x > 0.5)
memcpy(this, b, sizeof(Parameter));
memcpy((void*)this, (void*)b, sizeof(Parameter));
else
memcpy(this, a, sizeof(Parameter));
memcpy((void*)this, (void*)a, sizeof(Parameter));
}
}
8 changes: 4 additions & 4 deletions src/common/SurgeSynthesizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ SurgeSynthesizer::SurgeSynthesizer(PluginLayer* parent, std::string suppliedData
memset(storage.getPatch().scenedata[1], 0, sizeof(pdata) * n_scene_params);
memset(storage.getPatch().globaldata, 0, sizeof(pdata) * n_global_params);
memset(mControlInterpolatorUsed, 0, sizeof(bool) * num_controlinterpolators);
memset(fxsync, 0, sizeof(FxStorage) * 8);
memset((void*)fxsync, 0, sizeof(FxStorage) * 8);
for (int i = 0; i < 8; i++)
{
memcpy(&fxsync[i], &storage.getPatch().fx[i], sizeof(FxStorage));
memcpy((void*)&fxsync[i], (void*)&storage.getPatch().fx[i], sizeof(FxStorage));
fx_reload[i] = false;
}

Expand Down Expand Up @@ -1558,7 +1558,7 @@ bool SurgeSynthesizer::loadFx(bool initp, bool force_reload_all)
}

if (/*!force_reload_all && */ storage.getPatch().fx[s].type.val.i)
memcpy(&storage.getPatch().fx[s].p, &fxsync[s].p, sizeof(Parameter) * n_fx_params);
memcpy((void*)&storage.getPatch().fx[s].p, (void*)&fxsync[s].p, sizeof(Parameter) * n_fx_params);

fx[s].reset(spawn_effect(storage.getPatch().fx[s].type.val.i, &storage,
&storage.getPatch().fx[s], storage.getPatch().globaldata));
Expand All @@ -1581,7 +1581,7 @@ bool SurgeSynthesizer::loadFx(bool initp, bool force_reload_all)
}
else if (fx_reload[s])
{
memcpy(&storage.getPatch().fx[s].p, &fxsync[s].p, sizeof(Parameter) * n_fx_params);
memcpy((void*)&storage.getPatch().fx[s].p, (void*)&fxsync[s].p, sizeof(Parameter) * n_fx_params);
if (fx[s])
{
fx[s]->suspend();
Expand Down
2 changes: 1 addition & 1 deletion src/common/SurgeSynthesizerIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ void SurgeSynthesizer::loadRaw(const void* data, int size, bool preset)
storage.getPatch().update_controls(false, nullptr, true);
for (int i = 0; i < 8; i++)
{
memcpy(&fxsync[i], &storage.getPatch().fx[i], sizeof(FxStorage));
memcpy((void*)&fxsync[i], (void*)&storage.getPatch().fx[i], sizeof(FxStorage));
fx_reload[i] = true;
}

Expand Down
6 changes: 3 additions & 3 deletions src/common/WavSupport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,9 @@ void SurgeStorage::load_wt_wav_portable(std::string fn, Wavetable *wt)
free(data);

// Do a format check here to bail out
if (! ( numChannels == 1 &&
( (audioFormat == 1 /* WAVE_FORMAT_PCM */) && (bitsPerSample == 16) ) ||
( (audioFormat == 3 /* IEEE_FLOAT */ ) && (bitsPerSample == 32) ) ) )
if (! ( ( numChannels == 1 ) &&
( ( (audioFormat == 1 /* WAVE_FORMAT_PCM */) && (bitsPerSample == 16) ) ||
( (audioFormat == 3 /* IEEE_FLOAT */ ) && (bitsPerSample == 32) ) ) ) )
{
std::string formname = "Unknown (" + std::to_string(audioFormat) + ")";
if( audioFormat == 1 ) formname = "PCM";
Expand Down
6 changes: 3 additions & 3 deletions src/common/gui/CAboutBox.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ class CAboutBox : public VSTGUI::CControl, public Surge::UI::SkinConsumingCompon
VSTGUI::CBitmap* aboutBitmap);
virtual ~CAboutBox();

virtual void draw(VSTGUI::CDrawContext*);
virtual bool hitTest(const VSTGUI::CPoint& where, const VSTGUI::CButtonState& buttons = -1);
virtual void draw(VSTGUI::CDrawContext*) override;
virtual bool hitTest(const VSTGUI::CPoint& where, const VSTGUI::CButtonState& buttons = -1) override;
// virtual void mouse (VSTGUI::CDrawContext *pContext, VSTGUI::CPoint &where, long button = -1);
virtual VSTGUI::CMouseEventResult
onMouseDown(VSTGUI::CPoint& where,
const VSTGUI::CButtonState& buttons); ///< called when a mouse down event occurs
const VSTGUI::CButtonState& buttons) override; ///< called when a mouse down event occurs
virtual void unSplash();

void boxShow(std::string dataPath, std::string userPath);
Expand Down
6 changes: 3 additions & 3 deletions src/common/gui/CCursorHidingControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ class CCursorHidingControl : public VSTGUI::CControl
VSTGUI::CBitmap* pBackground);
virtual ~CCursorHidingControl();

virtual VSTGUI::CMouseEventResult onMouseDown(VSTGUI::CPoint& where, const VSTGUI::CButtonState& buttons);
virtual VSTGUI::CMouseEventResult onMouseUp(VSTGUI::CPoint& where, const VSTGUI::CButtonState& buttons);
virtual VSTGUI::CMouseEventResult onMouseMoved(VSTGUI::CPoint& where, const VSTGUI::CButtonState& buttons);
virtual VSTGUI::CMouseEventResult onMouseDown(VSTGUI::CPoint& where, const VSTGUI::CButtonState& buttons) override;
virtual VSTGUI::CMouseEventResult onMouseUp(VSTGUI::CPoint& where, const VSTGUI::CButtonState& buttons) override;
virtual VSTGUI::CMouseEventResult onMouseMoved(VSTGUI::CPoint& where, const VSTGUI::CButtonState& buttons) override;

virtual void
onMouseMoveDelta(VSTGUI::CPoint& where, const VSTGUI::CButtonState& buttons, double dx, double dy) = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/common/gui/CEffectLabel.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class CEffectLabel : public VSTGUI::CControl, public Surge::UI::SkinConsumingCom
CEffectLabel(const VSTGUI::CRect& size) : VSTGUI::CControl(size, 0, 0, 0)
{}

virtual void draw(VSTGUI::CDrawContext* dc)
virtual void draw(VSTGUI::CDrawContext* dc) override
{
VSTGUI::CRect size = getViewSize();
VSTGUI::CRect bl(size);
Expand Down
6 changes: 3 additions & 3 deletions src/common/gui/CEffectSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ class CEffectSettings : public VSTGUI::CControl
long tag,
int current,
std::shared_ptr<SurgeBitmaps> bitmapStore);
virtual void draw(VSTGUI::CDrawContext* dc);
virtual void draw(VSTGUI::CDrawContext* dc) override;
virtual VSTGUI::CMouseEventResult
onMouseDown(VSTGUI::CPoint& where,
const VSTGUI::CButtonState& buttons); ///< called when a mouse down event occurs
const VSTGUI::CButtonState& buttons) override; ///< called when a mouse down event occurs
virtual VSTGUI::CMouseEventResult
onMouseUp(VSTGUI::CPoint& where, const VSTGUI::CButtonState& buttons); ///< called when a mouse up event occurs
onMouseUp(VSTGUI::CPoint& where, const VSTGUI::CButtonState& buttons) override; ///< called when a mouse up event occurs

int current;
VSTGUI::CBitmap *bg, *labels;
Expand Down
10 changes: 5 additions & 5 deletions src/common/gui/CHSwitch2.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,17 @@ class CHSwitch2 : public VSTGUI::CHorizontalSwitch
bool dragable;
bool usesMouseWheel;

virtual void draw(VSTGUI::CDrawContext* dc);
virtual void draw(VSTGUI::CDrawContext* dc) override;
virtual VSTGUI::CMouseEventResult
onMouseDown(VSTGUI::CPoint& where,
const VSTGUI::CButtonState& buttons); ///< called when a mouse down event occurs
const VSTGUI::CButtonState& buttons) override; ///< called when a mouse down event occurs
virtual VSTGUI::CMouseEventResult
onMouseUp(VSTGUI::CPoint& where, const VSTGUI::CButtonState& buttons); ///< called when a mouse up event occurs
onMouseUp(VSTGUI::CPoint& where, const VSTGUI::CButtonState& buttons) override; ///< called when a mouse up event occurs
virtual VSTGUI::CMouseEventResult
onMouseMoved(VSTGUI::CPoint& where,
const VSTGUI::CButtonState& buttons); ///< called when a mouse move event occurs
const VSTGUI::CButtonState& buttons) override; ///< called when a mouse move event occurs
virtual bool
onWheel (const VSTGUI::CPoint& where, const float& distance, const VSTGUI::CButtonState& buttons); ///< called when scrollwheel events occurs
onWheel (const VSTGUI::CPoint& where, const float& distance, const VSTGUI::CButtonState& buttons) override; ///< called when scrollwheel events occurs
CLASS_METHODS(CHSwitch2, VSTGUI::CControl)
void setUsesMouseWheel(bool wheel);
};
8 changes: 4 additions & 4 deletions src/common/gui/CLFOGui.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ class CLFOGui : public VSTGUI::CControl, public Surge::UI::SkinConsumingComponnt
#endif
}
// virtual void mouse (CDrawContext *pContext, VSTGUI::CPoint &where, long buttons = -1);
virtual VSTGUI::CMouseEventResult onMouseDown(VSTGUI::CPoint& where, const VSTGUI::CButtonState& buttons);
virtual VSTGUI::CMouseEventResult onMouseUp(VSTGUI::CPoint& where, const VSTGUI::CButtonState& buttons);
virtual VSTGUI::CMouseEventResult onMouseMoved(VSTGUI::CPoint& where, const VSTGUI::CButtonState& buttons);
virtual VSTGUI::CMouseEventResult onMouseDown(VSTGUI::CPoint& where, const VSTGUI::CButtonState& buttons) override;
virtual VSTGUI::CMouseEventResult onMouseUp(VSTGUI::CPoint& where, const VSTGUI::CButtonState& buttons) override;
virtual VSTGUI::CMouseEventResult onMouseMoved(VSTGUI::CPoint& where, const VSTGUI::CButtonState& buttons) override;

virtual void setSkin( Surge::UI::Skin::ptr_t s ) override {
SkinConsumingComponnt::setSkin(s);
Expand All @@ -107,7 +107,7 @@ class CLFOGui : public VSTGUI::CControl, public Surge::UI::SkinConsumingComponnt
{
delete cdisurf;
}
virtual void draw(VSTGUI::CDrawContext* dc);
virtual void draw(VSTGUI::CDrawContext* dc) override;
void drawVectorized(VSTGUI::CDrawContext* dc);
void drawBitmap(VSTGUI::CDrawContext* dc);
void drawStepSeq(VSTGUI::CDrawContext *dc, VSTGUI::CRect &maindisp, VSTGUI::CRect &leftpanel);
Expand Down
14 changes: 7 additions & 7 deletions src/common/gui/CModulationSourceButton.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ class CModulationSourceButton : public CCursorHidingControl
std::shared_ptr<SurgeBitmaps> bitmapStore);
~CModulationSourceButton();

virtual void setValue(float val)
virtual void setValue(float val) override
{
if (value != val)
invalid();
value = val;
}

virtual void onMouseMoveDelta(VSTGUI::CPoint& where, const VSTGUI::CButtonState& buttons, double dx, double dy);
virtual double getMouseDeltaScaling(VSTGUI::CPoint& where, const VSTGUI::CButtonState& buttons);
virtual bool onWheel(const VSTGUI::CPoint& where, const float &distance, const VSTGUI::CButtonState& buttons);
virtual void onMouseMoveDelta(VSTGUI::CPoint& where, const VSTGUI::CButtonState& buttons, double dx, double dy) override;
virtual double getMouseDeltaScaling(VSTGUI::CPoint& where, const VSTGUI::CButtonState& buttons) override;
virtual bool onWheel(const VSTGUI::CPoint& where, const float &distance, const VSTGUI::CButtonState& buttons) override;

int state, msid, controlstate;

Expand Down Expand Up @@ -66,9 +66,9 @@ class CModulationSourceButton : public CCursorHidingControl
bool useAlternate = false;
void setUseAlternate( bool f ) { useAlternate = f; if( hasAlternate ) { invalid(); setDirty(); } }

virtual void draw(VSTGUI::CDrawContext* dc);
virtual void draw(VSTGUI::CDrawContext* dc) override;
// virtual void mouse (VSTGUI::CDrawContext *pContext, VSTGUI::CPoint &where, long button = -1);
virtual VSTGUI::CMouseEventResult onMouseDown(VSTGUI::CPoint& where, const VSTGUI::CButtonState& buttons);
virtual VSTGUI::CMouseEventResult onMouseUp(VSTGUI::CPoint& where, const VSTGUI::CButtonState& buttons);
virtual VSTGUI::CMouseEventResult onMouseDown(VSTGUI::CPoint& where, const VSTGUI::CButtonState& buttons) override;
virtual VSTGUI::CMouseEventResult onMouseUp(VSTGUI::CPoint& where, const VSTGUI::CButtonState& buttons) override;
CLASS_METHODS(CModulationSourceButton, VSTGUI::CControl)
};
14 changes: 7 additions & 7 deletions src/common/gui/CNumberField.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,9 @@ class CNumberField : public VSTGUI::CControl, public Surge::UI::SkinConsumingCom
envColor = bgcol;
}

virtual void bounceValue();
virtual void bounceValue() override;

virtual void setValue(float val);
virtual void setValue(float val) override;

void setIntValue(int ival)
{
Expand Down Expand Up @@ -221,12 +221,12 @@ class CNumberField : public VSTGUI::CControl, public Surge::UI::SkinConsumingCom
virtual void setLabel(char* newlabel);
virtual void setLabelPlacement(int placement);

virtual void draw(VSTGUI::CDrawContext*);
virtual void draw(VSTGUI::CDrawContext*) override;
// virtual void mouse (VSTGUI::CDrawContext *pContext, VSTGUI::CPoint &where, long buttons = -1);
virtual VSTGUI::CMouseEventResult onMouseDown(VSTGUI::CPoint& where, const VSTGUI::CButtonState& buttons);
virtual VSTGUI::CMouseEventResult onMouseUp(VSTGUI::CPoint& where, const VSTGUI::CButtonState& buttons);
virtual VSTGUI::CMouseEventResult onMouseMoved(VSTGUI::CPoint& where, const VSTGUI::CButtonState& buttons);
virtual bool onWheel(const VSTGUI::CPoint& where, const float& distance, const VSTGUI::CButtonState& buttons);
virtual VSTGUI::CMouseEventResult onMouseDown(VSTGUI::CPoint& where, const VSTGUI::CButtonState& buttons) override;
virtual VSTGUI::CMouseEventResult onMouseUp(VSTGUI::CPoint& where, const VSTGUI::CButtonState& buttons) override;
virtual VSTGUI::CMouseEventResult onMouseMoved(VSTGUI::CPoint& where, const VSTGUI::CButtonState& buttons) override;
virtual bool onWheel(const VSTGUI::CPoint& where, const float& distance, const VSTGUI::CButtonState& buttons) override;
bool altlook;

private:
Expand Down
Loading

0 comments on commit c2c229b

Please sign in to comment.