[Bug c++/80916] [7/8/9 Regression] Spurious "declared 'static' but never defined" warning

2019-03-07 Thread jason at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80916

--- Comment #12 from Jason Merrill  ---
Author: jason
Date: Thu Mar  7 15:10:22 2019
New Revision: 269459

URL: https://gcc.gnu.org/viewcvs?rev=269459=gcc=rev
Log:
PR c++/80916 - spurious "static but not defined" warning.

Nothing can refer to an internal decl with no definition, so we shouldn't
treat such a decl as a possible devirtualization target.

* gimple-fold.c (can_refer_decl_in_current_unit_p): Return false
for an internal symbol with DECL_EXTERNAL.

Added:
trunk/gcc/testsuite/g++.dg/warn/unused-fn1.C
Modified:
trunk/gcc/ChangeLog
trunk/gcc/gimple-fold.c

[Bug c++/80916] [7/8/9 Regression] Spurious "declared 'static' but never defined" warning

2019-02-27 Thread jason at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80916

Jason Merrill  changed:

   What|Removed |Added

 CC||hubicka at gcc dot gnu.org

--- Comment #11 from Jason Merrill  ---
Patch still waiting for review.

[Bug c++/80916] [7/8/9 Regression] Spurious "declared 'static' but never defined" warning

2019-01-27 Thread jason at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80916

Jason Merrill  changed:

   What|Removed |Added

   Keywords||patch

--- Comment #10 from Jason Merrill  ---
Patch posted: https://gcc.gnu.org/ml/gcc-patches/2019-01/msg01512.html

[Bug c++/80916] [7/8/9 Regression] Spurious "declared 'static' but never defined" warning

2019-01-25 Thread jason at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80916

--- Comment #9 from Jason Merrill  ---
It has internal linkage because one of its template arguments is a local class,
and it isn't instantiated because it isn't ever used.  It's added to cgraph as
a possible devirtualization target.

I think the last of these is the place to attack this issue, since it's also
the source of the regression.

[Bug c++/80916] [7/8/9 Regression] Spurious "declared 'static' but never defined" warning

2019-01-24 Thread jason at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80916

Jason Merrill  changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
   Assignee|unassigned at gcc dot gnu.org  |jason at gcc dot gnu.org

[Bug c++/80916] [7/8/9 Regression] Spurious "declared 'static' but never defined" warning

2019-01-08 Thread davmac at davmac dot org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80916

--- Comment #8 from Davin McCall  ---
(In reply to ensadc from comment #7)
> Note that the "never defined" part is also misleading: the warning persists
> when `i::dispatch` does have a definition

Yes; and actually, I note that in the original test case I supplied, the
dispatch function doesn't have a definition, but it doesn't have internal
linkage either.

So, I think the warning really is spurious and it's not just a case of it
saying "declared static" where it should say "has internal linkage".

[Bug c++/80916] [7/8/9 Regression] Spurious "declared 'static' but never defined" warning

2019-01-08 Thread ensadc at mailnesia dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80916

--- Comment #7 from ensadc at mailnesia dot com ---
Note that the "never defined" part is also misleading: the warning persists
when `i::dispatch` does have a definition
(https://wandbox.org/permlink/MKif1shXFjt7aT6C):

struct j {
  virtual void dispatch(void *) {}
};
template 
struct i : j {
  void dispatch(void *) {} // warning: 'void i< 
>::dispatch(void*) [with  = {anonymous}::l]' declared
'static' but never defined [-Wunused-function]
};
namespace {
struct l : i {};
}
void f(j *k) {
  k->dispatch(0);
}

[Bug c++/80916] [7/8/9 Regression] Spurious "declared 'static' but never defined" warning

2019-01-07 Thread davmac at davmac dot org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80916

--- Comment #6 from Davin McCall  ---
> The wording could be improved, but why do you think the warning is spurious?

I guess I think that the warning is spurious given the current wording? It may
well be legitimate to warn that there is a declaration of a function with
internal linkage but no definition, which may be what triggered this warning
originally (it no longer triggers in my current code base, so I can't easily
verify). But that's not what the warning does say.

If you'd prefer to change the title to reflect that the wording of the warning
doesn't match its cause, I have no issue with that.

[Bug c++/80916] [7/8/9 Regression] Spurious "declared 'static' but never defined" warning

2019-01-07 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80916

Jakub Jelinek  changed:

   What|Removed |Added

 CC||jakub at gcc dot gnu.org,
   ||jason at gcc dot gnu.org

--- Comment #5 from Jakub Jelinek  ---
The wording could be improved, but why do you think the warning is spurious?

While the method isn't static, it is effectively static, because it is internal
linkage (i.e. visibility constrained to the current TU in which it is not
really defined).  If you ask for -Wunused-function, you get it if the compiler
can figure it out.  The reason it doesn't warn at -O0 is that it doesn't see it
unless it tries to devirtualize.

Not sure if we have a way to find out if !TREE_PUBLIC is because it has been
declared static or because it has internal linkage and constrain_visibility
VISIBILITY_ANON has been called on it (and would need a langhook anyway to
determine that).

[Bug c++/80916] [7/8/9 Regression] Spurious "declared 'static' but never defined" warning

2018-12-06 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80916

Richard Biener  changed:

   What|Removed |Added

   Target Milestone|7.4 |7.5

[Bug c++/80916] [7/8/9 Regression] Spurious "declared 'static' but never defined" warning

2018-11-22 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80916

Richard Biener  changed:

   What|Removed |Added

   Priority|P3  |P2

[Bug c++/80916] [7/8/9 Regression] Spurious "declared 'static' but never defined" warning

2018-10-31 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80916

Richard Biener  changed:

   What|Removed |Added

   Target Milestone|--- |7.4