Enable gdb.cp/ambiguous.exp with GCC and clang
authorGary Benson <gbenson@redhat.com>
Tue, 25 Aug 2020 14:14:46 +0000 (15:14 +0100)
committerGary Benson <gbenson@redhat.com>
Tue, 25 Aug 2020 14:14:46 +0000 (15:14 +0100)
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, building with
-Wno-inaccessible-base when using GCC >= 10.1, and -w otherwise.

gdb/testsuite/ChangeLog:

* gdb.cp/ambiguous.exp: Enable test when compiling with GCC.
Add additional_flags=-Wno-inaccessible-base when compiling
with GCC >= 10.1 or clang.  Add additional_flags=-w when
compiling with GCC < 10.

gdb/testsuite/ChangeLog
gdb/testsuite/gdb.cp/ambiguous.exp

index f5c258b432c04f78a065ce8dd6f28b1eddc4ccfc..93df7f9c5d274a13f9c979ed353e5e177cc2536d 100644 (file)
@@ -1,3 +1,10 @@
+2020-08-25  Gary Benson <gbenson@redhat.com>
+
+       * gdb.cp/ambiguous.exp: Enable test when compiling with GCC.
+       Add additional_flags=-Wno-inaccessible-base when compiling
+       with GCC >= 10.1 or clang.  Add additional_flags=-w when
+       compiling with GCC < 10.
+
 2020-08-25  Gaius Mulley  <gaiusmod2@gmail.com>
 
        PR m2/26372
index fffe20ae5965f97126021da6f6c6d61e308d7ab3..17fb29f5350e48b4f34888776857b9e66d031b7b 100644 (file)
@@ -30,12 +30,20 @@ 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 }
+set additional_flags ""
+if {[test_compiler_info {gcc-[0-9]-*}]} {
+    # GCCs prior to 10.1 do not support -Wno-inaccessible-base.
+    set additional_flags "additional_flags=-w"
+} elseif {[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
 }
 
This page took 0.033377 seconds and 4 git commands to generate.