[Bug c++/78749] [7 Regression] bogus warning for friend member function in anonymous namespace
mpolacek at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Fri Dec 9 15:18:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78749
--- Comment #4 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
It's tempting to write just
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -922,11 +922,12 @@ wrapup_globals_for_namespace (tree name_space, void* data
ATTRIBUTE_UNUSED)
unsigned int i;
FOR_EACH_VEC_SAFE_ELT (statics, i, decl)
if (TREE_CODE (decl) == FUNCTION_DECL
- && DECL_INITIAL (decl) == 0
+ && DECL_INITIAL (decl) == NULL_TREE
&& DECL_EXTERNAL (decl)
&& !TREE_PUBLIC (decl)
&& !DECL_ARTIFICIAL (decl)
- && !TREE_NO_WARNING (decl))
+ && !TREE_NO_WARNING (decl)
+ && !DECL_FRIEND_P (decl))
{
warning_at (DECL_SOURCE_LOCATION (decl),
OPT_Wunused_function,
given that "Storage class specifiers are not allowed in friend function
declarations. A function that is defined in the friend declaration has external
linkage, a function that was previously defined, keeps the linkage it was
defined with." But maybe somebody has an example of a friend member function
that we'd want to warn for?
More information about the Gcc-bugs
mailing list