Skip to content

Commit 1f8b8c9

Browse files
authored
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
2 parents 3f84837 + e19e6ad commit 1f8b8c9

File tree

7 files changed

+50
-10
lines changed

7 files changed

+50
-10
lines changed

libsmtutil/CVC4Interface.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <libsmtutil/CVC4Interface.h>
2020

2121
#include <libsolutil/CommonIO.h>
22+
#include <libsolutil/Exceptions.h>
2223

2324
#include <cvc4/util/bitvector.h>
2425

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

280-
smtAssert(false, "");
281+
smtAssert(false);
281282
}
282283
catch (CVC4::TypeCheckingException const& _e)
283284
{
@@ -288,7 +289,10 @@ CVC4::Expr CVC4Interface::toCVC4Expr(Expression const& _expr)
288289
smtAssert(false, _e.what());
289290
}
290291

291-
smtAssert(false, "");
292+
smtAssert(false);
293+
294+
// FIXME: Workaround for spurious GCC 12.1 warning (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105794)
295+
throw exception();
292296
}
293297

294298
CVC4::Type CVC4Interface::cvc4Sort(Sort const& _sort)

libsmtutil/Z3Interface.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
#include <libsolutil/CommonData.h>
2222
#include <libsolutil/CommonIO.h>
23+
#include <libsolutil/Exceptions.h>
2324

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

266-
smtAssert(false, "");
267+
smtAssert(false);
267268
}
268269
catch (z3::exception const& _e)
269270
{
270271
smtAssert(false, _e.msg());
271272
}
272273

273-
smtAssert(false, "");
274+
smtAssert(false);
275+
276+
// FIXME: Workaround for spurious GCC 12.1 warning (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105794)
277+
throw exception();
274278
}
275279

276280
Expression Z3Interface::fromZ3Expr(z3::expr const& _expr)
@@ -378,7 +382,10 @@ Expression Z3Interface::fromZ3Expr(z3::expr const& _expr)
378382
)
379383
return Expression(_expr.decl().name().str(), arguments, fromZ3Sort(_expr.get_sort()));
380384

381-
smtAssert(false, "");
385+
smtAssert(false);
386+
387+
// FIXME: Workaround for spurious GCC 12.1 warning (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105794)
388+
throw exception();
382389
}
383390

384391
z3::sort Z3Interface::z3Sort(Sort const& _sort)

libsolidity/ast/ASTJsonImporter.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,9 @@ ASTPointer<ASTNode> ASTJsonImporter::convertJsonToASTNode(Json::Value const& _js
229229
return createDocumentation(_json);
230230
else
231231
astAssert(false, "Unknown type of ASTNode: " + nodeType);
232+
233+
// FIXME: Workaround for spurious GCC 12.1 warning (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105794)
234+
throw exception();
232235
}
233236

234237
// ============ functions to instantiate the AST-Nodes from Json-Nodes ==============
@@ -1073,6 +1076,9 @@ Visibility ASTJsonImporter::visibility(Json::Value const& _node)
10731076
return Visibility::External;
10741077
else
10751078
astAssert(false, "Unknown visibility declaration");
1079+
1080+
// FIXME: Workaround for spurious GCC 12.1 warning (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105794)
1081+
throw exception();
10761082
}
10771083

10781084
VariableDeclaration::Location ASTJsonImporter::location(Json::Value const& _node)
@@ -1092,6 +1098,9 @@ VariableDeclaration::Location ASTJsonImporter::location(Json::Value const& _node
10921098
return VariableDeclaration::Location::CallData;
10931099
else
10941100
astAssert(false, "Unknown location declaration");
1101+
1102+
// FIXME: Workaround for spurious GCC 12.1 warning (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105794)
1103+
throw exception();
10951104
}
10961105

