On Wed, Aug 24, 2011 at 9:32 PM, Alan Modra <amo...@gmail.com> wrote:
> Wouldn't -Wshadow be more useful if it obeyed -Wno-system-headers?
> For code like
>
>        #include <stdlib.h>
>        int foo (int atof);
>        int foo (int atof) { return atof; }
>
> we currently do not warn on the prototype, but do on the function
> definition, leading to reports such as
> http://sourceware.org/bugzilla/show_bug.cgi?id=13121
>
> The following has been bootstrapped and regression tested
> powerpc-linux.  OK to apply?

OK.

>
>        * c-decl.c (warn_if_shadowing): Don't warn if shadowed
>        identifier is from system header.
>
> Index: gcc/c-decl.c
> ===================================================================
> --- gcc/c-decl.c        (revision 178035)
> +++ gcc/c-decl.c        (working copy)
> @@ -2516,7 +2516,10 @@ warn_if_shadowing (tree new_decl)
>
>   /* Is anything being shadowed?  Invisible decls do not count.  */
>   for (b = I_SYMBOL_BINDING (DECL_NAME (new_decl)); b; b = b->shadowed)
> -    if (b->decl && b->decl != new_decl && !b->invisible)
> +    if (b->decl && b->decl != new_decl && !b->invisible
> +       && (b->decl == error_mark_node
> +           || diagnostic_report_warnings_p (global_dc,
> +                                            DECL_SOURCE_LOCATION (b->decl))))
>       {
>        tree old_decl = b->decl;
>
>
> --
> Alan Modra
> Australia Development Lab, IBM
>

Reply via email to