Skip to content

Commit 539e139

Browse files
committed
Add explicit throws after some assertions to work around a spurious warning in GCC 12.1
1 parent f5e421f commit 539e139

File tree

7 files changed

+41
-0
lines changed

7 files changed

+41
-0
lines changed

libsmtutil/CVC4Interface.cpp

Lines changed: 4 additions & 0 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

@@ -289,6 +290,9 @@ CVC4::Expr CVC4Interface::toCVC4Expr(Expression const& _expr)
289290
}
290291

291292
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: 7 additions & 0 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>
@@ -271,6 +272,9 @@ z3::expr Z3Interface::toZ3Expr(Expression const& _expr)
271272
}
272273

273274
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)
@@ -379,6 +383,9 @@ Expression Z3Interface::fromZ3Expr(z3::expr const& _expr)
379383
return Expression(_expr.decl().name().str(), arguments, fromZ3Sort(_expr.get_sort()));
380384

381385
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: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1653,6 +1653,9 @@ ASTPointer<Statement> Parser::parseSimpleStatement(ASTPointer<ASTString> const&
16531653
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

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)