Enable gdb.cp/ambiguous.exp with GCC >= 10.1 and clang

Message ID 1595855345-15492-1-git-send-email-gbenson@redhat.com
State New
Headers show
Series
  • Enable gdb.cp/ambiguous.exp with GCC >= 10.1 and clang
Related show

Commit Message

Eli Zaretskii via Gdb-patches July 27, 2020, 1:09 p.m.
Hi all,

gdb.cp/ambiguous.exp failed to build using clang with the following
error:

 gdb compile failed, /gdbtest/src/gdb/testsuite/gdb.cp/ambiguous.cc:70:36:
   warning: direct base 'A1' is inaccessible due to ambiguity:
     class JVA1 -> class KV -> class A1
     class JVA1 -> class A1 [-Winaccessible-base]
 class JVA1 : public KV, public LV, public A1 {
                                   ^~~~~~~~~

This commit builds this testcase with -Wno-inaccessible-base when
using clang, to avoid this failure.

Furthermore, gdb.cp/ambiguous.exp has been disabled when using GCC
since 1998.  This commit enables this testcase when compiling with
GCC >= 10.1, the first version with -Wno-inaccessible-base.

Checked on Fedora 31 x86_64, GCC and clang.  Ok to commit?

Cheers,
Gary

--
gdb/testsuite/ChangeLog:

	* gdb.cp/ambiguous.exp: Enable test when compiling with GCC >=
	10.1.  Add additional_flags=-Wno-inaccessible-base when compiling
	with GCC or clang.
---
 gdb/testsuite/ChangeLog            |  6 ++++++
 gdb/testsuite/gdb.cp/ambiguous.exp | 17 +++++++++++++++--
 2 files changed, 21 insertions(+), 2 deletions(-)

-- 
1.8.3.1

Comments

Pedro Alves Aug. 7, 2020, 3:27 p.m. | #1
On 7/27/20 2:09 PM, Gary Benson via Gdb-patches wrote:
> Hi all,

> 

> gdb.cp/ambiguous.exp failed to build using clang with the following

> error:

> 

>  gdb compile failed, /gdbtest/src/gdb/testsuite/gdb.cp/ambiguous.cc:70:36:

>    warning: direct base 'A1' is inaccessible due to ambiguity:

>      class JVA1 -> class KV -> class A1

>      class JVA1 -> class A1 [-Winaccessible-base]

>  class JVA1 : public KV, public LV, public A1 {

>                                    ^~~~~~~~~

> 

> This commit builds this testcase with -Wno-inaccessible-base when

> using clang, to avoid this failure.

> 

> Furthermore, gdb.cp/ambiguous.exp has been disabled when using GCC

> since 1998.  


Curious you reference the year, do you know it because you found the
commit that disabled it?

> This commit enables this testcase when compiling with

> GCC >= 10.1, the first version with -Wno-inaccessible-base.

> 

> Checked on Fedora 31 x86_64, GCC and clang.  Ok to commit?

> 

> Cheers,

> Gary

> 

> --

> gdb/testsuite/ChangeLog:

> 

> 	* gdb.cp/ambiguous.exp: Enable test when compiling with GCC >=

> 	10.1.  Add additional_flags=-Wno-inaccessible-base when compiling

> 	with GCC or clang.

> ---

>  gdb/testsuite/ChangeLog            |  6 ++++++

>  gdb/testsuite/gdb.cp/ambiguous.exp | 17 +++++++++++++++--

>  2 files changed, 21 insertions(+), 2 deletions(-)

> 

> diff --git a/gdb/testsuite/gdb.cp/ambiguous.exp b/gdb/testsuite/gdb.cp/ambiguous.exp

> index fffe20a..26f96a9 100644

> --- a/gdb/testsuite/gdb.cp/ambiguous.exp

> +++ b/gdb/testsuite/gdb.cp/ambiguous.exp

> @@ -30,12 +30,25 @@ if { [skip_cplus_tests] } { continue }

>  standard_testfile .cc

>  

>  if [get_compiler_info "c++"] {

> +    unsupported "couldn't find a valid c++ compiler"

>      return -1

>  }

>  

> -if { [test_compiler_info gcc-*] } then { continue }

> +# GCCs prior to 10.1 do not support -Wno-inaccessible-base.

> +if { [test_compiler_info {gcc-[0-9]-*}]

> +     || [test_compiler_info {gcc-10-0-*}] } {


Given the first release of GCC 10 is 10.1, do we really
need the second check?

> +    unsupported "compiler does not support -Wno-inaccessible-base"


How about instead of bailing out, use "-Wno-inaccessible-base"
with GCC >= 10, and use "-w" with older GCCs?

Patch

diff --git a/gdb/testsuite/gdb.cp/ambiguous.exp b/gdb/testsuite/gdb.cp/ambiguous.exp
index fffe20a..26f96a9 100644
--- a/gdb/testsuite/gdb.cp/ambiguous.exp
+++ b/gdb/testsuite/gdb.cp/ambiguous.exp
@@ -30,12 +30,25 @@  if { [skip_cplus_tests] } { continue }
 standard_testfile .cc
 
 if [get_compiler_info "c++"] {
+    unsupported "couldn't find a valid c++ compiler"
     return -1
 }
 
-if { [test_compiler_info gcc-*] } then { continue }
+# GCCs prior to 10.1 do not support -Wno-inaccessible-base.
+if { [test_compiler_info {gcc-[0-9]-*}]
+     || [test_compiler_info {gcc-10-0-*}] } {
+    unsupported "compiler does not support -Wno-inaccessible-base"
+    return -1
+}
+
+set additional_flags ""
+if { [test_compiler_info gcc*] } {
+     || [test_compiler_info clang*] } {
+    set additional_flags "additional_flags=-Wno-inaccessible-base"
+}
 
-if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug c++}]} {
+if {[prepare_for_testing "failed to prepare" $testfile $srcfile \
+     [list debug c++ $additional_flags]]} {
     return -1
 }