[PATCH] D100581: [Clang] -Wunused-but-set-parameter and -Wunused-but-set-variable

Dávid Bolvanský via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 19 17:33:05 PDT 2021


xbolva00 added a comment.

So.... I checked gcc on godbolt since gcc docs are not so clear.

UnusedButSetParameter is ignored with:

- -Wunused alone
- -Wextra alone
- -Wall -Wunused

But works with -Wextra -Wunused or  -Wall -Wextra.

So I think we should put UnusedButSetParameter under -Wextra

  def Extra : DiagGroup<"extra", [
      DeprecatedCopy,
      MissingFieldInitializers,
      IgnoredQualifiers,
      InitializerOverrides,
      SemiBeforeMethodBody,
      MissingMethodReturnType,
      SignCompare,
      UnusedButSetParameter
      UnusedParameter,
      NullPointerArithmetic,
      EmptyInitStatement,
      StringConcatation,
      FUseLdPath,
    ]>;

UnusedButSetVariable is part of -Wall and -Wunused (gcc's -Wunused is enabled by -Wall.)

So I would just put UnusedButSetVariable under -Wunused (and -Wunused is part of -Wall):

  def Unused : DiagGroup<"unused",
                         [UnusedArgument, UnusedButSetVariable,
                          UnusedFunction, UnusedLabel,
                          // UnusedParameter, (matches GCC's behavior)
                          // UnusedTemplate, (clean-up libc++ before enabling)
                          // UnusedMemberFunction, (clean-up llvm before enabling)
                          UnusedPrivateField, UnusedLambdaCapture,
                          UnusedLocalTypedef, UnusedValue, UnusedVariable,
                          UnusedPropertyIvar]>,
                          DiagCategory<"Unused Entity Issue">;

WDYT?



================
Comment at: clang/test/Sema/warn-unused-but-set-variables-cpp.cpp:1
+// RUN: %clang_cc1 -fblocks -fsyntax-only -Wunused-but-set-variable -verify %s
+
----------------
I would suggest move it to clang/test/SemaCXX/warn-unused-but-set-variables.cpp


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100581/new/

https://reviews.llvm.org/D100581



More information about the cfe-commits mailing list