This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] PR28901 Add two levels for -Wunused-const-variable.


On Tue, Feb 23, 2016 at 09:53:57AM +0100, Mark Wielaard wrote:
> --- a/gcc/ChangeLog
> +++ b/gcc/ChangeLog
> @@ -1,3 +1,10 @@
> +2016-02-23  Mark Wielaard  <mjw@redhat.com>
> +	    Jakub Jelinek  <jakub@redhat.com>
> +
> +	PR c/69911
> +	* cgraphunit.c (check_global_declaration): Check main_input_filename
> +	and DECL_SOURCE_FILE are not NULL.
> +
>  2016-02-20  Mark Wielaard  <mjw@redhat.com>

This is ok for trunk if it passes testing.  Thanks.

> 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))))
>  	   && TREE_CODE (decl) == VAR_DECL))
>        && ! DECL_IN_SYSTEM_HEADER (decl)
>        && ! snode->referred_to_p (/*include_self=*/false)

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]