Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH 0/2] [gdb/testsuite] Handle gcc 16
@ 2026-05-29 12:51 Tom de Vries
  2026-05-29 12:51 ` [PATCH 1/2] [gdb/testsuite] Fix ambiguous operator warning Tom de Vries
  2026-05-29 12:51 ` [PATCH 2/2] [gdb/testsuite] Use Wno-non-c-typedef-for-linkage for gcc 16 Tom de Vries
  0 siblings, 2 replies; 6+ messages in thread
From: Tom de Vries @ 2026-05-29 12:51 UTC (permalink / raw)
  To: gdb-patches

System gcc on fedora 44 (aarch64-linux) got bumped to 16, which defaults to
c++20 by default.

There are a number of new warnings.  Fix them.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=34187

Tom de Vries (2):
  [gdb/testsuite] Fix ambiguous operator warning
  [gdb/testsuite] Use Wno-non-c-typedef-for-linkage for gcc 16

 gdb/testsuite/gdb.cp/class2.exp       | 3 ++-
 gdb/testsuite/gdb.cp/classes.exp      | 9 ++++++---
 gdb/testsuite/gdb.cp/cmpd-minsyms.cc  | 2 +-
 gdb/testsuite/gdb.cp/cmpd-minsyms.exp | 2 +-
 gdb/testsuite/gdb.cp/many-args.cc     | 2 +-
 5 files changed, 11 insertions(+), 7 deletions(-)


base-commit: 2786cbfa05e3df7f8727eff02a15906eb244aa37
-- 
2.51.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/2] [gdb/testsuite] Fix ambiguous operator warning
  2026-05-29 12:51 [PATCH 0/2] [gdb/testsuite] Handle gcc 16 Tom de Vries
@ 2026-05-29 12:51 ` Tom de Vries
  2026-05-29 16:23   ` Keith Seitz
  2026-05-29 12:51 ` [PATCH 2/2] [gdb/testsuite] Use Wno-non-c-typedef-for-linkage for gcc 16 Tom de Vries
  1 sibling, 1 reply; 6+ messages in thread
From: Tom de Vries @ 2026-05-29 12:51 UTC (permalink / raw)
  To: gdb-patches

With gcc 16, defaulting to c++20, and test-case gdb.cp/cmpd-minsyms.exp I run
into:
...
cmpd-minsyms.cc: In function 'int main(int, char**)':^M
cmpd-minsyms.cc:39:13: warning: C++20 says that these are ambiguous, even \
  though the second is reversed:^M
   39 |    if (a == b)^M
      |             ^^M
cmpd-minsyms.cc:26:8: note: candidate 1: 'int GDB<T>::operator==(const GDB<T>&) [with T = int]'^M
   26 |    int operator == (GDB const& other)^M
      |        ^~~~~~~~^M
cmpd-minsyms.cc:26:8: note: candidate 2: 'int GDB<T>::operator==(const GDB<T>&) [with T = int]' (reversed)^M
cmpd-minsyms.cc:26:8: note: try making the operator a 'const' member function^M
...

Fix this by following the advice:
...
-   int operator == (GDB const& other)
+   int operator == (GDB const& other) const
    { return 1; }
...

Likewise in gdb.cp/many-args.exp.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=34187
---
 gdb/testsuite/gdb.cp/cmpd-minsyms.cc  | 2 +-
 gdb/testsuite/gdb.cp/cmpd-minsyms.exp | 2 +-
 gdb/testsuite/gdb.cp/many-args.cc     | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/gdb/testsuite/gdb.cp/cmpd-minsyms.cc b/gdb/testsuite/gdb.cp/cmpd-minsyms.cc
index 504dfec0f9c..afef5d7dcd4 100644
--- a/gdb/testsuite/gdb.cp/cmpd-minsyms.cc
+++ b/gdb/testsuite/gdb.cp/cmpd-minsyms.cc
@@ -23,7 +23,7 @@ class GDB
    static int harder (T a) { return 1; }
    template <typename X>
    static X even_harder (T a) { return static_cast<X> (a); }
-   int operator == (GDB const& other)
+   int operator == (GDB const& other) const
    { return 1; }
   void a (void) const { }
   void b (void) volatile { }
diff --git a/gdb/testsuite/gdb.cp/cmpd-minsyms.exp b/gdb/testsuite/gdb.cp/cmpd-minsyms.exp
index 19653a4ccc9..ccd7f5d692a 100644
--- a/gdb/testsuite/gdb.cp/cmpd-minsyms.exp
+++ b/gdb/testsuite/gdb.cp/cmpd-minsyms.exp
@@ -48,7 +48,7 @@ gdb_test_no_output "set language c++"
 # of the minimal symbol.
 set min_syms [list \
 		  "GDB<int>::operator ==" \
-		  "GDB<int>::operator==(GDB<int> const&)" \
+		  "GDB<int>::operator==(GDB<int> const&) const" \
 		  "GDB<char>::harder(char)" \
 		  "GDB<int>::harder(int)" \
 		  {"int GDB<char>::even_harder<int>(char)"} \
diff --git a/gdb/testsuite/gdb.cp/many-args.cc b/gdb/testsuite/gdb.cp/many-args.cc
index b5685b13c47..8c8805297f7 100644
--- a/gdb/testsuite/gdb.cp/many-args.cc
+++ b/gdb/testsuite/gdb.cp/many-args.cc
@@ -26,7 +26,7 @@ struct ss
 
   unsigned char aa;
 
-  bool operator== (const ss &rhs)
+  bool operator== (const ss &rhs) const
   {
     return (memcmp (&this->static_field, &rhs.static_field,
 		    sizeof (this->static_field)) == 0
-- 
2.51.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 2/2] [gdb/testsuite] Use Wno-non-c-typedef-for-linkage for gcc 16
  2026-05-29 12:51 [PATCH 0/2] [gdb/testsuite] Handle gcc 16 Tom de Vries
  2026-05-29 12:51 ` [PATCH 1/2] [gdb/testsuite] Fix ambiguous operator warning Tom de Vries
