Skip to content

Commit 10249a7

Browse files
committed
rust: silence warnings
1 parent e12ab86 commit 10249a7

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

Diff for: rust/rust.cc

+10-2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
namespace {
2323
USING_NEXTPNR_NAMESPACE;
2424

25+
// `memcpy` is used here to avoid strict-aliasing problems, but GCC dislikes it.
26+
#pragma GCC diagnostic push
27+
#pragma GCC diagnostic ignored "-Wclass-memaccess"
2528
template<typename T>
2629
uint64_t wrap(T thing) {
2730
static_assert(sizeof(T) <= 8, "T is too big for FFI");
@@ -50,6 +53,7 @@ namespace {
5053
memcpy(&w, &wire, sizeof(WireId));
5154
return w;
5255
}
56+
#pragma GCC diagnostic pop
5357
}
5458

5559
using DownhillIter = decltype(Context(ArchArgs()).getPipsDownhill(WireId()).begin());
@@ -99,8 +103,10 @@ extern "C" {
99103

100104
uint64_t npnr_context_get_pips_leak(const Context *ctx, uint64_t **pips) {
101105
auto size = size_t{};
102-
for (auto _pip : ctx->getPips())
106+
for (auto _pip : ctx->getPips()) {
107+
NPNR_UNUSED(_pip);
103108
size++;
109+
}
104110
*pips = new uint64_t[size];
105111
auto idx = 0;
106112
for (auto pip : ctx->getPips()) {
@@ -113,8 +119,10 @@ extern "C" {
113119

114120
uint64_t npnr_context_get_wires_leak(const Context *ctx, uint64_t **wires) {
115121
auto size = size_t{};
116-
for (auto _wire : ctx->getWires())
122+
for (auto _wire : ctx->getWires()) {
123+
NPNR_UNUSED(_wire);
117124
size++;
125+
}
118126
*wires = new uint64_t[size];
119127
auto idx = 0;
120128
for (auto wire : ctx->getWires()) {

0 commit comments

Comments
 (0)