aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.fortran
diff options
context:
space:
mode:
authorCristian Sandu <cristian.sandu@intel.com>2022-05-31 16:43:44 +0200
committerNils-Christian Kempke <nils-christian.kempke@intel.com>2022-05-31 16:44:54 +0200
commit44d469c5f85a4243462b8966722dafa62b602bf5 (patch)
tree89b8401b36dd3ff9f87f25bc926aa74bbabe09c1 /gdb/testsuite/gdb.fortran
parent7ce4a6d1846fae44b25c1733164451a316f22567 (diff)
downloadgdb-44d469c5f85a4243462b8966722dafa62b602bf5.zip
gdb-44d469c5f85a4243462b8966722dafa62b602bf5.tar.gz
gdb-44d469c5f85a4243462b8966722dafa62b602bf5.tar.bz2
gdb/testsuite: add Fortran compiler identification to GDB
This commit adds a separate Fortran compiler identification mechanism to the testsuite, similar to the existing one for C/C++. Before this change, the options and version for the Fortran compiler specified when running the testsuite with F90_FOR_TARGET set, was detected via its respective C compiler. So running the testsuite as make check TEST=gdb.fortran/*.exp CC_FOR_TARGET=gcc F90_FOR_TARGET=ifx or even make check TEST=gdb.fortran/*.exp F90_FOR_TARGET=ifx would use the gcc compiler inside the procedures get_compiler_info and test_compiler_info to identify compiler flags and the compiler version. This could sometimes lead to unpredictable outputs. It also limited testsuite execution to combinations where C and Fortran compiler would come from the same family of compiers (gcc/gfortran, icc/ifort, icx/ifx, clang/flang ..). This commit enables GDB to detect C and Fortran compilers independently of each other. As most/nearly all Fortran compilers have a mechanism for preprocessing files in a C like fashion we added the exact same meachnism that already existed for C/CXX. We let GDB preprocess a file with the compilers Fortran preprocessor and evaluate the preprocessor defined macros in that file. This enables GDB to properly run heterogeneous combinations of C and Fortran compilers such as CC_FOR_TARGET='gcc' and F90_FOR_TARGET='ifort' or enables one to run the testsuite without specifying a C compiler as in make check TESTS=gdb.fortran/*.exp F90_FOR_TARGET='ifx' make check TESTS=gdb.fortran/*.exp F90_FOR_TARGET='flang' On the other hand this also requires one to always specify a identification mechanism for Fortran compilers in the compiler.F90 file. We added identification for GFORTRAN, FLANG (CLASSIC and LLVM) IFX, IFORT, and ARMFLANG for now. Classic and LLVM flang were each tested with their latest releases on their respective release pages. Both get recognized by the new compiler identification and we introduced the two names flang-classic and flang-llvm to distinguish the two. While LLVM flang is not quite mature enough yet for running the testsuite we still thought it would be a good idea to include it already. For this we added a case for the fortran_main procedure. LLVM flang uses 'MAIN__' as opposed to classic flang which uses 'MAIN_' here. We did not have the possibility to test ARMFLANG - the versioning scheme here was extracted from its latest online documentation. We changed the test_compiler_info procedure to take another optional argument, the language string, which will be passed though to the get_compiler_info procedure. Passing 'f90' or 'c++' here will then trigger the C++/Fortran compiler identification within get_compiler_info. The latter procedure was extended to also handle the 'f90' argument (similarly to the already existing 'c++' one). Co-authored-by: Nils-Christian Kempke <nils-christian.kempke@intel.com>
Diffstat (limited to 'gdb/testsuite/gdb.fortran')
-rw-r--r--gdb/testsuite/gdb.fortran/assumedrank.exp6
-rw-r--r--gdb/testsuite/gdb.fortran/class-allocatable-array.exp4
-rw-r--r--gdb/testsuite/gdb.fortran/derived-type-striding.exp2
-rw-r--r--gdb/testsuite/gdb.fortran/library-module.exp2
-rw-r--r--gdb/testsuite/gdb.fortran/namelist.exp2
-rw-r--r--gdb/testsuite/gdb.fortran/nested-funcs-2.exp3
-rw-r--r--gdb/testsuite/gdb.fortran/ptype-on-functions.exp6
-rwxr-xr-xgdb/testsuite/gdb.fortran/vla-type.exp2
8 files changed, 14 insertions, 13 deletions
diff --git a/gdb/testsuite/gdb.fortran/assumedrank.exp b/gdb/testsuite/gdb.fortran/assumedrank.exp
index e9429b4..37bb825 100644
--- a/gdb/testsuite/gdb.fortran/assumedrank.exp
+++ b/gdb/testsuite/gdb.fortran/assumedrank.exp
@@ -21,8 +21,8 @@ standard_testfile ".f90"
load_lib fortran.exp
# Only gcc version >=11 supports assumed rank arrays.
-if { [test_compiler_info gcc*] &&
- ![test_compiler_info {gcc-1[1-9]-*}]} {
+if { [test_compiler_info {gfortran-*} f90] &&
+ ![test_compiler_info {gfortran-1[1-9]-*} f90] } {
untested "compiler does not support assumed rank"
return -1
}
@@ -59,7 +59,7 @@ while { $test_count < 500 } {
}
# Currently, flang does not support rank0.
- if {$test_count == 1 && [test_compiler_info {clang-*}]} {
+ if { $test_count == 1 && [test_compiler_info {flang-*} f90] } {
unsupported "compiler does not support rank 0"
continue
}
diff --git a/gdb/testsuite/gdb.fortran/class-allocatable-array.exp b/gdb/testsuite/gdb.fortran/class-allocatable-array.exp
index 3e92f80..30bdcb0 100644
--- a/gdb/testsuite/gdb.fortran/class-allocatable-array.exp
+++ b/gdb/testsuite/gdb.fortran/class-allocatable-array.exp
@@ -37,8 +37,8 @@ gdb_continue_to_breakpoint "Break Here"
# different names, or maybe a completely different approach, for
# representing class like structures. The following tests are
# cetainly going to fail.
-# Hence the test case is modified for clang.
-if {[test_compiler_info {clang-*}]} {
+# Hence the test case is modified for flang.
+if { [test_compiler_info {flang-*} f90] } {
gdb_test "print this" " = \\( a = 0, b = \\(\\(1, 2, 3\\) \\(4, 5, 6\\)\\) \\)"
gdb_test "print this%a" " = 0"
gdb_test "print this%b" " = \\(\\(1, 2, 3\\) \\(4, 5, 6\\)\\)"
diff --git a/gdb/testsuite/gdb.fortran/derived-type-striding.exp b/gdb/testsuite/gdb.fortran/derived-type-striding.exp
index f8062b5..1edc489 100644
--- a/gdb/testsuite/gdb.fortran/derived-type-striding.exp
+++ b/gdb/testsuite/gdb.fortran/derived-type-striding.exp
@@ -22,7 +22,7 @@ standard_testfile ".f90"
# Unfortunately recent versions of GCC broke the stride information in
# the DEBUG so tests in this file will fail.
-set gcc_with_broken_stride [test_compiler_info {gcc-[89]-*}]
+set gcc_with_broken_stride [test_compiler_info {gfortran-[89]-*} f90]
if {[prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
{debug f90}]} {
diff --git a/gdb/testsuite/gdb.fortran/library-module.exp b/gdb/testsuite/gdb.fortran/library-module.exp
index 09013b0..a28dc36 100644
--- a/gdb/testsuite/gdb.fortran/library-module.exp
+++ b/gdb/testsuite/gdb.fortran/library-module.exp
@@ -22,7 +22,7 @@ set srclibfile ${testfile}-lib.f90
set libfile [standard_output_file ${testfile}-lib.so]
# Required for -fPIC by gdb_compile_shlib.
-if [get_compiler_info] {
+if { [get_compiler_info f90] } {
warning "Could not get compiler info"
return -1
}
diff --git a/gdb/testsuite/gdb.fortran/namelist.exp b/gdb/testsuite/gdb.fortran/namelist.exp
index c7c92c1..3917f1b 100644
--- a/gdb/testsuite/gdb.fortran/namelist.exp
+++ b/gdb/testsuite/gdb.fortran/namelist.exp
@@ -37,7 +37,7 @@ set int [fortran_int4]
gdb_breakpoint [gdb_get_line_number "Display namelist"]
gdb_continue_to_breakpoint "Display namelist"
-if {[test_compiler_info {gcc-*}]} {
+if { [test_compiler_info {gfortran-*} f90] } {
gdb_test "ptype nml" \
"type = Type nml\r\n *$int :: a\r\n *$int :: b\r\n *End Type nml"
gdb_test "print nml" \
diff --git a/gdb/testsuite/gdb.fortran/nested-funcs-2.exp b/gdb/testsuite/gdb.fortran/nested-funcs-2.exp
index 3c8a536..bf67944 100644
--- a/gdb/testsuite/gdb.fortran/nested-funcs-2.exp
+++ b/gdb/testsuite/gdb.fortran/nested-funcs-2.exp
@@ -68,7 +68,8 @@ proc do_bp_tests {with_src_prefix_p with_nest_prefix_p} {
# mangling.
proc get_linkage_name_pattern {symbol_name} {
- if { [test_compiler_info icc*] || [test_compiler_info intel*]} {
+ if { [test_compiler_info {ifort-*} f90]
+ || [test_compiler_info {ifx-*} f90] } {
return "\(?:.*_\)?${symbol_name}_?"
} else {
return ${symbol_name}
diff --git a/gdb/testsuite/gdb.fortran/ptype-on-functions.exp b/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
index 8c49781..cc24548 100644
--- a/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
+++ b/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
@@ -40,7 +40,7 @@ set integer8 [fortran_int8]
# https://gcc.gnu.org/onlinedocs/gfortran/Argument-passing-conventions.html ).
set stringlen ($integer8|$integer4)
-if {[test_compiler_info {clang-*}]} {
+if { [test_compiler_info {flang-*} f90] } {
set some_module_class_type "Type number"
set some_module_aux_info ", $integer8 \\(10\\)"
} else {
@@ -61,7 +61,7 @@ gdb_test "ptype say_numbers" \
"type = void \\($integer4, $integer4, $integer4\\)"
set fun_ptr_arg "$integer4"
-if {[test_compiler_info {gcc-*}]} {
+if { [test_compiler_info {gfortran-*} f90] } {
set fun_ptr_arg "REF TO -> \\( ${fun_ptr_arg} \\)"
}
@@ -72,7 +72,7 @@ gdb_test "ptype say_string" \
"type = void \\(character\[^,\]+, $stringlen\\)"
set say_array_artificial_first_arg ""
-if {[test_compiler_info {clang-*}]} {
+if { [test_compiler_info {flang-*} f90] } {
set say_array_artificial_first_arg "$integer8, "
}
diff --git a/gdb/testsuite/gdb.fortran/vla-type.exp b/gdb/testsuite/gdb.fortran/vla-type.exp
index 4ec68c4..fc8494f 100755
--- a/gdb/testsuite/gdb.fortran/vla-type.exp
+++ b/gdb/testsuite/gdb.fortran/vla-type.exp
@@ -33,7 +33,7 @@ set int [fortran_int4]
# Check if not allocated VLA in type does not break
# the debugger when accessing it.
# break main for Flang compiler already breaks here
-if ![test_compiler_info "clang-*"] {
+if { ![test_compiler_info {flang-*} f90] } {
gdb_breakpoint [gdb_get_line_number "before-allocated"]
gdb_continue_to_breakpoint "before-allocated"
}