@ 2026-05-29 12:51 ` Tom de Vries
  2026-05-29 16:25   ` Keith Seitz
  1 sibling, 1 reply; 6+ messages in thread
From: Tom de Vries @ 2026-05-29 12:51 UTC (permalink / raw)
  To: gdb-patches

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.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=34187
---
 gdb/testsuite/gdb.cp/class2.exp  | 3 ++-
 gdb/testsuite/gdb.cp/classes.exp | 9 ++++++---
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/gdb/testsuite/gdb.cp/class2.exp b/gdb/testsuite/gdb.cp/class2.exp
index 705f51ac3e0..aa2a04467f4 100644
--- a/gdb/testsuite/gdb.cp/class2.exp
+++ b/gdb/testsuite/gdb.cp/class2.exp
@@ -21,7 +21,8 @@ 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 } {
+if { [gcc_major_version "clang-*" "c++"] > 10
+     || [gcc_major_version "gcc-*" "c++"] >= 16} {
     lappend flags additional_flags=-Wno-non-c-typedef-for-linkage
 }
 
diff --git a/gdb/testsuite/gdb.cp/classes.exp b/gdb/testsuite/gdb.cp/classes.exp
index 71ce810adad..d2fb7c0c14c 100644
--- a/gdb/testsuite/gdb.cp/classes.exp
+++ b/gdb/testsuite/gdb.cp/classes.exp
@@ -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]} {
-- 
2.51.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] [gdb/testsuite] Fix ambiguous operator warning
  2026-05-29 12:51 ` [PATCH 1/2] [gdb/testsuite] Fix ambiguous operator warning Tom de Vries
@ 2026-05-29 16:23   ` Keith Seitz
  0 siblings, 0 replies; 6+ messages in thread
From: Keith Seitz @ 2026-05-29 16:23 UTC (permalink / raw)
  To: Tom de Vries, gdb-patches

On 5/29/26 5:51 AM, Tom de Vries wrote:
> With gcc 16, defaulting to c++20, and test-case gdb.cp/cmpd-minsyms.exp I run
> into:
> ...
> cmpd-minsyms.cc: In function 'int main(int, char**)':^M
> cmpd-minsyms.cc:39:13: warning: C++20 says that these are ambiguous, even \
>    though the second is reversed:^M
>     39 |    if (a == b)^M
>        |             ^^M
> cmpd-minsyms.cc:26:8: note: candidate 1: 'int GDB<T>::operator==(const GDB<T>&) [with T = int]'^M
>     26 |    int operator == (GDB const& other)^M
>        |        ^~~~~~~~^M
> cmpd-minsyms.cc:26:8: note: candidate 2: 'int GDB<T>::operator==(const GDB<T>&) [with T = int]' (reversed)^M
> cmpd-minsyms.cc:26:8: note: try making the operator a 'const' member function^M
> ...
> 
> Fix this by following the advice:
> ...
> -   int operator == (GDB const& other)
> +   int operator == (GDB const& other) const
>      { return 1; }
> ...
> 
> Likewise in gdb.cp/many-args.exp.

