All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alistair Francis <alistair23@gmail.com>
To: Richard Henderson <richard.henderson@linaro.org>
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
	"open list:RISC-V" <qemu-riscv@nongnu.org>,
	"qemu-devel@nongnu.org Developers" <qemu-devel@nongnu.org>,
	qemu-arm <qemu-arm@nongnu.org>,
	"Alistair Francis" <Alistair.Francis@wdc.com>,
	"Philippe Mathieu-Daudé" <philmd@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 2/3] decodetree: Suppress redundant declaration warnings
Date: Fri, 9 Aug 2019 19:02:44 -0700	[thread overview]
Message-ID: <CAKmqyKNU0UV_-wEqFgQLFqAUXBxHZyiu1dBX4bPachkYKTB=Mw@mail.gmail.com> (raw)
In-Reply-To: <20190809154153.31763-3-richard.henderson@linaro.org>

On Fri, Aug 9, 2019 at 8:42 AM Richard Henderson
<richard.henderson@linaro.org> wrote:
>
> We can tell that a decodetree input file is "secondary" when it
> uses an argument set marked "!extern".  This indicates that at
> least one of the insn translation functions will have already
> been declared by the "primary" input file, but given only the
> secondary we cannot tell which.
>
> Avoid redundant declaration warnings by suppressing them with pragmas.
>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>

Alistair

> ---
>  scripts/decodetree.py | 22 ++++++++++++++++++++++
>  1 file changed, 22 insertions(+)
>
> diff --git a/scripts/decodetree.py b/scripts/decodetree.py
> index a2490aeb74..f02c8acca1 100755
> --- a/scripts/decodetree.py
> +++ b/scripts/decodetree.py
> @@ -33,6 +33,7 @@ arguments = {}
>  formats = {}
>  patterns = []
>  allpatterns = []
> +anyextern = False
>
>  translate_prefix = 'trans'
>  translate_scope = 'static '
> @@ -485,12 +486,14 @@ def parse_arguments(lineno, name, toks):
>      """Parse one argument set from TOKS at LINENO"""
>      global arguments
>      global re_ident
> +    global anyextern
>
>      flds = []
>      extern = False
>      for t in toks:
>          if re_fullmatch('!extern', t):
>              extern = True
> +            anyextern = True
>              continue
>          if not re_fullmatch(re_ident, t):
>              error(lineno, 'invalid argument set token "{0}"'.format(t))
> @@ -1191,6 +1194,7 @@ def main():
>      global insnmask
>      global decode_function
>      global variablewidth
> +    global anyextern
>
>      decode_scope = 'static '
>
> @@ -1251,6 +1255,19 @@ def main():
>      # A single translate function can be invoked for different patterns.
>      # Make sure that the argument sets are the same, and declare the
>      # function only once.
> +    #
> +    # If we're sharing formats, we're likely also sharing trans_* functions,
> +    # but we can't tell which ones.  Prevent issues from the compiler by
> +    # suppressing redundant declaration warnings.
> +    if anyextern:
> +        output("#ifdef CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE\n",
> +               "# pragma GCC diagnostic push\n",
> +               "# pragma GCC diagnostic ignored \"-Wredundant-decls\"\n",
> +               "# ifdef __clang__\n"
> +               "#  pragma GCC diagnostic ignored \"-Wtypedef-redefinition\"\n",
> +               "# endif\n",
> +               "#endif\n\n")
> +
>      out_pats = {}
>      for i in allpatterns:
>          if i.name in out_pats:
> @@ -1262,6 +1279,11 @@ def main():
>              out_pats[i.name] = i
>      output('\n')
>
> +    if anyextern:
> +        output("#ifdef CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE\n",
> +               "# pragma GCC diagnostic pop\n",
> +               "#endif\n\n")
> +
>      for n in sorted(formats.keys()):
>          f = formats[n]
>          f.output_extract()
> --
> 2.17.1
>
>


WARNING: multiple messages have this Message-ID (diff)
From: Alistair Francis <alistair23@gmail.com>
To: Richard Henderson <richard.henderson@linaro.org>
Cc: "qemu-devel@nongnu.org Developers" <qemu-devel@nongnu.org>,
	"Peter Maydell" <peter.maydell@linaro.org>,
	"Alistair Francis" <Alistair.Francis@wdc.com>,
	qemu-arm <qemu-arm@nongnu.org>,
	"open list:RISC-V" <qemu-riscv@nongnu.org>,
	"Philippe Mathieu-Daudé" <philmd@redhat.com>
Subject: Re: [Qemu-riscv] [Qemu-devel] [PATCH 2/3] decodetree: Suppress redundant declaration warnings
Date: Fri, 9 Aug 2019 19:02:44 -0700	[thread overview]
Message-ID: <CAKmqyKNU0UV_-wEqFgQLFqAUXBxHZyiu1dBX4bPachkYKTB=Mw@mail.gmail.com> (raw)
In-Reply-To: <20190809154153.31763-3-richard.henderson@linaro.org>

On Fri, Aug 9, 2019 at 8:42 AM Richard Henderson
<richard.henderson@linaro.org> wrote:
>
> We can tell that a decodetree input file is "secondary" when it
> uses an argument set marked "!extern".  This indicates that at
> least one of the insn translation functions will have already
> been declared by the "primary" input file, but given only the
> secondary we cannot tell which.
>
> Avoid redundant declaration warnings by suppressing them with pragmas.
>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>

