diff --git a/src/compiler-support.h b/src/compiler-support.h index a3485919086..3082ab3dfa1 100644 --- a/src/compiler-support.h +++ b/src/compiler-support.h @@ -31,4 +31,10 @@ #define WASM_BUILTIN_UNREACHABLE __assume(false) #endif +#if defined(__GNUC__) || defined(__clang__) +#define BYN_WARN_UNUSED [[gnu::warn_unused]] +#else +#define BYN_WARN_UNUSED +#endif + #endif // wasm_compiler_support_h diff --git a/src/ir/possible-contents.cpp b/src/ir/possible-contents.cpp index f5bdb46fc09..f752fa10172 100644 --- a/src/ir/possible-contents.cpp +++ b/src/ir/possible-contents.cpp @@ -898,7 +898,6 @@ struct InfoCollector } void visitCall(Call* curr) { - Name targetName; if (!Intrinsics(*getModule()).isCallWithoutEffects(curr)) { // This is just a normal call. handleDirectCall(curr, curr->target); diff --git a/src/support/istring.h b/src/support/istring.h index bc7d2380dd2..458c8b47c6e 100644 --- a/src/support/istring.h +++ b/src/support/istring.h @@ -31,7 +31,7 @@ namespace wasm { -struct IString { +struct BYN_WARN_UNUSED IString { private: static const char* interned(std::string_view s); diff --git a/src/support/name.h b/src/support/name.h index d6c71f732c9..2d22f8ad1cb 100644 --- a/src/support/name.h +++ b/src/support/name.h @@ -31,7 +31,7 @@ namespace wasm { // TODO: as an optimization, IString values < some threshold could be considered // numerical indices directly. -struct Name : public IString { +struct BYN_WARN_UNUSED Name : public IString { Name() : IString() {} Name(std::string_view str) : IString(str) {} Name(const char* str) : IString(str) {} diff --git a/src/tools/wasm-ctor-eval.cpp b/src/tools/wasm-ctor-eval.cpp index 42cd1097623..f5b05c98220 100644 --- a/src/tools/wasm-ctor-eval.cpp +++ b/src/tools/wasm-ctor-eval.cpp @@ -1540,8 +1540,6 @@ static bool canEval(Module& wasm) { // int main(int argc, const char* argv[]) { - Name entry; - std::vector passes; bool emitBinary = true; bool debugInfo = false; String::Split ctors; diff --git a/src/tools/wasm-metadce.cpp b/src/tools/wasm-metadce.cpp index f0647a4c337..3f7c44cc5d4 100644 --- a/src/tools/wasm-metadce.cpp +++ b/src/tools/wasm-metadce.cpp @@ -416,8 +416,6 @@ struct MetaDCEGraph { // int main(int argc, const char* argv[]) { - Name entry; - std::vector passes; bool emitBinary = true; bool debugInfo = false; std::string graphFile; diff --git a/src/tools/wasm-opt.cpp b/src/tools/wasm-opt.cpp index ef85804963c..94d72181cac 100644 --- a/src/tools/wasm-opt.cpp +++ b/src/tools/wasm-opt.cpp @@ -74,7 +74,6 @@ willRemoveDebugInfo(const std::vector& passes) { // int main(int argc, const char* argv[]) { - Name entry; bool emitBinary = true; bool converge = false; bool fuzzExecBefore = false; diff --git a/src/tools/wasm-shell.cpp b/src/tools/wasm-shell.cpp index ca864998714..e33400320af 100644 --- a/src/tools/wasm-shell.cpp +++ b/src/tools/wasm-shell.cpp @@ -655,9 +655,6 @@ struct Shell { }; int main(int argc, const char* argv[]) { - Name entry; - std::set skipped; - // Read stdin by default. std::string infile = "-"; Options options("wasm-shell", "Execute .wast files");