public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Gary Benson <gbenson@redhat.com>
To: gdb-patches@sourceware.org
Cc: Pedro Alves <pedro@palves.net>,
	Luis Machado <luis.machado@linaro.org>,
	Simon Marchi <simark@simark.ca>
Subject: [PUSHED] Skip tests requiring "alignof (void)" when compiling using clang
Date: Mon, 20 Jul 2020 15:10:29 +0100	[thread overview]
Message-ID: <1595254229-20136-1-git-send-email-gbenson@redhat.com> (raw)
In-Reply-To: <d6a883c2-24dc-480a-8a23-f933b63dc166@palves.net>

Hi all,

Thanks for the reviews.  This is the version that I pushed.
The last part isn't exactly as Pedro suggested, so I hope
it's ok!

Cheers,
Gary

--
As an extension, GCC allows void pointer arithmetic, with sizeof(void)
and alignof(void) both 1.  GDB supports this extension, but clang does
not, and fails to compile the generated output of gdb.cp/align.exp
with the following error:

 gdb compile failed, /gdbtest/build/gdb/testsuite/outputs/gdb.cp/align/align.cc:28:23:
       error: invalid application of 'alignof' to an incomplete type 'void'
    unsigned a_void = alignof (void);
                      ^       ~~~~~~
 1 error generated.

This commit adds preprocessor conditionals to the generated output, to
omit the unsupported code when using clang, and supplies the expected
value so the test can complete.

gdb/testsuite/ChangeLog:

	* gdb.cp/align.exp: Fix "alignof (void)" tests when compiling
	with clang.
---
 gdb/testsuite/ChangeLog        |  5 +++++
 gdb/testsuite/gdb.cp/align.exp | 13 ++++++++++++-
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/gdb/testsuite/gdb.cp/align.exp b/gdb/testsuite/gdb.cp/align.exp
index 0905a27..4894de0 100644
--- a/gdb/testsuite/gdb.cp/align.exp
+++ b/gdb/testsuite/gdb.cp/align.exp
@@ -80,7 +80,9 @@ puts $outfile {
 
     unsigned a_int3 = alignof (int[3]);
 
+#if !defined (__clang__)
     unsigned a_void = alignof (void);
+#endif
 
     struct base { char c; };
     struct derived : public virtual base { int i; };
@@ -170,5 +172,14 @@ foreach type $typelist {
 
 set expected [get_integer_valueof a_int3 0]
 gdb_test "print alignof(int\[3\])" " = $expected"
-set expected [get_integer_valueof a_void 0]
+
+# As an extension, GCC allows void pointer arithmetic, with
+# sizeof(void) and alignof(void) both 1.  This test checks
+# GDB's support of GCC's extension.
+if [test_compiler_info clang*] {
+    # Clang doesn't support GCC's extension.
+    set expected 1
+} else {
+    set expected [get_integer_valueof a_void 0]
+}
 gdb_test "print alignof(void)" " = $expected"
-- 
1.8.3.1


      parent reply	other threads:[~2020-07-20 14:10 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-30 15:03 [PATCH] " Gary Benson
2020-06-30 17:10 ` Luis Machado
2020-07-02 20:50   ` Pedro Alves
2020-07-02 20:49 ` Pedro Alves
2020-07-02 20:52   ` Simon Marchi
2020-07-02 21:08     ` Pedro Alves
2020-07-20 14:10   ` Gary Benson [this message]

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=1595254229-20136-1-git-send-email-gbenson@redhat.com \
    --to=gbenson@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=luis.machado@linaro.org \
    --cc=pedro@palves.net \
    --cc=simark@simark.ca \
    /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).