public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Bruno Larsen <blarsen@redhat.com>
To: gdb-patches@sourceware.org
Cc: Bruno Larsen <blarsen@redhat.com>
Subject: [PATCH v2 1/9] gdb/testsuite: ignore Non-C-typedefs for gdb.cp/class2.exp
Date: Mon,  7 Nov 2022 14:45:57 +0100	[thread overview]
Message-ID: <20221107134604.596986-2-blarsen@redhat.com> (raw)
In-Reply-To: <20221107134604.596986-1-blarsen@redhat.com>

When attempting to test gdb.cp/class2.exp using Clang, it fails to
prepare with the following error:

Executing on host: clang++    -fdiagnostics-color=never -Wno-unknown-warning-option  -c -g -o /home/blarsen/Documents/fsf_build/gdb/testsuite/outputs/gdb.cp/class2/class20.o /home/blarsen/Documents/fsf_build/gdb/testsuite/../../../binutils-gdb/gdb/testsuite/gdb.cp/class2.cc    (timeout = 300)
builtin_spawn -ignore SIGHUP clang++ -fdiagnostics-color=never -Wno-unknown-warning-option -c -g -o /home/blarsen/Documents/fsf_build/gdb/testsuite/outputs/gdb.cp/class2/class20.o /home/blarsen/Documents/fsf_build/gdb/testsuite/../../../binutils-gdb/gdb/testsuite/gdb.cp/class2.cc
/home/blarsen/Documents/fsf_build/gdb/testsuite/../../../binutils-gdb/gdb/testsuite/gdb.cp/class2.cc:53:14: warning: anonymous non-C-compatible type given name for linkage purposes by typedef declaration; add a tag name here [-Wnon-c-typedef-for-linkage]
typedef class {
             ^
              Dbase
/home/blarsen/Documents/fsf_build/gdb/testsuite/../../../binutils-gdb/gdb/testsuite/gdb.cp/class2.cc:54:2: note: type is not C-compatible due to this member declaration
 public:
 ^~~~~~~
/home/blarsen/Documents/fsf_build/gdb/testsuite/../../../binutils-gdb/gdb/testsuite/gdb.cp/class2.cc:58:3: note: type is given name 'Dbase' for linkage purposes by this typedef declaration
} Dbase;
  ^
1 warning generated.
gdb compile failed, /home/blarsen/Documents/fsf_build/gdb/testsuite/../../../binutils-gdb/gdb/testsuite/gdb.cp/class2.cc:53:14: warning: anonymous non-C-compatible type given name for linkage purposes by typedef declaration; add a tag name here [-Wnon-c-typedef-for-linkage]
typedef class {
             ^
              Dbase
/home/blarsen/Documents/fsf_build/gdb/testsuite/../../../binutils-gdb/gdb/testsuite/gdb.cp/class2.cc:54:2: note: type is not C-compatible due to this member declaration
 public:
 ^~~~~~~
/home/blarsen/Documents/fsf_build/gdb/testsuite/../../../binutils-gdb/gdb/testsuite/gdb.cp/class2.cc:58:3: note: type is given name 'Dbase' for linkage purposes by this typedef declaration
} Dbase;
  ^
1 warning generated.
UNTESTED: gdb.cp/class2.exp: failed to prepare

This can be silenced by adding -Wno-non-c-typedef-for-linkage for Clang
11 or later.  The test shows no failures with this change.
---
 gdb/testsuite/gdb.cp/class2.exp | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/gdb/testsuite/gdb.cp/class2.exp b/gdb/testsuite/gdb.cp/class2.exp
index 32f9dfc18a5..cc192b6de64 100644
--- a/gdb/testsuite/gdb.cp/class2.exp
+++ b/gdb/testsuite/gdb.cp/class2.exp
@@ -18,7 +18,14 @@ if { [skip_cplus_tests] } { return }
 
 standard_testfile .cc
 
-if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug c++}]} {
+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 } {
+    lappend flags additional_flags=-Wno-non-c-typedef-for-linkage
+}
+
+if {[prepare_for_testing "failed to prepare" $testfile $srcfile $flags]} {
     return -1
 }
 
-- 
2.37.3


  reply	other threads:[~2022-11-07 13:52 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-07 13:45 [PATCH v2 0/9] Cleanup gdb.cp tests when running with clang Bruno Larsen
2022-11-07 13:45 ` Bruno Larsen [this message]
2022-11-07 13:45 ` [PATCH v2 2/9] gdb/testsuite: enable running gdb.cp/classes.exp " Bruno Larsen
2022-11-07 13:45 ` [PATCH v2 3/9] gdb/testsuite: account for clang's nested destructor calls on gdb.cp/mb-ctor.exp Bruno Larsen
2022-11-07 13:46 ` [PATCH v2 4/9] gdb/testsuite: add XFAIL to gdb.cp/derivation.exp when using Clang Bruno Larsen
2022-11-07 13:46 ` [PATCH v2 5/9] gdb/testsuite: allow for Clang style destructors on gdb.cp/m-static.exp Bruno Larsen
2022-11-07 13:46 ` [PATCH v2 6/9] gdb/testsuite: skip gdb.cp/anon-struct.exp when using Clang Bruno Larsen
2022-11-07 13:46 ` [PATCH v2 7/9] gdb/testsuite: disable some tests of gdb.cp/typeid.exp " Bruno Larsen
2022-11-07 13:46 ` [PATCH v2 8/9] gdb/testsuite: remove XFAIL on gdb.cp/temargs.exp Bruno Larsen
2022-11-10 18:21   ` Tom Tromey
2022-11-07 13:46 ` [PATCH v2 9/9] gdb/testsuite: disable gdb.cp/call-method-register.exp when not using gcc Bruno Larsen
2022-11-10 18:24 ` [PATCH v2 0/9] Cleanup gdb.cp tests when running with clang Tom Tromey
2022-11-11  8:38   ` Bruno Larsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221107134604.596986-2-blarsen@redhat.com \
    --to=blarsen@redhat.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).