Skip to content

Commit

Permalink
Merge pull request ethereum#13087 from ethereum/gcc-12-control-reache…
Browse files Browse the repository at this point in the history
…s-end-of-function-warning-workaround

Workaround for the spurious `control reaches end of non-void function` warning in GCC 12.1
  • Loading branch information
cameel authored Jun 2, 2022
2 parents 3f84837 + e19e6ad commit 1f8b8c9
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 10 deletions.
8 changes: 6 additions & 2 deletions libsmtutil/CVC4Interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <libsmtutil/CVC4Interface.h>

#include <libsolutil/CommonIO.h>
#include <libsolutil/Exceptions.h>

#include <cvc4/util/bitvector.h>

Expand Down Expand Up @@ -277,7 +278,7 @@ CVC4::Expr CVC4Interface::toCVC4Expr(Expression const& _expr)
return m_context.mkExpr(CVC4::kind::APPLY_CONSTRUCTOR, c, arguments);
}

smtAssert(false, "");
smtAssert(false);
}
catch (CVC4::TypeCheckingException const& _e)
{
Expand All @@ -288,7 +289,10 @@ CVC4::Expr CVC4Interface::toCVC4Expr(Expression const& _expr)
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)
Expand Down
13 changes: 10 additions & 3 deletions libsmtutil/Z3Interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#include <libsolutil/CommonData.h>
#include <libsolutil/CommonIO.h>
#include <libsolutil/Exceptions.h>

#ifdef HAVE_Z3_DLOPEN
#include <libsmtutil/Z3Loader.h>
Expand Down Expand Up @@ -263,14 +264,17 @@ z3::expr Z3Interface::toZ3Expr(Expression const& _expr)
return constructor(args);
}

smtAssert(false, "");
smtAssert(false);
}
catch (z3::exception const& _e)
{
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)
Expand Down Expand Up @@ -378,7 +382,10 @@ Expression Z3Interface::fromZ3Expr(z3::expr const& _expr)
)
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)
Expand Down
15 changes: 15 additions & 0 deletions libsolidity/ast/ASTJsonImporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,9 @@ ASTPointer<ASTNode> 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 ==============
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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();
}

}
12 changes: 7 additions & 5 deletions libsolidity/parsing/Parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1637,7 +1637,7 @@ ASTPointer<Statement> Parser::parseSimpleStatement(ASTPointer<ASTString> const&
return parseExpressionStatement(_docString, nodeFactory.createNode<TupleExpression>(components, false));
}
default:
solAssert(false, "");
solAssert(false);
}
}
else
Expand All @@ -1650,17 +1650,19 @@ ASTPointer<Statement> Parser::parseSimpleStatement(ASTPointer<ASTString> const&
case LookAheadInfo::Expression:
return parseExpressionStatement(_docString, expressionFromIndexAccessStructure(iap));
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
{
if (!indices.empty())
{
solAssert(!path.empty(), "");
}
solAssert(!path.empty());

return path.empty() && indices.empty();
}

Expand Down
6 changes: 6 additions & 0 deletions libyul/AsmJsonImporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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<Expression> AsmJsonImporter::createExpressionVector(Json::Value const& _array)
Expand Down
3 changes: 3 additions & 0 deletions libyul/backends/evm/StackHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,9 @@ class Shuffler
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();
}
};

Expand Down
3 changes: 3 additions & 0 deletions tools/yulPhaser/Phaser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,9 @@ unique_ptr<FitnessMetric> 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)
Expand Down

0 comments on commit 1f8b8c9

Please sign in to comment.