On Tue, Jun 10, 2025 at 1:19 AM Robert Dubner <rdub...@symas.com> wrote:
>
> In the course of stamping out cppcheck warnings, we ran across a complaint
> about a "shadowed variable."
>
> It turns out that a variable declared in gcc/gcc/h as "extern int
> n_infiles;" is used only locally in gcc/gcc/cc.
>
> This change makes that variable "static int n_infiles;" in gcc/gcc.cc.
>
> Okay for trunk?

OK.

Richard.

>
> From 1d9afbdb9c313fd58fefc5d1d284f1831942ed98 Mon Sep 17 00:00:00 2001
> From: Robert Dubner mailto:rdub...@symas.com
> Date: Mon, 9 Jun 2025 18:38:10 -0400
> Subject: [PATCH] gcc: Make int n_infiles local to gcc.cc.
>
> The variable "int n_infiles" was declared as "extern int n_infiles"
> although
> it was used only in gcc.h.  This patch makes it "static int n_infiles".
>
> gcc/ChangeLog:
>
>         * gcc.cc: Change "int n_infiles" to "static int n_infiles".
>         * gcc.h: Delete "extern int n_infiles".
> ---
>  gcc/gcc.cc | 2 +-
>  gcc/gcc.h  | 2 --
>  2 files changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/gcc/gcc.cc b/gcc/gcc.cc
> index 4e61de2a47c..1a6cfc6056f 100644
> --- a/gcc/gcc.cc
> +++ b/gcc/gcc.cc
> @@ -3651,7 +3651,7 @@ struct infile
>
>  static struct infile *infiles;
>
> -int n_infiles;
> +static int n_infiles;
>
>  static int n_infiles_alloc;
>
> diff --git a/gcc/gcc.h b/gcc/gcc.h
> index 5ba6c9d33dd..15ae21eea56 100644
> --- a/gcc/gcc.h
> +++ b/gcc/gcc.h
> @@ -83,8 +83,6 @@ extern void lang_specific_driver (struct
> cl_decoded_option **,
>  /* Called before linking.  Returns 0 on success and -1 on failure.  */
>  extern int lang_specific_pre_link (void);
>
> -extern int n_infiles;
> -
>  /* Number of extra output files that lang_specific_pre_link may generate.
> */
>  extern int lang_specific_extra_outfiles;
>
> --
> 2.34.1
>

Reply via email to