This LGTM.

Reviewed-By: Keith Seitz <keiths@redhat.com>

Keith


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] [gdb/testsuite] Use Wno-non-c-typedef-for-linkage for gcc 16
  2026-05-29 12:51 ` [PATCH 2/2] [gdb/testsuite] Use Wno-non-c-typedef-for-linkage for gcc 16 Tom de Vries
@ 2026-05-29 16:25   ` Keith Seitz
  2026-05-30  8:49     ` Tom de Vries
  0 siblings, 1 reply; 6+ messages in thread
From: Keith Seitz @ 2026-05-29 16:25 UTC (permalink / raw)
  To: Tom de Vries, gdb-patches

Hi,

On 5/29/26 5:51 AM, Tom de Vries wrote:
> 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.

This LGTM, just one little nit.

> diff --git a/gdb/testsuite/gdb.cp/class2.exp b/gdb/testsuite/gdb.cp/class2.exp
> index 705f51ac3e0..aa2a04467f4 100644
> --- a/gdb/testsuite/gdb.cp/class2.exp
> +++ b/gdb/testsuite/gdb.cp/class2.exp
> @@ -21,7 +21,8 @@ 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.

This comment could use a small update.

> -if { [gcc_major_version "clang-*" "c++"] > 10 } {
> +if { [gcc_major_version "clang-*" "c++"] > 10
> +     || [gcc_major_version "gcc-*" "c++"] >= 16} {
>       lappend flags additional_flags=-Wno-non-c-typedef-for-linkage
>   }
>   

Reviewed-By: Keith Seitz <keiths@redhat.com>

Thank you for fixing these.

Keith


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] [gdb/testsuite] Use Wno-non-c-typedef-for-linkage for gcc 16
  2026-05-29 16:25   ` Keith Seitz
@ 2026-05-30  8:49     ` Tom de Vries
  0 siblings, 0 replies; 6+ messages in thread
From: Tom de Vries @ 2026-05-30  8:49 UTC (permalink / raw)
  To: Keith Seitz, gdb-patches

On 5/29/26 6:25 PM, Keith Seitz wrote:
> Hi,
> 
> On 5/29/26 5:51 AM, Tom de Vries wrote:
>> 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.
> 
> This LGTM, just one little nit.
> 
>> diff --git a/gdb/testsuite/gdb.cp/class2.exp b/gdb/testsuite/gdb.cp/ 
>> class2.exp
>> index 705f51ac3e0..aa2a04467f4 100644
>> --- a/gdb/testsuite/gdb.cp/class2.exp
>> +++ b/gdb/testsuite/gdb.cp/class2.exp
>> @@ -21,7 +21,8 @@ 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.
> 
> This comment could use a small update.
> 

Hi Keith,

thanks for the reviews.

I've updated the comment to use "Clangs/GCCs".

I'll push this series after retesting on x86_64-linux.

Thanks,
- Tom

>> -if { [gcc_major_version "clang-*" "c++"] > 10 } {
>> +if { [gcc_major_version "clang-*" "c++"] > 10
>> +     || [gcc_major_version "gcc-*" "c++"] >= 16} {
>>       lappend flags additional_flags=-Wno-non-c-typedef-for-linkage
>>   }
> 
> Reviewed-By: Keith Seitz <keiths@redhat.com>
> 
> Thank you for fixing these.
> 
> Keith
> 


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-05-30  8:50 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-05-29 12:51 [PATCH 0/2] [gdb/testsuite] Handle gcc 16 Tom de Vries
2026-05-29 12:51 ` [PATCH 1/2] [gdb/testsuite] Fix ambiguous operator warning Tom de Vries
2026-05-29 16:23   ` Keith Seitz
2026-05-29 12:51 ` [PATCH 2/2] [gdb/testsuite] Use Wno-non-c-typedef-for-linkage for gcc 16 Tom de Vries
2026-05-29 16:25   ` Keith Seitz
2026-05-30  8:49     ` Tom de Vries

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox