From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7876) id AC4CE395A00B; Tue, 31 May 2022 14:45:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AC4CE395A00B Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Nils-Christian Kempke To: gdb-cvs@sourceware.org Subject: [binutils-gdb] gdb/testsuite: add Fortran compiler identification to GDB X-Act-Checkin: binutils-gdb X-Git-Author: Cristian Sandu X-Git-Refname: refs/heads/master X-Git-Oldrev: 7ce4a6d1846fae44b25c1733164451a316f22567 X-Git-Newrev: 44d469c5f85a4243462b8966722dafa62b602bf5 Message-Id: <20220531144533.AC4CE395A00B@sourceware.org> Date: Tue, 31 May 2022 14:45:33 +0000 (GMT) X-BeenThere: gdb-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 31 May 2022 14:45:33 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D44d469c5f85a= 4243462b8966722dafa62b602bf5 commit 44d469c5f85a4243462b8966722dafa62b602bf5 Author: Cristian Sandu Date: Tue May 31 16:43:44 2022 +0200 gdb/testsuite: add Fortran compiler identification to GDB =20 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 =20 make check TEST=3Dgdb.fortran/*.exp CC_FOR_TARGET=3Dgcc F90_FOR_TARGE= T=3Difx =20 or even =20 make check TEST=3Dgdb.fortran/*.exp F90_FOR_TARGET=3Difx =20 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. =20 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 th= at file. =20 This enables GDB to properly run heterogeneous combinations of C and Fortran compilers such as =20 CC_FOR_TARGET=3D'gcc' and F90_FOR_TARGET=3D'ifort' =20 or enables one to run the testsuite without specifying a C compiler as = in =20 make check TESTS=3Dgdb.fortran/*.exp F90_FOR_TARGET=3D'ifx' make check TESTS=3Dgdb.fortran/*.exp F90_FOR_TARGET=3D'flang' =20 On the other hand this also requires one to always specify a identification mechanism for Fortran compilers in the compiler.F90 file. =20 We added identification for GFORTRAN, FLANG (CLASSIC and LLVM) IFX, IFORT, and ARMFLANG for now. =20 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_m= ain procedure. LLVM flang uses 'MAIN__' as opposed to classic flang which uses 'MAIN_' here. =20 We did not have the possibility to test ARMFLANG - the versioning scheme here was extracted from its latest online documentation. =20 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). =20 Co-authored-by: Nils-Christian Kempke Diff: --- gdb/testsuite/gdb.fortran/assumedrank.exp | 6 +- .../gdb.fortran/class-allocatable-array.exp | 4 +- .../gdb.fortran/derived-type-striding.exp | 2 +- gdb/testsuite/gdb.fortran/library-module.exp | 2 +- gdb/testsuite/gdb.fortran/namelist.exp | 2 +- gdb/testsuite/gdb.fortran/nested-funcs-2.exp | 3 +- gdb/testsuite/gdb.fortran/ptype-on-functions.exp | 6 +- gdb/testsuite/gdb.fortran/vla-type.exp | 2 +- gdb/testsuite/lib/compiler.F90 | 69 ++++++++++++++ gdb/testsuite/lib/fortran.exp | 100 ++++++++++-------= ---- gdb/testsuite/lib/gdb.exp | 24 +++-- 11 files changed, 150 insertions(+), 70 deletions(-) diff --git a/gdb/testsuite/gdb.fortran/assumedrank.exp b/gdb/testsuite/gdb.= fortran/assumedrank.exp index e9429b44a9a..37bb825d164 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 =20 # Only gcc version >=3D11 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 } { } =20 # Currently, flang does not support rank0. - if {$test_count =3D=3D 1 && [test_compiler_info {clang-*}]} { + if { $test_count =3D=3D 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/te= stsuite/gdb.fortran/class-allocatable-array.exp index 3e92f804b13..30bdcb01652 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" " =3D \\( a =3D 0, b =3D \\(\\(1, 2, 3\\) \\(4, = 5, 6\\)\\) \\)" gdb_test "print this%a" " =3D 0" gdb_test "print this%b" " =3D \\(\\(1, 2, 3\\) \\(4, 5, 6\\)\\)" diff --git a/gdb/testsuite/gdb.fortran/derived-type-striding.exp b/gdb/test= suite/gdb.fortran/derived-type-striding.exp index f8062b56572..1edc489bcfb 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" =20 # 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] =20 if {[prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \ {debug f90}]} { diff --git a/gdb/testsuite/gdb.fortran/library-module.exp b/gdb/testsuite/g= db.fortran/library-module.exp index 09013b05447..a28dc3634cc 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] =20 # 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.for= tran/namelist.exp index c7c92c1349c..3917f1b9adb 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" =20 -if {[test_compiler_info {gcc-*}]} { +if { [test_compiler_info {gfortran-*} f90] } { gdb_test "ptype nml" \ "type =3D 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/g= db.fortran/nested-funcs-2.exp index 3c8a5364efa..bf679447c03 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} { =20 - 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/testsui= te/gdb.fortran/ptype-on-functions.exp index 8c497810534..cc2454858a0 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.htm= l ). set stringlen ($integer8|$integer4) =20 -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 =3D void \\($integer4, $integer4, $integer4\\)" =20 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} \\)" } =20 @@ -72,7 +72,7 @@ gdb_test "ptype say_string" \ "type =3D void \\(character\[^,\]+, $stringlen\\)" =20 set say_array_artificial_first_arg "" -if {[test_compiler_info {clang-*}]} { +if { [test_compiler_info {flang-*} f90] } { set say_array_artificial_first_arg "$integer8, " } =20 diff --git a/gdb/testsuite/gdb.fortran/vla-type.exp b/gdb/testsuite/gdb.for= tran/vla-type.exp index 4ec68c47606..fc8494fe36c 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" } diff --git a/gdb/testsuite/lib/compiler.F90 b/gdb/testsuite/lib/compiler.F90 new file mode 100644 index 00000000000..71cf3d2c2b2 --- /dev/null +++ b/gdb/testsuite/lib/compiler.F90 @@ -0,0 +1,69 @@ +/* Copyright 2022 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . = */ + +set compiler_info "unknown" + +#if defined (__GFORTRAN__) +set compiler_info [join {gfortran __GNUC__ __GNUC_MINOR__ __GNUC_PATCHLEVE= L__} -] +#endif + +/* ARM seems to not define a patch version. */ +#if defined (__ARM_LINUX_COMPILER__) +set compiler_info [join {armflang __armclang_major__ __armclang_minor__ 0}= -] +#endif + +/* Classic flang and LLVM flang emit their respective macros differently. = */ + +/* LLVM flang complains about non Fortran tokens so we do not use "{" here= . */ +#if defined (__flang__) +set major __flang_major__ +set minor __flang_minor__ +set patch __flang_patchlevel__ +set compiler_info [join "flang-llvm $major $minor $patch" -] +#endif + +/* Classic Flang. */ +#if defined (__FLANG) +set compiler_info [join {flang-classic __FLANG_MAJOR__ __FLANG_MINOR__ __F= LANG_PATCHLEVEL__} -] +#endif + +/* Intel LLVM emits a string like 20220100 with version 2021.2.0 and highe= r. */ +#if defined (__INTEL_LLVM_COMPILER) +set major [string range __INTEL_LLVM_COMPILER 0 3] +set minor [string range __INTEL_LLVM_COMPILER 4 5] +set patch [string range __INTEL_LLVM_COMPILER 6 7] +set compiler_info [join "ifx $major $minor $patch" -] +#elif defined (__INTEL_COMPILER) +/* Starting with 2021 the ifort versioning scheme changed. Before, Intel = ifort + would define its version as e.g. 19.0.0 or rather __INTEL_COMPILER woul= d be + emitted as 1900. With 2021 the versioning became e.g. 2021.1 defined in + __INTEL_COMPILER.__INTEL_COMPILER_UPDATE. No patch is emitted since the + change. This compiler identification might not work with ifort versions + smaller than 10. */ +#if (__INTEL_COMPILER < 2021) +set major [string range __INTEL_COMPILER 0 1] +set minor [string range __INTEL_COMPILER 2 2] +#if defined (__INTEL_COMPILER_UPDATE) +set patch __INTEL_COMPILER_UPDATE +#else +set patch [string range __INTEL_COMPILER 3 3] +#endif +#else +set major __INTEL_COMPILER +set minor __INTEL_COMPILER_UPDATE +set patch 0 +#endif +set compiler_info [join "ifort $major $minor $patch" -] +#endif diff --git a/gdb/testsuite/lib/fortran.exp b/gdb/testsuite/lib/fortran.exp index 9531d393a1b..9ee4208fb88 100644 --- a/gdb/testsuite/lib/fortran.exp +++ b/gdb/testsuite/lib/fortran.exp @@ -30,15 +30,15 @@ proc set_lang_fortran {} { } =20 proc fortran_int4 {} { - if {[test_compiler_info {gcc-4-[012]-*}]} { + if {[test_compiler_info {gfortran-4-[012]-*} f90]} { return "int4" - } elseif {[test_compiler_info {gcc-*}]} { + } elseif {[test_compiler_info {gfortran-*} f90]} { return "integer\\(kind=3D4\\)" - } elseif {[test_compiler_info {clang-*}]} { + } elseif {[test_compiler_info {flang-*} f90]} { return "integer" - } elseif {[test_compiler_info {icc-*}]} { + } elseif {[test_compiler_info {ifort-*} f90]} { return "INTEGER\\(4\\)" - } elseif {[test_compiler_info {intel-*}]} { + } elseif {[test_compiler_info {ifx-*} f90]} { return "INTEGER\\*4" } else { return "unknown" @@ -46,15 +46,15 @@ proc fortran_int4 {} { } =20 proc fortran_int8 {} { - if {[test_compiler_info {gcc-4-[012]-*}]} { + if {[test_compiler_info {gfortran-4-[012]-*} f90]} { return "int8" - } elseif {[test_compiler_info {gcc-*}]} { + } elseif {[test_compiler_info {gfortran-*} f90]} { return "integer\\(kind=3D8\\)" - } elseif {[test_compiler_info {clang-*}]} { + } elseif {[test_compiler_info {flang-*} f90]} { return "integer\\*8" - } elseif {[test_compiler_info {icc-*}]} { + } elseif {[test_compiler_info {ifort-*} f90]} { return "INTEGER\\(8\\)" - } elseif {[test_compiler_info {intel-*}]} { + } elseif {[test_compiler_info {ifx-*} f90]} { return "INTEGER\\*8" } else { return "unknown" @@ -62,15 +62,15 @@ proc fortran_int8 {} { } =20 proc fortran_real4 {} { - if {[test_compiler_info {gcc-4-[012]-*}]} { + if {[test_compiler_info {gfortran-4-[012]-*} f90]} { return "real4" - } elseif {[test_compiler_info {gcc-*}]} { + } elseif {[test_compiler_info {gfortran-*} f90]} { return "real\\(kind=3D4\\)" - } elseif {[test_compiler_info {clang-*}]} { + } elseif {[test_compiler_info {flang-*} f90]} { return "real" - } elseif {[test_compiler_info {icc-*}]} { + } elseif {[test_compiler_info {ifort-*} f90]} { return "REAL\\(4\\)" - } elseif {[test_compiler_info {intel-*}]} { + } elseif {[test_compiler_info {ifx-*} f90]} { return "REAL\\*4" } else { return "unknown" @@ -78,15 +78,15 @@ proc fortran_real4 {} { } =20 proc fortran_real8 {} { - if {[test_compiler_info {gcc-4-[012]-*}]} { + if {[test_compiler_info {gfortran-4-[012]-*} f90]} { return "real8" - } elseif {[test_compiler_info {gcc-*}]} { + } elseif {[test_compiler_info {gfortran-*} f90]} { return "real\\(kind=3D8\\)" - } elseif {[test_compiler_info {clang-*}]} { + } elseif {[test_compiler_info {flang-*} f90]} { return "double precision" - } elseif {[test_compiler_info {icc-*}]} { + } elseif {[test_compiler_info {ifort-*} f90]} { return "REAL\\(8\\)" - } elseif {[test_compiler_info {intel-*}]} { + } elseif {[test_compiler_info {ifx-*} f90]} { return "REAL\\*8" } else { return "unknown" @@ -94,15 +94,15 @@ proc fortran_real8 {} { } =20 proc fortran_complex4 {} { - if {[test_compiler_info {gcc-4-[012]-*}]} { + if {[test_compiler_info {gfortran-4-[012]-*} f90]} { return "complex4" - } elseif {[test_compiler_info {gcc-*}]} { + } elseif {[test_compiler_info {gfortran-*} f90]} { return "complex\\(kind=3D4\\)" - } elseif {[test_compiler_info {clang-*}]} { + } elseif {[test_compiler_info {flang-*} f90]} { return "complex" - } elseif {[test_compiler_info {icc-*}]} { + } elseif {[test_compiler_info {ifort-*} f90]} { return "COMPLEX\\(4\\)" - } elseif {[test_compiler_info {intel-*}]} { + } elseif {[test_compiler_info {ifx-*} f90]} { return "COMPLEX\\*8" } else { return "unknown" @@ -110,15 +110,15 @@ proc fortran_complex4 {} { } =20 proc fortran_complex8 {} { - if {[test_compiler_info {gcc-4-[012]-*}]} { + if {[test_compiler_info {gfortran-4-[012]-*} f90]} { return "complex8" - } elseif {[test_compiler_info {gcc-*}]} { + } elseif {[test_compiler_info {gfortran-*} f90]} { return "complex\\(kind=3D8\\)" - } elseif {[test_compiler_info {clang-*}]} { + } elseif {[test_compiler_info {flang-*} f90]} { return "double complex" - } elseif {[test_compiler_info {icc-*}]} { + } elseif {[test_compiler_info {ifort-*} f90]} { return "COMPLEX\\(8\\)" - } elseif {[test_compiler_info {intel-*}]} { + } elseif {[test_compiler_info {ifx-*} f90]} { return "COMPLEX\\*16" } else { return "unknown" @@ -126,15 +126,15 @@ proc fortran_complex8 {} { } =20 proc fortran_complex16 {} { - if {[test_compiler_info {gcc-4-[012]-*}]} { + if {[test_compiler_info {gfortran-4-[012]-*} f90]} { return "complex16" - } elseif {[test_compiler_info {gcc-*}]} { + } elseif {[test_compiler_info {gfortran-*} f90]} { return "complex\\(kind=3D16\\)" - } elseif {[test_compiler_info {clang-*}]} { + } elseif {[test_compiler_info {flang-*} f90]} { return "quad complex" - } elseif {[test_compiler_info {icc-*}]} { + } elseif {[test_compiler_info {ifort-*} f90]} { return "COMPLEX\\(16\\)" - } elseif {[test_compiler_info {intel-*}]} { + } elseif {[test_compiler_info {ifx-*} f90]} { return "COMPLEX\\*32" } else { return "unknown" @@ -142,15 +142,15 @@ proc fortran_complex16 {} { } =20 proc fortran_logical4 {} { - if {[test_compiler_info {gcc-4-[012]-*}]} { + if {[test_compiler_info {gfortran-4-[012]-*} f90]} { return "logical4" - } elseif {[test_compiler_info {gcc-*}]} { + } elseif {[test_compiler_info {gfortran-*} f90]} { return "logical\\(kind=3D4\\)" - } elseif {[test_compiler_info {clang-*}]} { + } elseif {[test_compiler_info {flang-*} f90]} { return "logical" - } elseif {[test_compiler_info {icc-*}]} { + } elseif {[test_compiler_info {ifort-*} f90]} { return "LOGICAL\\(4\\)" - } elseif {[test_compiler_info {intel-*}]} { + } elseif {[test_compiler_info {ifx-*} f90]} { return "LOGICAL\\*4" } else { return "unknown" @@ -158,15 +158,15 @@ proc fortran_logical4 {} { } =20 proc fortran_character1 {} { - if {[test_compiler_info {gcc-4-[012]-*}]} { + if {[test_compiler_info {gfortran-4-[012]-*} f90]} { return "character1" - } elseif {[test_compiler_info {gcc-*}]} { + } elseif {[test_compiler_info {gfortran-*} f90]} { return "character\\(kind=3D1\\)" - } elseif {[test_compiler_info {clang-*}]} { + } elseif {[test_compiler_info {flang-*} f90]} { return "character" - } elseif {[test_compiler_info {icc-*}]} { + } elseif {[test_compiler_info {ifort-*} f90]} { return "CHARACTER\\(1\\)" - } elseif {[test_compiler_info {intel-*}]} { + } elseif {[test_compiler_info {ifx-*} f90]} { return "CHARACTER\\*1" } else { return "unknown" @@ -176,12 +176,12 @@ proc fortran_character1 {} { # Return name of the main procedure based on the compiler version. =20 proc fortran_main {} { - if {[test_compiler_info {gcc-4-[012]-*}] - || [test_compiler_info {gcc-*}] - || [test_compiler_info {icc-*}] - || [test_compiler_info {intel-*}]} { + if {[test_compiler_info {gfortran-*} f90] + || [test_compiler_info {ifort-*} f90] + || [test_compiler_info {ifx-*} f90] + || [test_compiler_info {flang-llvm-*} f90]} { return "MAIN__" - } elseif {[test_compiler_info {clang-*}]} { + } elseif {[test_compiler_info {flang-classic-*} f90]} { return "MAIN_" } else { return "unknown" diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 381367ee6c4..87f0a36fe7d 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -4106,14 +4106,14 @@ set gcc_compiled 0 # -- chastain 2004-01-06 =20 proc get_compiler_info {{arg ""}} { - # For compiler.c and compiler.cc + # For compiler.c, compiler.cc and compiler.F90. global srcdir =20 # I am going to play with the log to keep noise out. global outdir global tool =20 - # These come from compiler.c or compiler.cc + # These come from compiler.c, compiler.cc or compiler.F90. global compiler_info =20 # Legacy global data symbols. @@ -4128,6 +4128,8 @@ proc get_compiler_info {{arg ""}} { set ifile "${srcdir}/lib/compiler.c" if { $arg =3D=3D "c++" } { set ifile "${srcdir}/lib/compiler.cc" + } elseif { $arg =3D=3D "f90" } { + set ifile "${srcdir}/lib/compiler.F90" } =20 # Run $ifile through the right preprocessor. @@ -4158,6 +4160,10 @@ proc get_compiler_info {{arg ""}} { # eval this line verbose "get_compiler_info: $cppline" 2 eval "$cppline" + } elseif { [ regexp "flang.*warning.*'-fdiagnostics-color=3Dnever'" "$cpp= line"] } { + # Both flang preprocessors (llvm flang and classic flang) print a + # warning for the unused -fdiagnostics-color=3Dnever, so we skip this + # output line here. } else { # unknown line verbose -log "get_compiler_info: $cppline" @@ -4195,9 +4201,9 @@ proc get_compiler_info {{arg ""}} { # Otherwise the argument is a glob-style expression to match against # compiler_info. =20 -proc test_compiler_info { {compiler ""} } { +proc test_compiler_info { {compiler ""} {language ""} } { global compiler_info - get_compiler_info + get_compiler_info $language =20 # If no arg, return the compiler_info string. if [string match "" $compiler] { @@ -4470,10 +4476,10 @@ proc gdb_compile {source dest type options} { if { !$getting_compiler_info && [lsearch -exact $options f90] !=3D -1 = } { # Fortran compile. set mod_path [standard_output_file ""] - if [test_compiler_info "gcc-*"] { + if { [test_compiler_info {gfortran-*} f90] } { lappend new_options "additional_flags=3D-J${mod_path}" - } elseif { [test_compiler_info {icc-*}] - || [test_compiler_info {intel-*}] } { + } elseif { [test_compiler_info {ifort-*} f90] + || [test_compiler_info {ifx-*} f90] } { lappend new_options "additional_flags=3D-module ${mod_path}" } } @@ -4770,6 +4776,8 @@ proc gdb_compile_shlib_1 {sources dest options} { set info_options "" if { [lsearch -exact $options "c++"] >=3D 0 } { set info_options "c++" + } elseif { [lsearch -exact $options "f90"] >=3D 0 } { + set info_options "f90" } if [get_compiler_info ${info_options}] { return -1 @@ -6957,6 +6965,8 @@ proc build_executable_from_specs {testname executable= options args} { set info_options "" if { [lsearch -exact $options "c++"] >=3D 0 } { set info_options "c++" + } elseif { [lsearch -exact $options "f90"] >=3D 0 } { + set info_options "f90" } if [get_compiler_info ${info_options}] { return -1