This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] PR28901 Add two levels for -Wunused-const-variable.
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Manuel López-Ibáñez <lopezibanez at gmail dot com>
- Cc: Mark Wielaard <mjw at redhat dot com>, "H.J. Lu" <hjl dot tools at gmail dot com>, Jeff Law <law at redhat dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>, Bernd Schmidt <bschmidt at redhat dot com>, Martin Sebor <msebor at gmail dot com>, Steve Ellcey <sellcey at imgtec dot com>
- Date: Tue, 23 Feb 2016 10:55:34 +0100
- Subject: Re: [PATCH] PR28901 Add two levels for -Wunused-const-variable.
- Authentication-results: sourceware.org; auth=none
- References: <5603E4D3 dot 4050806 at redhat dot com> <1456018952-25270-1-git-send-email-mjw at redhat dot com> <56CB5A34 dot 8030301 at redhat dot com> <20160222224312 dot GK2586 at blokker dot redhat dot com> <CAMe9rOq7EMCU7gZmOFn9Np-4ujqR-w02dBhNyEyS0HCqMYBZ7Q at mail dot gmail dot com> <1456214140 dot 7770 dot 101 dot camel at redhat dot com> <20160223082652 dot GV3017 at tucnak dot redhat dot com> <1456217637 dot 7770 dot 108 dot camel at redhat dot com> <20160223085651 dot GW3017 at tucnak dot redhat dot com> <56CC2B89 dot 80404 at gmail dot com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Tue, Feb 23, 2016 at 09:51:05AM +0000, Manuel López-Ibáñez wrote:
> >>diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c
> >>index 27a073a..8b3fddc 100644
> >>--- a/gcc/cgraphunit.c
> >>+++ b/gcc/cgraphunit.c
> >>@@ -917,6 +917,7 @@ walk_polymorphic_call_targets (hash_set<void *> *reachable_call_targets,
> >> static void
> >> check_global_declaration (symtab_node *snode)
> >> {
> >>+ const char *decl_file;
> >> tree decl = snode->decl;
> >>
> >> /* Warn about any function declared static but not defined. We don't
> >>@@ -944,8 +945,10 @@ check_global_declaration (symtab_node *snode)
> >> || (((warn_unused_variable && ! TREE_READONLY (decl))
> >> || (warn_unused_const_variable > 0 && TREE_READONLY (decl)
> >> && (warn_unused_const_variable == 2
> >>- || filename_cmp (main_input_filename,
> >>- DECL_SOURCE_FILE (decl)) == 0)))
> >>+ || (main_input_filename != NULL
> >>+ && (decl_file = DECL_SOURCE_FILE (decl)) != NULL
> >>+ && filename_cmp (main_input_filename,
> >>+ decl_file) == 0))))
>
>
> Can we please please please hide this ugliness behind an (inline?) function
> such as bool in_main_file_at (location_t) in input.[ch]? The condition here
> is quickly becoming unreadable.
>
> Also because in the future somebody would want to re-implement this using
> MAIN_FILE_P() from line-map.h, which is faster.
I'm not against that, but I'd prefer if it is done incrementally, we don't
want to keep the trunk broken too much for too long. So if Mark is already
testing this patch, IMHO it is better to commit it in this shape sooner.
Jakub