]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
[gdb/testsuite] Use Wno-non-c-typedef-for-linkage for gcc 16
authorTom de Vries <tdevries@suse.de>
Sat, 30 May 2026 12:46:22 +0000 (14:46 +0200)
committerTom de Vries <tdevries@suse.de>
Sat, 30 May 2026 12:46:22 +0000 (14:46 +0200)
With gcc 16 and test-case gdb.cp/classes.exp I run into:
...
classes.cc:440:15: warning: anonymous non-C-compatible type given name for linkage purposes by 'typedef' declaration [-Wnon-c-typedef-for-linkage]^M
  440 | typedef class {^M
      |               ^^M
      |               DynamicBase2^M
classes.cc:443:15: note: type is not C-compatible because it contains 'virtual int DynamicBase2::get_x()' declaration^M
  443 |   virtual int get_x () { return x; }^M
      |               ^~~~~^M
...

Fix this by applying Wno-non-c-typedef-for-linkage, which is already done for
clang.

Likewise for gdb.cp/class2.exp.

Reviewed-By: Keith Seitz <keiths@redhat.com>
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=34187

gdb/testsuite/gdb.cp/class2.exp
gdb/testsuite/gdb.cp/classes.exp

index 705f51ac3e07aa67381187688ce1daa37b4972c9..0d434fde174c5a22d2757fc6abda208c48e28e39 100644 (file)
@@ -19,9 +19,11 @@ require allow_cplus_tests
 standard_testfile .cc
 
 set flags [list debug c++]
-# When using recent Clangs, this test fails to compile without this warning
-# being disabled.  However, older Clangs fail to recognize the flag.
-if { [gcc_major_version "clang-*" "c++"] > 10 } {
+# When using recent Clangs/GCCs, this test fails to compile without this
+# warning being disabled.  However, older Clangs/GCCs fail to recognize the
+# flag.
+if { [gcc_major_version "clang-*" "c++"] > 10
+     || [gcc_major_version "gcc-*" "c++"] >= 16} {
     lappend flags additional_flags=-Wno-non-c-typedef-for-linkage
 }
 
index 71ce810adadfd80d064f3d18950921d9175270cb..d2fb7c0c14c40e16d0edc67272ac0092af774222 100644 (file)
@@ -25,12 +25,15 @@ load_lib "cp-support.exp"
 standard_testfile .cc
 
 set flags [list debug c++]
+
 set clang_used false
 if { [test_compiler_info "clang-*" "c++"] } {
     set clang_used true
-    if { [gcc_major_version "clang-*" "c++"] >= 11} {
-       lappend flags additional_flags=-Wno-non-c-typedef-for-linkage
-    }
+}
+
+if { [gcc_major_version "clang-*" "c++"] >= 11
+     || [gcc_major_version "gcc-*" "c++"] >= 16} {
+    lappend flags additional_flags=-Wno-non-c-typedef-for-linkage
 }
 
 if {[prepare_for_testing "failed to prepare" $testfile $srcfile $flags]} {