aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGary Benson <gbenson@redhat.com>2020-07-20 15:01:04 +0100
committerGary Benson <gbenson@redhat.com>2020-07-20 15:01:04 +0100
commitc14b49135568f7fa17a9df19e85a454581617468 (patch)
treeb79f0023808b02c3cd4e90925c6434fbd1255fc1
parent39326c35dd8f1a154cfe15ca640d73873f2df572 (diff)
downloadgdb-c14b49135568f7fa17a9df19e85a454581617468.zip
gdb-c14b49135568f7fa17a9df19e85a454581617468.tar.gz
gdb-c14b49135568f7fa17a9df19e85a454581617468.tar.bz2
Skip tests requiring "alignof (void)" when compiling using clang
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.
-rw-r--r--gdb/testsuite/ChangeLog5
-rw-r--r--gdb/testsuite/gdb.cp/align.exp13
2 files changed, 17 insertions, 1 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 9e2e7e2..d0b848b 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2020-07-20 Gary Benson <gbenson@redhat.com>
+
+ * gdb.cp/align.exp: Fix "alignof (void)" tests when compiling
+ with clang.
+
2020-07-20 Tom de Vries <tdevries@suse.de>
* gdb.threads/omp-par-scope.c (lock, lock2): New variable.
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"