From 539e1395556c1a3df7c30f687b931acc7679780d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20=C5=9Aliwak?= Date: Wed, 1 Jun 2022 19:56:30 +0200 Subject: [PATCH] Add explicit throws after some assertions to work around a spurious warning in GCC 12.1 --- libsmtutil/CVC4Interface.cpp | 4 ++++ libsmtutil/Z3Interface.cpp | 7 +++++++ libsolidity/ast/ASTJsonImporter.cpp | 15 +++++++++++++++ libsolidity/parsing/Parser.cpp | 3 +++ libyul/AsmJsonImporter.cpp | 6 ++++++ libyul/backends/evm/StackHelpers.h | 3 +++ tools/yulPhaser/Phaser.cpp | 3 +++ 7 files changed, 41 insertions(+) diff --git a/libsmtutil/CVC4Interface.cpp b/libsmtutil/CVC4Interface.cpp index 8387b24cb..06a28890c 100644 --- a/libsmtutil/CVC4Interface.cpp +++ b/libsmtutil/CVC4Interface.cpp @@ -19,6 +19,7 @@ #include #include +#include #include @@ -289,6 +290,9 @@ CVC4::Expr CVC4Interface::toCVC4Expr(Expression const& _expr) } smtAssert(false, ""); + + // FIXME: Workaround for spurious GCC 12.1 warning (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105794) + throw exception(); } CVC4::Type CVC4Interface::cvc4Sort(Sort const& _sort) diff --git a/libsmtutil/Z3Interface.cpp b/libsmtutil/Z3Interface.cpp index a0d50d225..597d80c32 100644 --- a/libsmtutil/Z3Interface.cpp +++ b/libsmtutil/Z3Interface.cpp @@ -20,6 +20,7 @@ #include #include +#include #ifdef HAVE_Z3_DLOPEN #include @@ -271,6 +272,9 @@ z3::expr Z3Interface::toZ3Expr(Expression const& _expr) } smtAssert(false, ""); + + // FIXME: Workaround for spurious GCC 12.1 warning (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105794) + throw exception(); } Expression Z3Interface::fromZ3Expr(z3::expr const& _expr) @@ -379,6 +383,9 @@ Expression Z3Interface::fromZ3Expr(z3::expr const& _expr) return Expression(_expr.decl().name().str(), arguments, fromZ3Sort(_expr.get_sort())); smtAssert(false, ""); + + // FIXME: Workaround for spurious GCC 12.1 warning (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105794) + throw exception(); } z3::sort Z3Interface::z3Sort(Sort const& _sort) diff --git a/libsolidity/ast/ASTJsonImporter.cpp b/libsolidity/ast/ASTJsonImporter.cpp index 2f36cdead..859a93350 100644 --- a/libsolidity/ast/ASTJsonImporter.cpp +++ b/libsolidity/ast/ASTJsonImporter.cpp @@ -229,6 +229,9 @@ ASTPointer ASTJsonImporter::convertJsonToASTNode(Json::Value const& _js return createDocumentation(_json); else astAssert(false, "Unknown type of ASTNode: " + nodeType); + + // FIXME: Workaround for spurious GCC 12.1 warning (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105794) + throw exception(); } // ============ functions to instantiate the AST-Nodes from Json-Nodes ============== @@ -1073,6 +1076,9 @@ Visibility ASTJsonImporter::visibility(Json::Value const& _node) return Visibility::External; else astAssert(false, "Unknown visibility declaration"); + + // FIXME: Workaround for spurious GCC 12.1 warning (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105794) + throw exception(); } VariableDeclaration::Location ASTJsonImporter::location(Json::Value const& _node) @@ -1092,6 +1098,9 @@ VariableDeclaration::Location ASTJsonImporter::location(Json::Value const& _node return VariableDeclaration::Location::CallData; else astAssert(false, "Unknown location declaration"); + + // FIXME: Workaround for spurious GCC 12.1 warning (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105794) + throw exception(); } Literal::SubDenomination ASTJsonImporter::subdenomination(Json::Value const& _node) @@ -1125,6 +1134,9 @@ Literal::SubDenomination ASTJsonImporter::subdenomination(Json::Value const& _no return Literal::SubDenomination::Year; else astAssert(false, "Unknown subdenomination"); + + // FIXME: Workaround for spurious GCC 12.1 warning (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105794) + throw exception(); } StateMutability ASTJsonImporter::stateMutability(Json::Value const& _node) @@ -1142,6 +1154,9 @@ StateMutability ASTJsonImporter::stateMutability(Json::Value const& _node) return StateMutability::Payable; else astAssert(false, "Unknown stateMutability"); + + // FIXME: Workaround for spurious GCC 12.1 warning (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105794) + throw exception(); } } diff --git a/libsolidity/parsing/Parser.cpp b/libsolidity/parsing/Parser.cpp index 7bf0de045..ae1980477 100644 --- a/libsolidity/parsing/Parser.cpp +++ b/libsolidity/parsing/Parser.cpp @@ -1653,6 +1653,9 @@ ASTPointer Parser::parseSimpleStatement(ASTPointer const& solAssert(false, ""); } } + + // FIXME: Workaround for spurious GCC 12.1 warning (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105794) + throw exception(); } bool Parser::IndexAccessedPath::empty() const diff --git a/libyul/AsmJsonImporter.cpp b/libyul/AsmJsonImporter.cpp index 8fb4eaeb3..1f108145f 100644 --- a/libyul/AsmJsonImporter.cpp +++ b/libyul/AsmJsonImporter.cpp @@ -110,6 +110,9 @@ Statement AsmJsonImporter::createStatement(Json::Value const& _node) return createBlock(_node); else yulAssert(false, "Invalid nodeType as statement"); + + // FIXME: Workaround for spurious GCC 12.1 warning (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105794) + throw exception(); } Expression AsmJsonImporter::createExpression(Json::Value const& _node) @@ -129,6 +132,9 @@ Expression AsmJsonImporter::createExpression(Json::Value const& _node) return createLiteral(_node); else yulAssert(false, "Invalid nodeType as expression"); + + // FIXME: Workaround for spurious GCC 12.1 warning (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105794) + throw exception(); } vector AsmJsonImporter::createExpressionVector(Json::Value const& _array) diff --git a/libyul/backends/evm/StackHelpers.h b/libyul/backends/evm/StackHelpers.h index a0a942860..ff8887b24 100644 --- a/libyul/backends/evm/StackHelpers.h +++ b/libyul/backends/evm/StackHelpers.h @@ -371,6 +371,9 @@ private: return true; } yulAssert(false, ""); + + // FIXME: Workaround for spurious GCC 12.1 warning (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105794) + throw std::exception(); } }; diff --git a/tools/yulPhaser/Phaser.cpp b/tools/yulPhaser/Phaser.cpp index ffcbd1d5e..c49d9a2d8 100644 --- a/tools/yulPhaser/Phaser.cpp +++ b/tools/yulPhaser/Phaser.cpp @@ -276,6 +276,9 @@ unique_ptr FitnessMetricFactory::build( default: assertThrow(false, solidity::util::Exception, "Invalid MetricAggregatorChoice value."); } + + // FIXME: Workaround for spurious GCC 12.1 warning (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105794) + throw exception(); } PopulationFactory::Options PopulationFactory::Options::fromCommandLine(po::variables_map const& _arguments)