Merge pull request #13087 from ethereum/gcc-12-control-reaches-end-of-function-warning-workaround

Workaround for the spurious `control reaches end of non-void function` warning in GCC 12.1
This commit is contained in:
Kamil Śliwak 2022-06-02 14:59:01 +02:00 committed by GitHub
commit 1f8b8c98d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 50 additions and 10 deletions

View File

@ -19,6 +19,7 @@
#include <libsmtutil/CVC4Interface.h> #include <libsmtutil/CVC4Interface.h>
#include <libsolutil/CommonIO.h> #include <libsolutil/CommonIO.h>
#include <libsolutil/Exceptions.h>
#include <cvc4/util/bitvector.h> #include <cvc4/util/bitvector.h>
@ -277,7 +278,7 @@ CVC4::Expr CVC4Interface::toCVC4Expr(Expression const& _expr)
return m_context.mkExpr(CVC4::kind::APPLY_CONSTRUCTOR, c, arguments); return m_context.mkExpr(CVC4::kind::APPLY_CONSTRUCTOR, c, arguments);
} }
smtAssert(false, ""); smtAssert(false);
} }
catch (CVC4::TypeCheckingException const& _e) catch (CVC4::TypeCheckingException const& _e)
{ {
@ -288,7 +289,10 @@ CVC4::Expr CVC4Interface::toCVC4Expr(Expression const& _expr)
smtAssert(false, _e.what()); smtAssert(false, _e.what());
} }
smtAssert(false, ""); 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) CVC4::Type CVC4Interface::cvc4Sort(Sort const& _sort)

View File

@ -20,6 +20,7 @@
#include <libsolutil/CommonData.h> #include <libsolutil/CommonData.h>
#include <libsolutil/CommonIO.h> #include <libsolutil/CommonIO.h>
#include <libsolutil/Exceptions.h>
#ifdef HAVE_Z3_DLOPEN #ifdef HAVE_Z3_DLOPEN
#include <libsmtutil/Z3Loader.h> #include <libsmtutil/Z3Loader.h>
@ -263,14 +264,17 @@ z3::expr Z3Interface::toZ3Expr(Expression const& _expr)
return constructor(args); return constructor(args);
} }
smtAssert(false, ""); smtAssert(false);
} }
catch (z3::exception const& _e) catch (z3::exception const& _e)
{ {
smtAssert(false, _e.msg()); smtAssert(false, _e.msg());
} }
smtAssert(false, ""); 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) Expression Z3Interface::fromZ3Expr(z3::expr const& _expr)
@ -378,7 +382,10 @@ Expression Z3Interface::fromZ3Expr(z3::expr const& _expr)
) )
return Expression(_expr.decl().name().str(), arguments, fromZ3Sort(_expr.get_sort())); return Expression(_expr.decl().name().str(), arguments, fromZ3Sort(_expr.get_sort()));
smtAssert(false, ""); 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) z3::sort Z3Interface::z3Sort(Sort const& _sort)

View File

@ -229,6 +229,9 @@ ASTPointer<ASTNode> ASTJsonImporter::convertJsonToASTNode(Json::Value const& _js
return createDocumentation(_json); return createDocumentation(_json);
else else
astAssert(false, "Unknown type of ASTNode: " + nodeType); 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 ============== // ============ functions to instantiate the AST-Nodes from Json-Nodes ==============
@ -1073,6 +1076,9 @@ Visibility ASTJsonImporter::visibility(Json::Value const& _node)
return Visibility::External; return Visibility::External;
else else
astAssert(false, "Unknown visibility declaration"); 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) VariableDeclaration::Location ASTJsonImporter::location(Json::Value const& _node)
@ -1092,6 +1098,9 @@ VariableDeclaration::Location ASTJsonImporter::location(Json::Value const& _node
return VariableDeclaration::Location::CallData; return VariableDeclaration::Location::CallData;
else else
astAssert(false, "Unknown location declaration"); 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) Literal::SubDenomination ASTJsonImporter::subdenomination(Json::Value const& _node)
@ -1125,6 +1134,9 @@ Literal::SubDenomination ASTJsonImporter::subdenomination(Json::Value const& _no
return Literal::SubDenomination::Year; return Literal::SubDenomination::Year;
else else
astAssert(false, "Unknown subdenomination"); 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) StateMutability ASTJsonImporter::stateMutability(Json::Value const& _node)
@ -1142,6 +1154,9 @@ StateMutability ASTJsonImporter::stateMutability(Json::Value const& _node)
return StateMutability::Payable; return StateMutability::Payable;
else else
astAssert(false, "Unknown stateMutability"); astAssert(false, "Unknown stateMutability");
// FIXME: Workaround for spurious GCC 12.1 warning (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105794)
throw exception();
} }
} }

View File

@ -1637,7 +1637,7 @@ ASTPointer<Statement> Parser::parseSimpleStatement(ASTPointer<ASTString> const&
return parseExpressionStatement(_docString, nodeFactory.createNode<TupleExpression>(components, false)); return parseExpressionStatement(_docString, nodeFactory.createNode<TupleExpression>(components, false));
} }
default: default:
solAssert(false, ""); solAssert(false);
} }
} }
else else
@ -1650,17 +1650,19 @@ ASTPointer<Statement> Parser::parseSimpleStatement(ASTPointer<ASTString> const&
case LookAheadInfo::Expression: case LookAheadInfo::Expression:
return parseExpressionStatement(_docString, expressionFromIndexAccessStructure(iap)); return parseExpressionStatement(_docString, expressionFromIndexAccessStructure(iap));
default: default:
solAssert(false, ""); 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 bool Parser::IndexAccessedPath::empty() const
{ {
if (!indices.empty()) if (!indices.empty())
{ solAssert(!path.empty());
solAssert(!path.empty(), "");
}
return path.empty() && indices.empty(); return path.empty() && indices.empty();
} }

View File

@ -110,6 +110,9 @@ Statement AsmJsonImporter::createStatement(Json::Value const& _node)
return createBlock(_node); return createBlock(_node);
else else
yulAssert(false, "Invalid nodeType as statement"); 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) Expression AsmJsonImporter::createExpression(Json::Value const& _node)
@ -129,6 +132,9 @@ Expression AsmJsonImporter::createExpression(Json::Value const& _node)
return createLiteral(_node); return createLiteral(_node);
else else
yulAssert(false, "Invalid nodeType as expression"); 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<Expression> AsmJsonImporter::createExpressionVector(Json::Value const& _array) vector<Expression> AsmJsonImporter::createExpressionVector(Json::Value const& _array)

View File

@ -371,6 +371,9 @@ private:
return true; return true;
} }
yulAssert(false, ""); yulAssert(false, "");
// FIXME: Workaround for spurious GCC 12.1 warning (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105794)
throw std::exception();
} }
}; };

View File

@ -276,6 +276,9 @@ unique_ptr<FitnessMetric> FitnessMetricFactory::build(
default: default:
assertThrow(false, solidity::util::Exception, "Invalid MetricAggregatorChoice value."); 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) PopulationFactory::Options PopulationFactory::Options::fromCommandLine(po::variables_map const& _arguments)