Bug 109755 - -Wunused-function underline points at a class, not the unused method itself
Summary: -Wunused-function underline points at a class, not the unused method itself
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 14.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic
Depends on:
Blocks: Wunused
  Show dependency treegraph
 
Reported: 2023-05-06 07:17 UTC by Sergei Trofimovich
Modified: 2023-05-09 20:26 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2023-05-06 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sergei Trofimovich 2023-05-06 07:17:47 UTC
Noticed when reduced example manually. Was a bit confused by an underline under the class and not the method:

// $ cat a.cc
namespace {
    struct Foo {
        void m1();
        void m2();
    };
    void Foo::m1() {}
    void Foo::m2() {}
}

int main() {
    Foo o;
    o.m1();
}

$ gcc -c a.cc -Wall
a.cc:7:10: warning: 'void {anonymous}::Foo::m2()' defined but not used [-Wunused-function]
    7 |     void Foo::m2() {}
      |          ^~~

Here it's not visible, but m2 is correctly highlighted in 'void {anonymous}::Foo::m2()' string (good). But the underlying cursor points at the 'Foo' only. I think it should point at the whole 'Foo::m2' instead.

For example:

    7 |     void Foo::m2() {}
      |          ^~~~~~~

WDYT?

GCC is built from r14-539-g143e6695b20d35.

$ gcc -v
Using built-in specs.
COLLECT_GCC=/<<NIX>>/gcc-14.0.0/bin/gcc
COLLECT_LTO_WRAPPER=/<<NIX>>/gcc-14.0.0/libexec/gcc/x86_64-unknown-linux-gnu/14.0.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with:
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 14.0.0 99999999 (experimental) (GCC)
Comment 1 Andrew Pinski 2023-05-06 17:24:34 UTC
Confirmed, it is not just anonymous namespaces nor class methods..
Another example showing it happens with namespaces static functions too:
```
namespace g { static void f();}
static void g::f(){}
```