Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Gary Benson <gbenson@redhat.com>
To: Pedro Alves <palves@redhat.com>
Cc: Tom Tromey <tom@tromey.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH] W/ Clang, compile C/C++ testcases with -Wno-unknown-warning-option
Date: Thu, 18 Jun 2020 17:18:29 +0100	[thread overview]
Message-ID: <20200618161829.GB1032@blade.nx> (raw)
In-Reply-To: <4a87b8c6-a71c-cb54-8e23-7388c7128c2e@redhat.com>

Pedro Alves wrote:
> From 79f1cfddeea957a778c856c879a386901a96609b Mon Sep 17 00:00:00 2001
> From: Pedro Alves <palves@redhat.com>
> Date: Wed, 17 Jun 2020 19:29:37 +0100
> Subject: [PATCH] W/ Clang, compile C/C++ testcases with
>  -Wno-unknown-warning-option
> 
> Some C/C++ testcases unconditionally pass -Wno-foo as additional
> options to disable some warning.  That is OK with GCC, because GCC
> accepts -Wno-foo silently even if it doesn't support -Wfoo.  This is a
> feature which allows disabling warnings with newer compilers without
> breaking builds with older compilers.  Clang however warns about
> unknown -Wno-foo by default, unless you pass
> -Wno-unknown-warning-option as well:
> 
>  $ gcc -Wno-foo test.c
>  * nothing, compiles successfuly *
> 
>  $ clang -Wno-foo test.c
>  warning: unknown warning option '-Wno-foo [-Wunknown-warning-option]
> 
> This commit adds -Wunknown-warning-option centrally in gdb_compile, so
> that individual testcases don't have to worry about breaking older
> Clangs.
> 
> IOW, this avoids this problematic scenario:
> 
> #1 - A testcase compiles successfully with Clang version X.
> #2 - Clang version "X + 1" adds a new warning, enabled by default,
>      which breaks the test.
> #3 - We add -Wno-newwarning to the testcase, fixing the testcase with
>      clang "X + 1".
> #4 - Now building the test with Clang version X no longer works, due
>      to "unknown warning option".
> 
> gdb/testsuite/ChangeLog:
> yyyy-mm-dd  Pedro Alves  <palves@redhat.com>
> 
> 	* lib/gdb.exp (gdb_compile): Update intro comment.  If C/C++ with
> 	Clang, add "-Wno-unknown-warning-option" to the options.
> ---
>  gdb/testsuite/lib/gdb.exp | 19 ++++++++++++++++++-
>  1 file changed, 18 insertions(+), 1 deletion(-)
> 
> diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
> index f502eb157d8..bbc940a4512 100644
> --- a/gdb/testsuite/lib/gdb.exp
> +++ b/gdb/testsuite/lib/gdb.exp
> @@ -3826,7 +3826,8 @@ set gdb_saved_set_unbuffered_mode_obj ""
>  #   - ldflags=flag: Add FLAG to the linker flags.
>  #   - incdir=path: Add PATH to the searched include directories.
>  #   - libdir=path: Add PATH to the linker searched directories.
> -#   - ada, c++, f77: Compile the file as Ada, C++ or Fortran.
> +#   - ada, c++, f77, f90, rust: Compile the file as Ada, C++,
> +#     Fortran 77, Fortran 90 or Rust.
>  #   - debug: Build with debug information.
>  #   - optimize: Build with optimization.
>  
> @@ -3850,6 +3851,22 @@ proc gdb_compile {source dest type options} {
>  	set new_options [universal_compile_options]
>      }
>  
> +    # Some C/C++ testcases unconditionally pass -Wno-foo as additional
> +    # options to disable some warning.  That is OK with GCC, because
> +    # by design, GCC accepts any -Wno-foo option, even if it doesn't
> +    # support -Wfoo.  Clang however warns about unknown -Wno-foo by
> +    # default, unless you pass -Wno-unknown-warning-option as well.
> +    # We do that here, so that individual testcases don't have to
> +    # worry about it.
> +    if {[lsearch -exact $options getting_compiler_info] == -1
> +	&& [lsearch -exact $options rust] == -1
> +	&& [lsearch -exact $options ada] == -1
> +	&& [lsearch -exact $options f77] == -1
> +	&& [lsearch -exact $options f90] == -1
> +	&& [test_compiler_info "clang-*"]} {
> +	lappend new_options "additional_flags=-Wno-unknown-warning-option"
> +    }
> +
>      # Place (and look for) Fortran `.mod` files in the output
>      # directory for this specific test.
>      if {[lsearch -exact $options f77] != -1 \
> 
> base-commit: 669203174311c5be76744a879563c697cd479853
> -- 
> 2.14.5

Oh, thanks, that looks great.  Could you commit it please?

Cheers,
Gary

-- 
Gary Benson - he / him / his
Principal Software Engineer, Red Hat



  reply	other threads:[~2020-06-18 16:18 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-29 13:03 [OB PATCH] Build two gdb.cp testcases with -Wno-unused-comparison Gary Benson
2020-05-29 18:08 ` Tom Tromey
2020-05-29 18:31   ` Pedro Alves
2020-06-16 12:42     ` Gary Benson
2020-06-16 15:11       ` Pedro Alves
2020-06-17 17:29         ` Gary Benson
2020-06-17 19:53           ` [PATCH] W/ Clang, compile C/C++ testcases with -Wno-unknown-warning-option Pedro Alves
2020-06-18 16:18             ` Gary Benson [this message]
2020-06-24 22:26               ` Pedro Alves
2020-07-02 10:02                 ` Gary Benson
2020-06-16 12:38   ` [OB PATCH] Build two gdb.cp testcases with -Wno-unused-comparison Gary Benson

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=20200618161829.GB1032@blade.nx \
    --to=gbenson@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=palves@redhat.com \
    --cc=tom@tromey.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox