Skip to content

Commit

Permalink
Fix warnings in compilation using clang 15 (#3904)
Browse files Browse the repository at this point in the history
* Eliminate unused variables that breaks -Werror in clang 15
* Supress unused-but-set warning in p4parser
  • Loading branch information
vlstill authored Feb 22, 2023
1 parent 19500bc commit 07fad1f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 0 additions & 2 deletions backends/dpdk/dpdkContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,6 @@ Util::JsonObject *DpdkContextGenerator::addMatchAttributes(const IR::P4Table *ta
auto *immFldArray = new Util::JsonArray();
if (attr.params) {
int index = 0;
int position = 0;
int param_width = 8; // Minimum width for dpdk action params
for (auto param : *(attr.params)) {
if (param->type->is<IR::Type_Bits>()) {
Expand All @@ -346,7 +345,6 @@ Util::JsonObject *DpdkContextGenerator::addMatchAttributes(const IR::P4Table *ta
}
addImmediateField(immFldArray, param->name.originalName, index / 8, param_width);
index += param_width;
position++;
}
}
oneAction->emplace("immediate_fields", immFldArray);
Expand Down
2 changes: 0 additions & 2 deletions backends/ubpf/ubpfTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,6 @@ void UBPFTable::emitKeyType(EBPF::CodeBuilder *builder) {
if (keyGenerator != nullptr) {
// Use this to order elements by size
std::multimap<size_t, const IR::KeyElement *> ordered;
unsigned fieldNumber = 0;
for (auto c : keyGenerator->keyElements) {
auto type = program->typeMap->getType(c->expression);
auto ebpfType = UBPFTypeFactory::instance->create(type);
Expand All @@ -259,7 +258,6 @@ void UBPFTable::emitKeyType(EBPF::CodeBuilder *builder) {
ordered.emplace(width, c);
keyTypes.emplace(c, ebpfType);
keyFieldNames.emplace(c, fieldName);
fieldNumber++;
}

// Emit key in decreasing order size - this way there will be no gaps
Expand Down
6 changes: 6 additions & 0 deletions frontends/parsers/p4/p4parser.ypp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ limitations under the License.
#include "lib/cstring.h"
#include "lib/source_file.h"

#ifdef __clang__
#if __clang_major__ >= 13
#pragma clang diagnostic ignored "-Wunused-but-set-variable"
#endif
#endif

namespace P4 {
class AbstractP4Lexer;
class P4ParserDriver;
Expand Down

0 comments on commit 07fad1f

Please sign in to comment.