Alistair

> ---
>  scripts/decodetree.py | 22 ++++++++++++++++++++++
>  1 file changed, 22 insertions(+)
>
> diff --git a/scripts/decodetree.py b/scripts/decodetree.py
> index a2490aeb74..f02c8acca1 100755
> --- a/scripts/decodetree.py
> +++ b/scripts/decodetree.py
> @@ -33,6 +33,7 @@ arguments = {}
>  formats = {}
>  patterns = []
>  allpatterns = []
> +anyextern = False
>
>  translate_prefix = 'trans'
>  translate_scope = 'static '
> @@ -485,12 +486,14 @@ def parse_arguments(lineno, name, toks):
>      """Parse one argument set from TOKS at LINENO"""
>      global arguments
>      global re_ident
> +    global anyextern
>
>      flds = []
>      extern = False
>      for t in toks:
>          if re_fullmatch('!extern', t):
>              extern = True
> +            anyextern = True
>              continue
>          if not re_fullmatch(re_ident, t):
>              error(lineno, 'invalid argument set token "{0}"'.format(t))
> @@ -1191,6 +1194,7 @@ def main():
>      global insnmask
>      global decode_function
>      global variablewidth
> +    global anyextern
>
>      decode_scope = 'static '
>
> @@ -1251,6 +1255,19 @@ def main():
>      # A single translate function can be invoked for different patterns.
>      # Make sure that the argument sets are the same, and declare the
>      # function only once.
> +    #
> +    # If we're sharing formats, we're likely also sharing trans_* functions,
> +    # but we can't tell which ones.  Prevent issues from the compiler by
> +    # suppressing redundant declaration warnings.
> +    if anyextern:
> +        output("#ifdef CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE\n",
> +               "# pragma GCC diagnostic push\n",
> +               "# pragma GCC diagnostic ignored \"-Wredundant-decls\"\n",
> +               "# ifdef __clang__\n"
> +               "#  pragma GCC diagnostic ignored \"-Wtypedef-redefinition\"\n",
> +               "# endif\n",
> +               "#endif\n\n")
> +
>      out_pats = {}
>      for i in allpatterns:
>          if i.name in out_pats:
> @@ -1262,6 +1279,11 @@ def main():
>              out_pats[i.name] = i
>      output('\n')
>
> +    if anyextern:
> +        output("#ifdef CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE\n",
> +               "# pragma GCC diagnostic pop\n",
> +               "#endif\n\n")
> +
>      for n in sorted(formats.keys()):
>          f = formats[n]
>          f.output_extract()
> --
> 2.17.1
>
>


  parent reply	other threads:[~2019-08-10  2:04 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-09 15:41 [Qemu-devel] [PATCH 0/3] decodetree improvements Richard Henderson
2019-08-09 15:41 ` [Qemu-riscv] " Richard Henderson
2019-08-09 15:41 ` [Qemu-devel] [PATCH 1/3] decodetree: Allow !function with no input bits Richard Henderson
2019-08-09 15:41   ` [Qemu-riscv] " Richard Henderson
2019-08-09 15:52   ` [Qemu-devel] " Peter Maydell
2019-08-09 15:52     ` [Qemu-riscv] " Peter Maydell
2019-08-09 15:57     ` [Qemu-devel] " Richard Henderson
2019-08-09 15:57       ` [Qemu-riscv] " Richard Henderson
2019-08-09 15:41 ` [Qemu-devel] [PATCH 2/3] decodetree: Suppress redundant declaration warnings Richard Henderson
2019-08-09 15:41   ` [Qemu-riscv] " Richard Henderson
2019-08-09 15:48   ` [Qemu-devel] " Philippe Mathieu-Daudé
2019-08-09 15:48     ` [Qemu-riscv] " Philippe Mathieu-Daudé
2019-08-10  2:02   ` Alistair Francis [this message]
2019-08-10  2:02     ` [Qemu-riscv] [Qemu-devel] " Alistair Francis
2019-08-09 15:41 ` [Qemu-devel] [PATCH 3/3] target/riscv: Remove redundant declaration pragmas Richard Henderson
2019-08-09 15:41   ` [Qemu-riscv] " Richard Henderson
2019-08-09 15:48   ` [Qemu-devel] " Philippe Mathieu-Daudé
2019-08-09 15:48     ` [Qemu-riscv] " Philippe Mathieu-Daudé
2019-08-09 17:43   ` [Qemu-devel] " Palmer Dabbelt
2019-08-09 17:43     ` [Qemu-riscv] " Palmer Dabbelt
2019-08-10  0:05     ` Richard Henderson
2019-08-10  0:05       ` [Qemu-riscv] " Richard Henderson
2019-08-10  2:03   ` Alistair Francis
2019-08-10  2:03     ` [Qemu-riscv] " Alistair Francis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAKmqyKNU0UV_-wEqFgQLFqAUXBxHZyiu1dBX4bPachkYKTB=Mw@mail.gmail.com' \
    --to=alistair23@gmail.com \
    --cc=Alistair.Francis@wdc.com \
    --cc=peter.maydell@linaro.org \
    --cc=philmd@redhat.com \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-riscv@nongnu.org \
    --cc=richard.henderson@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.