[Bug bootstrap/91972] Bootstrap should use -Wmissing-declarations
rguenth at gcc dot gnu.org
Tue May 5 13:34:04 GMT 2020
--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #2)
> (In reply to Alexander Monakov from comment #0)
> > Transition to C++ did not change -Wmissing-prototypes to
> > -Wmissing-declarations, so over time several violations crept in. In
> > particular this penalizes optimization during non-LTO bootstrap (the
> > compiler has to assume the function might be used in another TU, even though
> > in reality all uses are in current file and it simply misses the 'static'
> > keyword).
> Why is it missing the static keyword then? (Or alternatively, why isn't it
> in an anonymous namespace?)
> (In reply to Alexander Monakov from comment #1)
> > Another reason to have -Wmissing-declarations is that otherwise mismatches
> > of unused functions are not caught until it's too late (mismatching
> > definition is assumed to be an overload of the function declared in the
> > header file).
> A more robust way to avoid that problem is to declare the function in a
> namespace, and define it using a qualified name:
> // declaration
> namespace targ
> void foo(void*);
> // definition
> void targ::foo(class vec_info*); // ERROR
> Because no foo with that signature was declared in namespace targ it's an
> error, not just a warning.
> Should the coding convention be adjusted to avoid this problem?
Ah, I like the namespace thing for target hooks (possibly langhooks as well).
More information about the Gcc-bugs