[LLVMbugs] [Bug 8752] New: Clang -Wunused should warn on unusable (member) functions.

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Dec 7 04:52:06 PST 2010


           Summary: Clang -Wunused should warn on unusable (member)
           Product: new-bugs
           Version: trunk
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: fvbommel at gmail.com
                CC: llvmbugs at cs.uiuc.edu

-Wunused (or -Wunused-function) should produce warnings for (member) functions
that can't possibly be used, for instance because their return value or one of
their parameters (including 'this') contains a class type declared in an
anonymous namespace. (extern "C" functions should probably be exempt)

Some examples:
// From some .h file.
class Bar {
  virtual void frob();

// From some .cpp file.
namespace {
  // Because Foo is in an anonymous namespace, newly-introduced members
  // can't be used from different translation units.
  class Foo : public Bar {
    virtual void frob() {
      // May be used externally.

    int quux() {
      // Unused, but doesn't produce warning.
      return 1;

    static int baz() {
      // Unused, but doesn't produce warning.
      return 2;

  // Unused, produces warning.
  Bar* getAnonNSBar() { return new Foo; }

// Unused, produces warning.
static Bar* getStaticBar() { return new Foo; }

// Unused, but doesn't produce warning.
Foo* getFoo() { return new Foo; }

// May be used externally.
Bar* getBar() { return new Foo; }

Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

More information about the llvm-bugs mailing list