10971106
Literal::SubDenomination ASTJsonImporter::subdenomination(Json::Value const& _node)
@@ -1125,6 +1134,9 @@ Literal::SubDenomination ASTJsonImporter::subdenomination(Json::Value const& _no
11251134
return Literal::SubDenomination::Year;
11261135
else
11271136
astAssert(false, "Unknown subdenomination");
1137+
1138+
// FIXME: Workaround for spurious GCC 12.1 warning (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105794)
1139+
throw exception();
11281140
}
11291141

11301142
StateMutability ASTJsonImporter::stateMutability(Json::Value const& _node)
@@ -1142,6 +1154,9 @@ StateMutability ASTJsonImporter::stateMutability(Json::Value const& _node)
11421154
return StateMutability::Payable;
11431155
else
11441156
astAssert(false, "Unknown stateMutability");
1157+
1158+
// FIXME: Workaround for spurious GCC 12.1 warning (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105794)
1159+
throw exception();
11451160
}
11461161

11471162
}

libsolidity/parsing/Parser.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1637,7 +1637,7 @@ ASTPointer<Statement> Parser::parseSimpleStatement(ASTPointer<ASTString> const&
16371637
return parseExpressionStatement(_docString, nodeFactory.createNode<TupleExpression>(components, false));
16381638
}
16391639
default:
1640-
solAssert(false, "");
1640+
solAssert(false);
16411641
}
16421642
}
16431643
else
@@ -1650,17 +1650,19 @@ ASTPointer<Statement> Parser::parseSimpleStatement(ASTPointer<ASTString> const&
16501650
case LookAheadInfo::Expression:
16511651
return parseExpressionStatement(_docString, expressionFromIndexAccessStructure(iap));
16521652
default:
1653-
solAssert(false, "");
1653+
solAssert(false);
16541654
}
16551655
}
1656+
1657+
// FIXME: Workaround for spurious GCC 12.1 warning (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105794)
1658+
throw exception();
16561659
}
16571660

16581661
bool Parser::IndexAccessedPath::empty() const
16591662
{
16601663
if (!indices.empty())
1661-
{
1662-
solAssert(!path.empty(), "");
1663-
}
1664+
solAssert(!path.empty());
1665+
16641666
return path.empty() && indices.empty();
16651667
}
16661668

libyul/AsmJsonImporter.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ Statement AsmJsonImporter::createStatement(Json::Value const& _node)
110110
return createBlock(_node);
111111
else
112112
yulAssert(false, "Invalid nodeType as statement");
113+
114+
// FIXME: Workaround for spurious GCC 12.1 warning (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105794)
115+
throw exception();
113116
}
114117

115118
Expression AsmJsonImporter::createExpression(Json::Value const& _node)
@@ -129,6 +132,9 @@ Expression AsmJsonImporter::createExpression(Json::Value const& _node)
129132
return createLiteral(_node);
130133
else
131134
yulAssert(false, "Invalid nodeType as expression");
135+
136+
// FIXME: Workaround for spurious GCC 12.1 warning (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105794)
137+
throw exception();
132138
}
133139

134140
vector<Expression> AsmJsonImporter::createExpressionVector(Json::Value const& _array)

libyul/backends/evm/StackHelpers.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,9 @@ class Shuffler
371371
return true;
372372
}
373373
yulAssert(false, "");
374+
375+
// FIXME: Workaround for spurious GCC 12.1 warning (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105794)
376+
throw std::exception();
374377
}
375378
};
376379

tools/yulPhaser/Phaser.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,9 @@ unique_ptr<FitnessMetric> FitnessMetricFactory::build(
276276
default:
277277
assertThrow(false, solidity::util::Exception, "Invalid MetricAggregatorChoice value.");
278278
}
279+
280+
// FIXME: Workaround for spurious GCC 12.1 warning (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105794)
281+
throw exception();
279282
}
280283

281284
PopulationFactory::Options PopulationFactory::Options::fromCommandLine(po::variables_map const& _arguments)

0 commit comments

Comments
 (0)