[pushed 1/3] [gdb/testsuite] Handle gdb.cp/*.exp with older compiler
Tom de Vries
tdevries@suse.de
Mon Aug 28 11:47:00 GMT 2023
When running test-cases gdb.cp/*.exp with gcc 4.8.4, I run into compilation
failures due to the test-cases requiring c++11 and the compiler defaulting
to less than that.
Fix this by compiling with -std=c++11.
This exposes two FAILs in gdb/testsuite/gdb.cp/empty-enum.exp due to
gcc PR debug/16063, so xfail those.
Also require have_compile_flag -std=c++17 in gdb.cp/constexpr-field.exp to
prevent compilation failure.
Tested on x86_64-linux.
---
gdb/testsuite/gdb.cp/casts.exp | 7 ++++-
gdb/testsuite/gdb.cp/constexpr-field.exp | 1 +
gdb/testsuite/gdb.cp/empty-enum.exp | 35 +++++++++++++++++++++--
gdb/testsuite/gdb.cp/koenig.exp | 9 ++++--
gdb/testsuite/gdb.cp/method-call-in-c.exp | 6 +++-
gdb/testsuite/gdb.cp/paramless.exp | 7 ++++-
gdb/testsuite/gdb.cp/templates.exp | 2 ++
gdb/testsuite/gdb.cp/typed-enum.exp | 7 ++++-
8 files changed, 65 insertions(+), 9 deletions(-)
diff --git a/gdb/testsuite/gdb.cp/casts.exp b/gdb/testsuite/gdb.cp/casts.exp
index ac798f9070f..41bb1259270 100644
--- a/gdb/testsuite/gdb.cp/casts.exp
+++ b/gdb/testsuite/gdb.cp/casts.exp
@@ -29,7 +29,12 @@ require allow_cplus_tests
standard_testfile .cc casts03.cc
-if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug c++}]} {
+set opts {}
+lappend opts debug
+lappend opts c++
+lappend opts additional_flags=-std=c++11
+
+if {[prepare_for_testing "failed to prepare" $testfile $srcfile $opts]} {
return -1
}
diff --git a/gdb/testsuite/gdb.cp/constexpr-field.exp b/gdb/testsuite/gdb.cp/constexpr-field.exp
index 18dcb0e91b7..dd8bf9a2e5d 100644
--- a/gdb/testsuite/gdb.cp/constexpr-field.exp
+++ b/gdb/testsuite/gdb.cp/constexpr-field.exp
@@ -16,6 +16,7 @@
# This file is part of the gdb testsuite.
require allow_cplus_tests
+require {have_compile_flag -std=c++17}
standard_testfile .cc
diff --git a/gdb/testsuite/gdb.cp/empty-enum.exp b/gdb/testsuite/gdb.cp/empty-enum.exp
index 83cb8cb3973..9ab3abf14b7 100644
--- a/gdb/testsuite/gdb.cp/empty-enum.exp
+++ b/gdb/testsuite/gdb.cp/empty-enum.exp
@@ -29,7 +29,11 @@
standard_testfile .cc
-if {[prepare_for_testing "failed to prepare" $testfile $srcfile]} {
+set opts {}
+lappend opts debug
+lappend opts additional_flags=-std=c++11
+
+if {[prepare_for_testing "failed to prepare" $testfile $srcfile $opts]} {
return -1
}
@@ -44,5 +48,30 @@ gdb_continue_to_breakpoint "stop in breakpt"
gdb_test "print arg1" " = 8"
gdb_test "print arg2" " = 4"
-gdb_test "ptype arg1" "type = enum enum1 : unsigned int \\{\\}"
-gdb_test "ptype arg2" "type = enum class enum2 : unsigned char \\{\\}"
+
+# Xfail for missing DW_AT_type in DW_TAG_enumeration_type, gcc PR debug/16063.
+set have_xfail [expr [test_compiler_info gcc-*] && [gcc_major_version] < 5]
+
+gdb_test_multiple "ptype arg1" "" {
+ -re -wrap "type = enum enum1 : unsigned int \\{\\}" {
+ pass $gdb_test_name
+ }
+ -re -wrap "type = enum enum1 \\{\\}" {
+ if { $have_xfail } {
+ setup_xfail *-*-* gcc/16063
+ }
+ fail $gdb_test_name
+ }
+}
+
+gdb_test_multiple "ptype arg2" "" {
+ -re -wrap "type = enum class enum2 : unsigned char \\{\\}" {
+ pass $gdb_test_name
+ }
+ -re -wrap "type = enum class enum2 \\{\\}" {
+ if { $have_xfail } {
+ setup_xfail *-*-* gcc/16063
+ }
+ fail $gdb_test_name
+ }
+}
diff --git a/gdb/testsuite/gdb.cp/koenig.exp b/gdb/testsuite/gdb.cp/koenig.exp
index 5343f2cbf06..dbec6d2e7f2 100644
--- a/gdb/testsuite/gdb.cp/koenig.exp
+++ b/gdb/testsuite/gdb.cp/koenig.exp
@@ -15,8 +15,13 @@
standard_testfile .cc
-if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
- {debug c++ additional_flags=-Wno-unused-comparison}] } {
+set opts {}
+lappend opts debug
+lappend opts c++
+lappend opts additional_flags=-Wno-unused-comparison
+lappend opts additional_flags=-std=c++11
+
+if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} $opts] } {
return -1
}
diff --git a/gdb/testsuite/gdb.cp/method-call-in-c.exp b/gdb/testsuite/gdb.cp/method-call-in-c.exp
index 269657068cf..1c18d81104e 100644
--- a/gdb/testsuite/gdb.cp/method-call-in-c.exp
+++ b/gdb/testsuite/gdb.cp/method-call-in-c.exp
@@ -20,7 +20,11 @@
standard_testfile .cc
-if { [prepare_for_testing "failed to prepare" $testfile $srcfile] } {
+set opts {}
+lappend opts debug
+lappend opts additional_flags=-std=c++11
+
+if { [prepare_for_testing "failed to prepare" $testfile $srcfile $opts] } {
return -1
}
diff --git a/gdb/testsuite/gdb.cp/paramless.exp b/gdb/testsuite/gdb.cp/paramless.exp
index 579f363d6a0..895b449f146 100644
--- a/gdb/testsuite/gdb.cp/paramless.exp
+++ b/gdb/testsuite/gdb.cp/paramless.exp
@@ -21,7 +21,12 @@ require allow_cplus_tests
standard_testfile .cc
-if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug c++}]} {
+set opts {}
+lappend opts debug
+lappend opts c++
+lappend opts additional_flags=-std=c++11
+
+if {[prepare_for_testing "failed to prepare" $testfile $srcfile $opts]} {
return -1
}
diff --git a/gdb/testsuite/gdb.cp/templates.exp b/gdb/testsuite/gdb.cp/templates.exp
index ba21c4727d3..7603d89572a 100644
--- a/gdb/testsuite/gdb.cp/templates.exp
+++ b/gdb/testsuite/gdb.cp/templates.exp
@@ -22,6 +22,8 @@ require allow_cplus_tests
standard_testfile .cc
set flags [list debug c++]
+lappend flags additional_flags=-std=c++11
+
if { [test_compiler_info gcc-*] && [gcc_major_version] >= 10 } {
# Work around PR gcc/101452.
lappend flags additional_flags=-DGCC_BUG
diff --git a/gdb/testsuite/gdb.cp/typed-enum.exp b/gdb/testsuite/gdb.cp/typed-enum.exp
index 1d11fb5a302..6a1df7053c6 100644
--- a/gdb/testsuite/gdb.cp/typed-enum.exp
+++ b/gdb/testsuite/gdb.cp/typed-enum.exp
@@ -19,7 +19,12 @@ require allow_cplus_tests
standard_testfile .cc
-if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug c++}]} {
+set opts {}
+lappend opts debug
+lappend opts c++
+lappend opts additional_flags=-std=c++11
+
+if {[prepare_for_testing "failed to prepare" $testfile $srcfile $opts]} {
return -1
}
base-commit: 025e84f93566c8ced594ef48ddee1dec7e5b4cdd
--
2.35.3
More information about the Gdb-patches
mailing list