From e11bd98f52ac906d74d0683fcbafdd8ee38c56be Mon Sep 17 00:00:00 2001 From: Jean-Paul Chaput Date: Fri, 1 Oct 2021 16:12:28 +0200 Subject: [PATCH] Correct for various warnings appearing under gcc 8.3.0 (Debian 10). Note: We don't suppress warnings due to unused variables or functions, as we may need them later or in debug mode... * Change: In Hurricane::DBo::~DBo, add a noexcept(false) because constructed by default destructor of derived classes seems to loosen it. The right solution whould be to explicitely define all virtual destructors (too lazy for now). * Change: In Viewer::Script, replace the deprecated PyModule_GetFilename() by PyModule_GetFilenameObject(), Unicode support again... --- crlcore/src/ccore/AllianceFramework.cpp | 4 ++-- .../src/ccore/toolbox/HyperNetPortOccurrences.cpp | 2 +- crlcore/src/ccore/toolbox/ToolBox.cpp | 4 ++-- .../hurricane/configuration/PyTypeManager.h | 4 ++-- hurricane/src/hurricane/DBo.cpp | 2 +- hurricane/src/hurricane/Hook.cpp | 6 +++--- hurricane/src/hurricane/hurricane/DBo.h | 2 +- hurricane/src/hurricane/hurricane/Hook.h | 2 +- hurricane/src/hurricane/hurricane/PhysicalRule.h | 2 +- hurricane/src/viewer/hurricane/viewer/Script.h | 12 +++++++++--- 10 files changed, 23 insertions(+), 17 deletions(-) diff --git a/crlcore/src/ccore/AllianceFramework.cpp b/crlcore/src/ccore/AllianceFramework.cpp index 171d496f..cef022c0 100644 --- a/crlcore/src/ccore/AllianceFramework.cpp +++ b/crlcore/src/ccore/AllianceFramework.cpp @@ -374,7 +374,7 @@ namespace CRL { if (state->getFlags(loadMode) != 0) continue; // Transmit all flags except thoses related to views. - loadMode |= (mode & (!Catalog::State::Views)); + loadMode |= (mode & (~Catalog::State::Views)); parser = & (_parsers.getParserSlot( name, loadMode, _environment )); // Try to open cell file (file extention is supplied by the parser). @@ -864,7 +864,7 @@ namespace CRL { if ( catalogProperty != NULL ) { Catalog::State* state = catalogProperty->getState (); - if ( (flags and IgnoreFeeds) and state->isFeed() ) continue; + if ( (flags & IgnoreFeeds) and state->isFeed() ) continue; } ++gates; diff --git a/crlcore/src/ccore/toolbox/HyperNetPortOccurrences.cpp b/crlcore/src/ccore/toolbox/HyperNetPortOccurrences.cpp index a780d8e7..d420605d 100644 --- a/crlcore/src/ccore/toolbox/HyperNetPortOccurrences.cpp +++ b/crlcore/src/ccore/toolbox/HyperNetPortOccurrences.cpp @@ -515,7 +515,7 @@ Occurrence CHyperNetReceiverPortOccurrences::Locator::getElement() const { if (_pinLocator.isValid()) return _pinLocator.getElement(); - return _plugOccurrenceLocator.getElement(); + return _plugOccurrenceLocator.getElement(); } Locator* CHyperNetReceiverPortOccurrences::Locator::getClone() const diff --git a/crlcore/src/ccore/toolbox/ToolBox.cpp b/crlcore/src/ccore/toolbox/ToolBox.cpp index 7e635136..f5e75b5b 100644 --- a/crlcore/src/ccore/toolbox/ToolBox.cpp +++ b/crlcore/src/ccore/toolbox/ToolBox.cpp @@ -401,7 +401,7 @@ static void AttachContacts(Net* net) { if (contact->getBodyHook()->isAttached()) throw Error("Cannot create contacts ring: A bodyHook is attached"); - componentsToAttachList.push_back(contact); + componentsToAttachList.push_back(contact); end_for; } list::iterator lcit = componentsToAttachList.begin(); @@ -779,7 +779,7 @@ void ConnectPlugHooks(Cell* cell) try { _index = std::stoi( sindex ); } - catch ( std::invalid_argument e ) { + catch ( std::invalid_argument& e ) { cerr << Error( "SubNetNames::match(): std::stoi() catched an exception on \"%s\"." , sindex.c_str() ) << endl; } diff --git a/hurricane/src/configuration/hurricane/configuration/PyTypeManager.h b/hurricane/src/configuration/hurricane/configuration/PyTypeManager.h index 7b97c1e2..1de32e90 100644 --- a/hurricane/src/configuration/hurricane/configuration/PyTypeManager.h +++ b/hurricane/src/configuration/hurricane/configuration/PyTypeManager.h @@ -1998,8 +1998,8 @@ namespace Isobar3 { PyErr_Clear(); setMessage( funcName() + "(): " ); - TC* object; - TArg* arg; + TC* object = NULL; + TArg* arg = NULL; pyToC( pyObject, &object ); if (not pyToC( pyArg, &arg )) { string message = "PyInPlaceOperatorWrapper():"; diff --git a/hurricane/src/hurricane/DBo.cpp b/hurricane/src/hurricane/DBo.cpp index 66238588..3f9d15b0 100644 --- a/hurricane/src/hurricane/DBo.cpp +++ b/hurricane/src/hurricane/DBo.cpp @@ -157,7 +157,7 @@ namespace Hurricane { } - DBo::~DBo () + DBo::~DBo () noexcept(false) { if (_idCount) --_idCount; else { diff --git a/hurricane/src/hurricane/Hook.cpp b/hurricane/src/hurricane/Hook.cpp index cadca6ae..ab1646c6 100644 --- a/hurricane/src/hurricane/Hook.cpp +++ b/hurricane/src/hurricane/Hook.cpp @@ -196,11 +196,11 @@ Hook::Hook() { } -Hook::~Hook() -// ********** +Hook::~Hook() noexcept(false) +// ************************** { if (_nextHook != this) - throw Error("Abnormal deletion of hook : always attached"); + throw Error("Abnormal deletion of hook : still attached"); } Hook* Hook::getNextHook() const diff --git a/hurricane/src/hurricane/hurricane/DBo.h b/hurricane/src/hurricane/hurricane/DBo.h index c84d89e6..1db5455f 100644 --- a/hurricane/src/hurricane/hurricane/DBo.h +++ b/hurricane/src/hurricane/hurricane/DBo.h @@ -81,7 +81,7 @@ namespace Hurricane { void toJsonSignature ( JsonWriter* ) const; protected: DBo (); - virtual ~DBo (); + virtual ~DBo () noexcept(false); virtual void _postCreate (); virtual void _preDestroy (); private: diff --git a/hurricane/src/hurricane/hurricane/Hook.h b/hurricane/src/hurricane/hurricane/Hook.h index e5520f63..aba5b647 100644 --- a/hurricane/src/hurricane/hurricane/Hook.h +++ b/hurricane/src/hurricane/hurricane/Hook.h @@ -52,7 +52,7 @@ class Hook { // Destructor // ********** - protected: virtual ~Hook(); + protected: virtual ~Hook() noexcept(false); // Operators // ********* diff --git a/hurricane/src/hurricane/hurricane/PhysicalRule.h b/hurricane/src/hurricane/hurricane/PhysicalRule.h index 4d12b80f..d8307ff5 100644 --- a/hurricane/src/hurricane/hurricane/PhysicalRule.h +++ b/hurricane/src/hurricane/hurricane/PhysicalRule.h @@ -115,7 +115,7 @@ namespace Hurricane { inline bool PhysicalRule::isDouble () const { return _doubleValue != 0; } inline bool PhysicalRule::isDbU () const { return not _stepsValue.empty(); } inline bool PhysicalRule::isSymmetric () const { return _symmetric; } - inline bool PhysicalRule::hasSteps () const { return not _stepsValue.size() > 1; } + inline bool PhysicalRule::hasSteps () const { return not (_stepsValue.size() > 1); } inline double PhysicalRule::getDoubleValue () const { return _doubleValue; } inline void PhysicalRule::setSymmetric ( bool state ) { _symmetric = state; } inline void PhysicalRule::addValue ( double value ) { _doubleValue = value; } diff --git a/hurricane/src/viewer/hurricane/viewer/Script.h b/hurricane/src/viewer/hurricane/viewer/Script.h index 63ff5480..da8413c0 100644 --- a/hurricane/src/viewer/hurricane/viewer/Script.h +++ b/hurricane/src/viewer/hurricane/viewer/Script.h @@ -48,7 +48,7 @@ namespace Isobar { static Script* create ( const std::string& name="" ); void destroy (); inline std::string getUserModuleName () const; - inline const char* getFileName () const; + inline std::string getFileName () const; inline PyObject* getSysModule (); inline PyObject* getHurricaneModule (); inline PyObject* getUserModule (); @@ -93,8 +93,14 @@ namespace Isobar { inline PyObject* Script::getHurricaneModule () { return _hurricaneModule; } inline PyObject* Script::getUserModule () { return _userModule; } - inline const char* Script::getFileName () const - { return (_userModule) ? PyModule_GetFilename(_userModule) : getUserModuleName().c_str(); } + inline std::string Script::getFileName () const + { + if (not _userModule) return getUserModuleName(); + PyObject* pyBytes = PyUnicode_AsASCIIString( PyModule_GetFilenameObject(_userModule) ); + std::string fileName = PyBytes_AsString( pyBytes ); + Py_DECREF( pyBytes ); + return fileName; + } inline PyObject* Script::_importHurricane ( unsigned int flags ) { return _hurricaneModule = _importModule("Hurricane",flags); }