[PATCH] Allow Flang kind printing in complex.exp,pointer-to-pointer.exp,vla-ptr-info.exp

Andrew Burgess andrew.burgess@embecosm.com
Thu Sep 3 15:52:12 GMT 2020


* Sharma, Alok Kumar <AlokKumar.Sharma@amd.com> [2020-09-03 14:36:10 +0000]:

> Hi All,
> 
> I request you all to please review this patch. Below are the details.
> 
> Problem Description:
> In the test cases complex.exp,pointer-to-pointer.exp,vla-ptr-info.exp
> fortran.exp routines are not used, which are to determine the type/kind
> string. Due to this these test incorrectly fail for Flang.
> Resolution:
> Now test cases are modified to use fortran.exp routines. fortran.exp
> file is modified to add absent routines fortran_complex8 and
> fortran_complex16.
> 
> gdb/testsuite/ChangeLog
> 
>         * lib/fortran.exp (fortran_complex8): New proc.
>         (fortran_complex16): New proc.
>         * gdb.fortran/complex.exp: Use routines from fortran.exp
>         * gdb.fortran/pointer-to-pointer.exp: Likewise.
>         * gdb.fortran/vla-ptr-info.exp: Likewise.

LGTM.

Thanks,
Andrew


> 
> Regards,
> Alok
> 
> 
> From 434b3d32739242f58b3e81945c23b394413f3017 Mon Sep 17 00:00:00 2001
> From: Alok Kumar Sharma <AlokKumar.Sharma@amd.com>
> Date: Thu, 3 Sep 2020 17:58:31 +0530
> Subject: [PATCH] Allow Flang kind printing in
>  complex.exp,pointer-to-pointer.exp,vla-ptr-info.exp
> 
> In the test cases complex.exp,pointer-to-pointer.exp,vla-ptr-info.exp
> fortran.exp routines are not used, which are to determine the type/kind
> string. Due to this these test incorrectly fail for Flang.
> Now test cases are modified to use fortran.exp routines. fortran.exp
> file is modified to add absent routines fortran_complex8 and
> fortran_complex16.
> 
> gdb/testsuite/ChangeLog
> 
> 	* lib/fortran.exp (fortran_complex8): New proc.
> 	(fortran_complex16): New proc.
> 	* gdb.fortran/complex.exp: Use routines from fortran.exp
> 	* gdb.fortran/pointer-to-pointer.exp: Likewise.
> 	* gdb.fortran/vla-ptr-info.exp: Likewise.
> 
> Change-Id: I3f89c142a14505fc49c235cc68962a8c69d5de5e
> ---
>  gdb/testsuite/ChangeLog                       |  8 ++++++
>  gdb/testsuite/gdb.fortran/complex.exp         | 14 ++++++----
>  .../gdb.fortran/pointer-to-pointer.exp        |  7 +++--
>  gdb/testsuite/gdb.fortran/vla-ptr-info.exp    |  4 ++-
>  gdb/testsuite/lib/fortran.exp                 | 28 +++++++++++++++++++
>  5 files changed, 53 insertions(+), 8 deletions(-)
> 
> diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
> index 63dcad7d99..b152b12025 100644
> --- a/gdb/testsuite/ChangeLog
> +++ b/gdb/testsuite/ChangeLog
> @@ -1,3 +1,11 @@
> +2020-09-03  Alok Kumar Sharma  <AlokKumar.Sharma@amd.com>
> +
> +	* lib/fortran.exp (fortran_complex8): New proc.
> +	(fortran_complex16): New proc.
> +	* gdb.fortran/complex.exp: Use routines from fortran.exp
> +	* gdb.fortran/pointer-to-pointer.exp: Likewise.
> +	* gdb.fortran/vla-ptr-info.exp: Likewise.
> +
>  2020-09-02  Tom Tromey  <tromey@adacore.com>
>  
>  	* gdb.ada/mi_var_access.exp: Test children of access variable.
> diff --git a/gdb/testsuite/gdb.fortran/complex.exp b/gdb/testsuite/gdb.fortran/complex.exp
> index 1faed2afb9..5d52dce647 100644
> --- a/gdb/testsuite/gdb.fortran/complex.exp
> +++ b/gdb/testsuite/gdb.fortran/complex.exp
> @@ -27,6 +27,10 @@ if ![fortran_runto_main] then {
>      continue
>  }
>  
> +# Depending on the compiler being used, the type names can be printed differently.
> +set complex4 [fortran_complex4]
> +set complex8 [fortran_complex8]
> +set complex16 [fortran_complex16]
>  
>  gdb_breakpoint [gdb_get_line_number "stop"]
>  gdb_continue_to_breakpoint "continue"
> @@ -38,29 +42,29 @@ gdb_test "print dc" " = \\(321,-22\\)"
>  
>  gdb_test "print c16" " = \\(-874,19\\)"
>  
> -gdb_test "whatis c" "type = complex\\(kind=4\\)"
> +gdb_test "whatis c" "type = $complex4"
>  gdb_test "print \$_creal (c)" " = 1000"
>  with_test_prefix "c" {
>      gdb_test "whatis \$" " = real"
>  }
>  
> -gdb_test "whatis c4" "type = complex\\(kind=4\\)"
> +gdb_test "whatis c4" "type = $complex4"
>  gdb_test "print \$_creal (c4)" " = 1000"
>  with_test_prefix "c4" {
>      gdb_test "whatis \$" " = real"
>  }
> -gdb_test "whatis c8" "type = complex\\(kind=8\\)"
> +gdb_test "whatis c8" "type = $complex8"
>  gdb_test "print \$_creal (c8)" " = 321"
>  with_test_prefix "c8" {
>      gdb_test "whatis \$" " = real\\*8"
>  }
> -gdb_test "whatis dc" "type = complex\\(kind=8\\)"
> +gdb_test "whatis dc" "type = $complex8"
>  gdb_test "print \$_creal (dc)" " = 321"
>  with_test_prefix "dc" {
>      gdb_test "whatis \$" " = real\\*8"
>  }
>  
> -gdb_test "whatis c16" "type = complex\\(kind=16\\)"
> +gdb_test "whatis c16" "type = $complex16"
>  gdb_test "print \$_creal (c16)" " = -874"
>  with_test_prefix "c16" {
>      gdb_test "whatis \$" " = real\\*16"
> diff --git a/gdb/testsuite/gdb.fortran/pointer-to-pointer.exp b/gdb/testsuite/gdb.fortran/pointer-to-pointer.exp
> index 7129e431ed..4c643c2990 100644
> --- a/gdb/testsuite/gdb.fortran/pointer-to-pointer.exp
> +++ b/gdb/testsuite/gdb.fortran/pointer-to-pointer.exp
> @@ -30,6 +30,9 @@ if ![fortran_runto_main] {
>      return -1
>  }
>  
> +# Depending on the compiler being used, the type names can be printed differently.
> +set real4 [fortran_real4]
> +
>  gdb_breakpoint [gdb_get_line_number "Break Here"]
>  gdb_continue_to_breakpoint "Break Here"
>  
> @@ -38,9 +41,9 @@ gdb_test "print *buffer" \
>  
>  set l_buffer_type [multi_line \
>  		       "Type l_buffer" \
> -		       "    real\\(kind=4\\) :: alpha\\(:\\)" \
> +		       "    $real4 :: alpha\\(:\\)" \
>  		       "End Type l_buffer" ]
>  
>  gdb_test "ptype buffer" "type = PTR TO -> \\( ${l_buffer_type} \\)"
>  gdb_test "ptype *buffer" "type = ${l_buffer_type}"
> -gdb_test "ptype buffer%alpha" "type = real\\(kind=4\\) \\(5\\)"
> +gdb_test "ptype buffer%alpha" "type = $real4 \\(5\\)"
> diff --git a/gdb/testsuite/gdb.fortran/vla-ptr-info.exp b/gdb/testsuite/gdb.fortran/vla-ptr-info.exp
> index bfc118491c..7ead9191b9 100644
> --- a/gdb/testsuite/gdb.fortran/vla-ptr-info.exp
> +++ b/gdb/testsuite/gdb.fortran/vla-ptr-info.exp
> @@ -28,8 +28,10 @@ if ![fortran_runto_main] {
>      return -1
>  }
>  
> +set real4 [fortran_real4]
> +
>  # Check the status of a pointer to a dynamic array.
>  gdb_breakpoint [gdb_get_line_number "pvla-associated"]
>  gdb_continue_to_breakpoint "pvla-associated"
> -gdb_test "print &pvla" " = \\(PTR TO -> \\( real\\(kind=4\\) \\(10,10,10\\) \\)\\) ${hex}" \
> +gdb_test "print &pvla" " = \\(PTR TO -> \\( $real4 \\(10,10,10\\) \\)\\) ${hex}" \
>    "print pvla pointer information"
> diff --git a/gdb/testsuite/lib/fortran.exp b/gdb/testsuite/lib/fortran.exp
> index b9def7fa21..97e442b849 100644
> --- a/gdb/testsuite/lib/fortran.exp
> +++ b/gdb/testsuite/lib/fortran.exp
> @@ -99,6 +99,34 @@ proc fortran_complex4 {} {
>      }
>  }
>  
> +proc fortran_complex8 {} {
> +    if {[test_compiler_info {gcc-4-[012]-*}]} {
> +	return "complex8"
> +    } elseif {[test_compiler_info {gcc-*}]} {
> +	return "complex\\(kind=8\\)"
> +    } elseif {[test_compiler_info {clang-*}]} {
> +	return "double complex"
> +    } elseif {[test_compiler_info {icc-*}]} {
> +	return "COMPLEX\\(8\\)"
> +    } else {
> +	return "unknown"
> +    }
> +}
> +
> +proc fortran_complex16 {} {
> +    if {[test_compiler_info {gcc-4-[012]-*}]} {
> +	return "complex16"
> +    } elseif {[test_compiler_info {gcc-*}]} {
> +	return "complex\\(kind=16\\)"
> +    } elseif {[test_compiler_info {clang-*}]} {
> +	return "quad complex"
> +    } elseif {[test_compiler_info {icc-*}]} {
> +	return "COMPLEX\\(16\\)"
> +    } else {
> +	return "unknown"
> +    }
> +}
> +
>  proc fortran_logical4 {} {
>      if {[test_compiler_info {gcc-4-[012]-*}]} {
>  	return "logical4"
> -- 
> 2.17.1



More information about the Gdb-patches mailing list