From 3c3bae18be894db971840180b59f56707b6d5ebd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E2=80=9Cbhkumarn=E2=80=9D?= <Bhuvanendra.KumarN@amd.com>
Date: Fri, 16 Apr 2021 02:35:08 +0530
Subject: [PATCH] [gdb.fortran] Add type info of formal parameter for
 clang.

Additional compiler generated formal parameter exist with clang and type
information for the same is added accordingly. Also few kind parameter
printing are removed which is not default for clang.
Note: More details about this kind parameter omission while printing can
be found with similar patch
  commit 0a709cba00d36d490482d0e8673e323ac1e897a6
  Author Alok Kumar Sharma (alokkumar.sharma@amd.com)

gdb/testsuite/ChangeLog:
	* gdb.fortran/ptype-on-functions.exp: Add type info of formal
	parameter for clang. Also removed the kind parameter for clang.
	* lib/fortran.exp (fortran_int8): Likewise.
---
 gdb/testsuite/ChangeLog                       |  5 ++
 .../gdb.fortran/ptype-on-functions.exp        | 55 ++++++++++++++-----
 gdb/testsuite/lib/fortran.exp                 |  2 +-
 3 files changed, 47 insertions(+), 15 deletions(-)

diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index ad289c135d..216d985995 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2021-04-16  Bhuvanendra Kumar  <Bhuvanendra.KumarN@amd.com>
+	* gdb.fortran/ptype-on-functions.exp: Add type info of formal
+	parameter for clang. Also removed the kind parameter for clang.
+	* lib/fortran.exp (fortran_int8): Likewise.
+
 2021-04-16  Bhuvanendra Kumar  <Bhuvanendra.KumarN@amd.com>
 
         * gdb.base/foll-exec.exp: Additional next commands added for
diff --git a/gdb/testsuite/gdb.fortran/ptype-on-functions.exp b/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
index 14f522d6d4..4e46e10166 100644
--- a/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
+++ b/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
@@ -29,23 +29,50 @@ if ![fortran_runto_main] then {
     continue
 }
 
-gdb_test "ptype some_module::get_number" \
-    "type = integer\\(kind=4\\) \\(Type __class_some_module_Number(_t)?\\)"
+if {[test_compiler_info {clang-*}]} {
+    set integer4 [fortran_int4]
+    set logical4 [fortran_logical4]
+    set integer8 [fortran_int8]
 
-gdb_test "ptype some_module::set_number" \
-    "type = void \\(Type __class_some_module_Number(_t)?, integer\\(kind=4\\)\\)"
+    gdb_test "ptype some_module::get_number" \
+        "type = $integer4 \\(Type number, $integer8 \\(10\\)\\)"
 
-gdb_test "ptype is_bigger" \
-    "type = logical\\(kind=4\\) \\(integer\\(kind=4\\), integer\\(kind=4\\)\\)"
+    gdb_test "ptype some_module::set_number" \
+        "type = void \\(Type number, $integer4\\, $integer8 \\(10\\)\\)"
 
-gdb_test "ptype say_numbers" \
-    "type = void \\(integer\\(kind=4\\), integer\\(kind=4\\), integer\\(kind=4\\)\\)"
+    gdb_test "ptype is_bigger" \
+        "type = $logical4 \\($integer4, $integer4\\)"
 
-gdb_test "ptype fun_ptr" \
-    "type = PTR TO -> \\( integer\\(kind=4\\) \\(\\) \\(REF TO -> \\( integer\\(kind=4\\) \\)\\) \\)"
+    gdb_test "ptype say_numbers" \
+        "type = void \\($integer4, $integer4, $integer4\\)"
 
-gdb_test "ptype say_string" \
-    "type = void \\(character\\*\\(\\*\\), integer\\(kind=\\d+\\)\\)"
+    gdb_test "ptype fun_ptr" \
+        "type = PTR TO -> \\( $integer4 \\(\\) \\($integer4\\) \\)"
 
-gdb_test "ptype say_array" \
-    "type = void \\(integer\\(kind=4\\) \\(:,:\\)\\)"
+    gdb_test "ptype say_string" \
+        "type = void \\(character\\*\\(\\*\\), $integer8\\)"
+
+    gdb_test "ptype say_array" \
+        "type = void \\($integer8, $integer4 \\(:,:\\)\\)"
+} else {
+    gdb_test "ptype some_module::get_number" \
+        "type = integer\\(kind=4\\) \\(Type __class_some_module_Number(_t)?\\)"
+
+    gdb_test "ptype some_module::set_number" \
+        "type = void \\(Type __class_some_module_Number(_t)?, integer\\(kind=4\\)\\)"
+
+    gdb_test "ptype is_bigger" \
+        "type = logical\\(kind=4\\) \\(integer\\(kind=4\\), integer\\(kind=4\\)\\)"
+
+    gdb_test "ptype say_numbers" \
+        "type = void \\(integer\\(kind=4\\), integer\\(kind=4\\), integer\\(kind=4\\)\\)"
+
+    gdb_test "ptype fun_ptr" \
+        "type = PTR TO -> \\( integer\\(kind=4\\) \\(\\) \\(REF TO -> \\( integer\\(kind=4\\) \\)\\) \\)"
+
+    gdb_test "ptype say_string" \
+        "type = void \\(character\\*\\(\\*\\), integer\\(kind=\\d+\\)\\)"
+
+    gdb_test "ptype say_array" \
+        "type = void \\(integer\\(kind=4\\) \\(:,:\\)\\)"
+}
diff --git a/gdb/testsuite/lib/fortran.exp b/gdb/testsuite/lib/fortran.exp
index 35db863e9c..f8c442fd09 100644
--- a/gdb/testsuite/lib/fortran.exp
+++ b/gdb/testsuite/lib/fortran.exp
@@ -49,7 +49,7 @@ proc fortran_int8 {} {
     } elseif {[test_compiler_info {gcc-*}]} {
 	return "integer\\(kind=8\\)"
     } elseif {[test_compiler_info {clang-*}]} {
-	return "integer*8"
+	return "integer\\*8"
     } elseif {[test_compiler_info {icc-*}]} {
 	return "INTEGER\\(8\\)"
     } else {
-- 
2.17.1

