[Mlir-commits] [llvm] [mlir] eliminating g++ warnings (PR #105520)

David Blaikie llvmlistbot at llvm.org
Wed Aug 21 10:21:21 PDT 2024


================
@@ -1593,7 +1593,8 @@ foldTrait(Operation *, ArrayRef<Attribute>, SmallVectorImpl<OpFoldResult> &) {
 /// Given a tuple type containing a set of traits, return the result of folding
 /// the given operation.
 template <typename... Ts>
-static LogicalResult foldTraits(Operation *op, ArrayRef<Attribute> operands,
+static LogicalResult foldTraits([[maybe_unused]] Operation *op,
+                                [[maybe_unused]] ArrayRef<Attribute> operands,
----------------
dwblaikie wrote:

> in particular since the warning does not appear when I add an actually unused parameter.

I'm not sure what's meant by this ^ - that the unused parameter warning (in GCC or Clang?) doesn't work/fire correctly on something genuinely/totally unused, but for GCC it /does/ fire on something unused only when the pack is zero sized? That's super confusing.

Even with that aside, I'd say if GCC's warning has a false positive (warning on an "unused" variable when the pack expands to zero elements) - we should disable the GCC warning. We do this for other GCC warnings that have false positives compared to clang.

If it's been fixed in some version of GCC, we can conditionally enable (or conditionally disable) it, either based on the behavior of the warning (again, something we do when bugs get fixed in warnings) in cmake with a snippet of code to test the compiler behavior - or based on compiler version, I think, probably.

https://github.com/llvm/llvm-project/pull/105520


More information about the Mlir-commits mailing list