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
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
}
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]} {