This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: PATCH RFA: Support -Wmissing-declarations in C++
Ian Lance Taylor wrote:
> Index: gcc/doc/invoke.texi
> ===================================================================
> --- gcc/doc/invoke.texi (revision 119818)
> +++ gcc/doc/invoke.texi (working copy)
> @@ -3215,12 +3215,13 @@ declaration. This warning is issued eve
> provides a prototype. The aim is to detect global functions that fail
> to be declared in header files.
>
> -@item -Wmissing-declarations @r{(C only)}
> +@item -Wmissing-declarations @r{(C and C++ only)}
> @opindex Wmissing-declarations
> Warn if a global function is defined without a previous declaration.
> Do so even if the definition itself provides a prototype.
> Use this option to detect global functions that are not declared in
> -header files.
> +header files. In C++, no warnings are issued for functions which are
> +explicitly declared inline, or for templatized functions.
"templatized functions" is not a standard term; please say "function
templates" (or "specializations of function templates"). Also, you've
exempted members of anonymous namespaces, so that should be documented too.
The patch is OK with those changes.
> + for (context = DECL_CONTEXT (decl1);
> + context;
> + context = DECL_CONTEXT (context))
> + {
> + if (TREE_CODE (context) == NAMESPACE_DECL
> + && DECL_NAME (context) == NULL_TREE)
I wanted to tell you to use ANON_NAMESPACE_P -- but we don't have such a
macro. :-( If you wanted to be clever here, you could note that anon
and context are redundant; at the end of the loop anon is true iff
context is non-NULL. Whether that's better or not is up to you; it's
just style.
--
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713