[v4,1/2] gdb/testsuite: fix XPASSes when testing with clang
Checks
Context |
Check |
Description |
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 |
success
|
Build passed
|
linaro-tcwg-bot/tcwg_gdb_build--master-arm |
success
|
Build passed
|
linaro-tcwg-bot/tcwg_gdb_check--master-arm |
success
|
Test passed
|
Commit Message
Clang used to not add access specifiers for typedefs, and the tests
gdb.cp/ptype-flags.exp and gdb.cp/classes.exp both set XFAILs if clang
is being used to test. This was fixed on the clang 16.0.0 release,
generating many XPASSes. This current commit checks the clang version
used for testing, and only emits XFAIL on when a bad clang version is
used.
The testsuite didn't have a good way to check how an arbitrary
compiler's version compares to a specific version, so this commit adds a
TCL proc to do just that, inspired by the version_compare proc. The new
proc receives a version as a list, the comparison operation, and
optionally the compiler and language. The usage is slightly
counter-intuitive, as you ask the proc in a backwards way. To check if
clang is older than 16.0.0, you ask "is 16.0.0 greater than the clang
version?", but this was required in order to keep compiler and language
optional arguments.
---
gdb/testsuite/gdb.cp/classes.exp | 16 +++++++++-------
gdb/testsuite/gdb.cp/ptype-flags.exp | 11 +++++------
gdb/testsuite/lib/gdb.exp | 27 +++++++++++++++++++++++++++
3 files changed, 41 insertions(+), 13 deletions(-)
@@ -25,9 +25,11 @@ load_lib "cp-support.exp"
standard_testfile .cc
set flags [list debug c++]
-set clang_used false
+set using_broken_clang false
if { [test_compiler_info "clang-*" "c++"] } {
- set clang_used true
+ if { [compiler_version_compare [list "16" "0" "0"] ">" "clang" "c++"] } {
+ set using_broken_clang true
+ }
if { [gcc_major_version "clang-*" "c++"] >= 11} {
lappend flags additional_flags=-Wno-non-c-typedef-for-linkage
}
@@ -330,7 +332,7 @@ proc test_ptype_class_objects {} {
# Clang does not add access information for typedefs in classes.
# More information on: https://github.com/llvm/llvm-project/issues/57608
- if {$::clang_used} {
+ if {$::using_broken_clang} {
setup_xfail "clang 57608" *-*-*
}
@@ -354,7 +356,7 @@ proc test_ptype_class_objects {} {
{ typedef private "typedef int private_int;" }
}
- if {$::clang_used} {
+ if {$::using_broken_clang} {
setup_xfail "clang 57608" *-*-*
}
@@ -366,7 +368,7 @@ proc test_ptype_class_objects {} {
{ typedef public "typedef int INT;" }
}
- if {$::clang_used} {
+ if {$::using_broken_clang} {
setup_xfail "clang 57608" *-*-*
}
@@ -378,7 +380,7 @@ proc test_ptype_class_objects {} {
{ typedef protected "typedef int INT;" }
}
- if {$::clang_used} {
+ if {$::using_broken_clang} {
setup_xfail "clang 57608" *-*-*
}
@@ -390,7 +392,7 @@ proc test_ptype_class_objects {} {
{ typedef protected "typedef int INT;" }
}
- if {$::clang_used} {
+ if {$::using_broken_clang} {
setup_xfail "clang 57608" *-*-*
}
@@ -29,10 +29,9 @@ if {![runto_main]} {
return
}
-if {[test_compiler_info {clang-*-*} c++]} {
- set using_clang true
-} else {
- set using_clang false
+set using_broken_clang false
+if {[compiler_version_compare [list "16" "0" "0"] ">" "clang" "c++"]} {
+ set using_broken_clang true
}
gdb_test_no_output "set language c++" ""
@@ -40,7 +39,7 @@ gdb_test_no_output "set width 0" ""
proc do_check_holder {name {flags ""} {show_typedefs 1} {show_methods 1}
{raw 0}} {
- global using_clang
+ global using_broken_clang
set contents {
{ base "public Base<T>" }
@@ -57,7 +56,7 @@ proc do_check_holder {name {flags ""} {show_typedefs 1} {show_methods 1}
if {$show_typedefs} {
# Clang does not add accessibility information for typedefs:
# https://github.com/llvm/llvm-project/issues/57608
- if {$using_clang} {
+ if {$using_broken_clang} {
setup_xfail "clang 57608" *-*-*
}
lappend contents { typedef public "typedef Simple<Simple<T> > Z;" }
@@ -5489,6 +5489,33 @@ proc gcc_major_version { {compiler "gcc-*"} {language "c"} } {
return $major.$minor
}
+# Calculate how the compiler version compares to VERSION.
+# If the proc can't tell or the provided compiler is different
+# to what is being used to run the tests, it returns false.
+# VERSION must be a list like "$major $minor". To manage
+# optional arguments, the way you call this proc is counter
+# intuitive. For example, if you want to check if gcc is older
+# than 10.0, you call:
+# compiler_version_compare [list 10 0] ">"
+# because you want the version 10.0 to be greater than the
+# current gcc version.
+
+proc compiler_version_compare { version op {compiler "gcc"} \
+ {language "c"} } {
+ global decimal
+
+ set res [regexp $compiler-($decimal)-($decimal)-($decimal) \
+ [test_compiler_info "" $language] dummy major minor point]
+
+ # We either can't determine the compiler, or the compiler is
+ # different than provided
+ if { $res != 1} {
+ return false
+ }
+
+ return [version_compare $version $op [list $major $minor $point]]
+}
+
proc current_target_name { } {
global target_info
if [info exists target_info(target,name)] {