Jan Kratochvil d258670
git diff --stat -p gdb/master...gdb/users/bheckel/fortran-vla-strings
Jan Kratochvil d258670
0ad7d8d1a3a36c6e04e3b6d37d8825f18d595723
Jan Kratochvil d258670
Jan Kratochvil d258670
 gdb/NEWS                                  |   2 +
Jan Kratochvil d258670
 gdb/c-valprint.c                          |  22 +++++
Jan Kratochvil d258670
 gdb/dwarf2read.c                          | 158 +++++++++++++++++++++++++-----
Jan Kratochvil d258670
 gdb/f-typeprint.c                         |  93 +++++++++---------
Jan Kratochvil d258670
 gdb/gdbtypes.c                            |  44 ++++++++-
Jan Kratochvil d258670
 gdb/testsuite/gdb.cp/vla-cxx.cc           |   9 ++
Jan Kratochvil d258670
 gdb/testsuite/gdb.cp/vla-cxx.exp          |   9 ++
Jan Kratochvil d258670
 gdb/testsuite/gdb.fortran/pointers.exp    | 143 +++++++++++++++++++++++++++
Jan Kratochvil d258670
 gdb/testsuite/gdb.fortran/pointers.f90    | 109 +++++++++++++++++++++
Jan Kratochvil d258670
 gdb/testsuite/gdb.fortran/print_type.exp  | 100 +++++++++++++++++++
Jan Kratochvil d258670
 gdb/testsuite/gdb.fortran/vla-ptype.exp   |  12 +--
Jan Kratochvil d258670
 gdb/testsuite/gdb.fortran/vla-strings.exp | 103 +++++++++++++++++++
Jan Kratochvil d258670
 gdb/testsuite/gdb.fortran/vla-strings.f90 |  39 ++++++++
Jan Kratochvil d258670
 gdb/testsuite/gdb.fortran/vla-type.exp    |   7 +-
Jan Kratochvil d258670
 gdb/testsuite/gdb.fortran/vla-value.exp   |  12 ++-
Jan Kratochvil d258670
 gdb/testsuite/gdb.mi/mi-var-child-f.exp   |   7 +-
Jan Kratochvil d258670
 gdb/testsuite/gdb.mi/mi-vla-fortran.exp   |  27 ++---
Jan Kratochvil d258670
 gdb/typeprint.c                           |  19 ++++
Jan Kratochvil d258670
 gdb/valops.c                              |  16 ++-
Jan Kratochvil d258670
 gdb/valprint.c                            |   6 --
Jan Kratochvil d258670
 20 files changed, 827 insertions(+), 110 deletions(-)
Jan Kratochvil d258670
Jan Kratochvil d258670
Index: gdb-7.11.90.20160907/gdb/NEWS
Jan Kratochvil d258670
===================================================================
Jan Kratochvil d258670
--- gdb-7.11.90.20160907.orig/gdb/NEWS	2016-09-07 21:52:10.273563060 +0200
Jan Kratochvil d258670
+++ gdb-7.11.90.20160907/gdb/NEWS	2016-09-07 21:53:22.708210416 +0200
Jan Kratochvil d258670
@@ -1,6 +1,8 @@
Jan Kratochvil d258670
 		What has changed in GDB?
Jan Kratochvil d258670
 	     (Organized release by release)
Jan Kratochvil d258670
 
Jan Kratochvil d258670
+* Fortran: Support pointers to dynamic types.
Jan Kratochvil d258670
+
Jan Kratochvil d258670
 *** Changes in GDB 7.12
Jan Kratochvil d258670
 
Jan Kratochvil d258670
 * GDB and GDBserver now build with a C++ compiler by default.
Jan Kratochvil d258670
Index: gdb-7.11.90.20160907/gdb/c-valprint.c
Jan Kratochvil d258670
===================================================================
Jan Kratochvil d258670
--- gdb-7.11.90.20160907.orig/gdb/c-valprint.c	2016-09-07 21:52:10.272563051 +0200
Jan Kratochvil d258670
+++ gdb-7.11.90.20160907/gdb/c-valprint.c	2016-09-07 21:53:22.708210416 +0200
Jan Kratochvil d258670
@@ -645,6 +645,28 @@
Jan Kratochvil d258670
       else
Jan Kratochvil d258670
 	{
Jan Kratochvil d258670
 	  /* normal case */
Jan Kratochvil d258670
+	  if (TYPE_CODE (type) == TYPE_CODE_PTR
Jan Kratochvil d258670
+	      && 1 == is_dynamic_type (type))
Jan Kratochvil d258670
+	    {
Jan Kratochvil d258670
+	      CORE_ADDR addr;
Jan Kratochvil d258670
+	      if (NULL != TYPE_DATA_LOCATION (TYPE_TARGET_TYPE (type)))
Jan Kratochvil d258670
+		addr = value_address (val);
Jan Kratochvil d258670
+	      else
Jan Kratochvil d258670
+		addr = value_as_address (val);
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+	      /* We resolve the target-type only when the
Jan Kratochvil d258670
+	         pointer is associated.  */
Jan Kratochvil d258670
+	      if ((addr != 0)
Jan Kratochvil d258670
+		  && (0 == type_not_associated (type)))
Jan Kratochvil d258670
+		  TYPE_TARGET_TYPE (type) =
Jan Kratochvil d258670
+		      resolve_dynamic_type (TYPE_TARGET_TYPE (type),
Jan Kratochvil d258670
+					    NULL, addr);
Jan Kratochvil d258670
+	    }
Jan Kratochvil d258670
+	  else
Jan Kratochvil d258670
+	    {
Jan Kratochvil d258670
+	      /* Do nothing. References are already resolved from the beginning,
Jan Kratochvil d258670
+	         only pointers are resolved when we actual need the target.  */
Jan Kratochvil d258670
+	    }
Jan Kratochvil d258670
 	  fprintf_filtered (stream, "(");
Jan Kratochvil d258670
 	  type_print (value_type (val), "", stream, -1);
Jan Kratochvil d258670
 	  fprintf_filtered (stream, ") ");
Jan Kratochvil d258670
Index: gdb-7.11.90.20160907/gdb/dwarf2read.c
Jan Kratochvil d258670
===================================================================
Jan Kratochvil d258670
--- gdb-7.11.90.20160907.orig/gdb/dwarf2read.c	2016-09-07 21:52:53.700951175 +0200
Jan Kratochvil d258670
+++ gdb-7.11.90.20160907/gdb/dwarf2read.c	2016-09-07 21:54:02.140562825 +0200
Jan Kratochvil d258670
@@ -1764,7 +1764,8 @@
Jan Kratochvil d258670
 
Jan Kratochvil d258670
 static int attr_to_dynamic_prop (const struct attribute *attr,
Jan Kratochvil d258670
 				 struct die_info *die, struct dwarf2_cu *cu,
Jan Kratochvil d258670
-				 struct dynamic_prop *prop);
Jan Kratochvil d258670
+				 struct dynamic_prop *prop, const gdb_byte *additional_data,
Jan Kratochvil d258670
+				 int additional_data_size);
Jan Kratochvil d258670
 
Jan Kratochvil d258670
 /* memory allocation interface */
Jan Kratochvil d258670
 
Jan Kratochvil d258670
@@ -11446,7 +11447,7 @@
Jan Kratochvil d258670
     {
Jan Kratochvil d258670
       newobj->static_link
Jan Kratochvil d258670
 	= XOBNEW (&objfile->objfile_obstack, struct dynamic_prop);
Jan Kratochvil d258670
-      attr_to_dynamic_prop (attr, die, cu, newobj->static_link);
Jan Kratochvil d258670
+      attr_to_dynamic_prop (attr, die, cu, newobj->static_link, NULL, 0);
Jan Kratochvil d258670
     }
Jan Kratochvil d258670
 
Jan Kratochvil d258670
   cu->list_in_scope = &local_symbols;
Jan Kratochvil d258670
@@ -14512,29 +14513,94 @@
Jan Kratochvil d258670
   struct gdbarch *gdbarch = get_objfile_arch (objfile);
Jan Kratochvil d258670
   struct type *type, *range_type, *index_type, *char_type;
Jan Kratochvil d258670
   struct attribute *attr;
Jan Kratochvil d258670
-  unsigned int length;
Jan Kratochvil d258670
+  unsigned int length = UINT_MAX;
Jan Kratochvil d258670
 
Jan Kratochvil d258670
+  index_type = objfile_type (objfile)->builtin_int;
Jan Kratochvil d258670
+  range_type = create_static_range_type (NULL, index_type, 1, length);
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+  /* If DW_AT_string_length is defined, the length is stored in memory.  */
Jan Kratochvil d258670
   attr = dwarf2_attr (die, DW_AT_string_length, cu);
Jan Kratochvil d258670
   if (attr)
Jan Kratochvil d258670
     {
Jan Kratochvil d258670
-      length = DW_UNSND (attr);
Jan Kratochvil d258670
+      if (attr_form_is_block (attr))
Jan Kratochvil d258670
+	{
Jan Kratochvil d258670
+	  struct attribute *byte_size, *bit_size;
Jan Kratochvil d258670
+	  struct dynamic_prop high;
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+	  byte_size = dwarf2_attr (die, DW_AT_byte_size, cu);
Jan Kratochvil d258670
+	  bit_size = dwarf2_attr (die, DW_AT_bit_size, cu);
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+	  /* DW_AT_byte_size should never occur in combination with
Jan Kratochvil d258670
+	     DW_AT_bit_size.  */
Jan Kratochvil d258670
+	  if (byte_size != NULL && bit_size != NULL)
Jan Kratochvil d258670
+	    complaint (&symfile_complaints,
Jan Kratochvil d258670
+		       _("DW_AT_byte_size AND "
Jan Kratochvil d258670
+			 "DW_AT_bit_size found together at the same time."));
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+	  /* If DW_AT_string_length AND DW_AT_byte_size exist together,
Jan Kratochvil d258670
+	     DW_AT_byte_size describes the number of bytes that should be read
Jan Kratochvil d258670
+	     from the length memory location.  */
Jan Kratochvil d258670
+	  if (byte_size != NULL)
Jan Kratochvil d258670
+	    {
Jan Kratochvil d258670
+	      /* Build new dwarf2_locexpr_baton structure with additions to the
Jan Kratochvil d258670
+		 data attribute, to reflect DWARF specialities to get address
Jan Kratochvil d258670
+		 sizes.  */
Jan Kratochvil d258670
+	      const gdb_byte append_ops[] =
Jan Kratochvil d258670
+		{
Jan Kratochvil d258670
+		/* DW_OP_deref_size: size of an address on the target machine
Jan Kratochvil d258670
+		   (bytes), where the size will be specified by the next
Jan Kratochvil d258670
+		   operand.  */
Jan Kratochvil d258670
+		DW_OP_deref_size,
Jan Kratochvil d258670
+		/* Operand for DW_OP_deref_size.  */
Jan Kratochvil d258670
+		DW_UNSND(byte_size) };
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+	      if (!attr_to_dynamic_prop (attr, die, cu, &high, append_ops,
Jan Kratochvil d258670
+					 ARRAY_SIZE(append_ops)))
Jan Kratochvil d258670
+		complaint (&symfile_complaints,
Jan Kratochvil d258670
+			   _("Could not parse DW_AT_byte_size"));
Jan Kratochvil d258670
+	    }
Jan Kratochvil d258670
+	  else if (bit_size != NULL)
Jan Kratochvil d258670
+	    complaint (&symfile_complaints,
Jan Kratochvil d258670
+		       _("DW_AT_string_length AND "
Jan Kratochvil d258670
+			 "DW_AT_bit_size found but not supported yet."));
Jan Kratochvil d258670
+	  /* If DW_AT_string_length WITHOUT DW_AT_byte_size exist, the default
Jan Kratochvil d258670
+	     is the address size of the target machine.  */
Jan Kratochvil d258670
+	  else
Jan Kratochvil d258670
+	    {
Jan Kratochvil d258670
+	      const gdb_byte append_ops[] =
Jan Kratochvil d258670
+		{ DW_OP_deref };
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+	      if (!attr_to_dynamic_prop (attr, die, cu, &high, append_ops,
Jan Kratochvil d258670
+					 ARRAY_SIZE(append_ops)))
Jan Kratochvil d258670
+		complaint (&symfile_complaints,
Jan Kratochvil d258670
+			   _("Could not parse DW_AT_string_length"));
Jan Kratochvil d258670
+	    }
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+	  TYPE_RANGE_DATA (range_type)->high = high;
Jan Kratochvil d258670
+	}
Jan Kratochvil d258670
+      else
Jan Kratochvil d258670
+	{
Jan Kratochvil d258670
+	  TYPE_HIGH_BOUND (range_type) = DW_UNSND(attr);
Jan Kratochvil d258670
+	  TYPE_HIGH_BOUND_KIND (range_type) = PROP_CONST;
Jan Kratochvil d258670
+	}
Jan Kratochvil d258670
     }
Jan Kratochvil d258670
   else
Jan Kratochvil d258670
     {
Jan Kratochvil d258670
-      /* Check for the DW_AT_byte_size attribute.  */
Jan Kratochvil d258670
+      /* Check for the DW_AT_byte_size attribute, which represents the length
Jan Kratochvil d258670
+	 in this case.  */
Jan Kratochvil d258670
       attr = dwarf2_attr (die, DW_AT_byte_size, cu);
Jan Kratochvil d258670
       if (attr)
Jan Kratochvil d258670
-        {
Jan Kratochvil d258670
-          length = DW_UNSND (attr);
Jan Kratochvil d258670
-        }
Jan Kratochvil d258670
+	{
Jan Kratochvil d258670
+	  TYPE_HIGH_BOUND (range_type) = DW_UNSND(attr);
Jan Kratochvil d258670
+	  TYPE_HIGH_BOUND_KIND (range_type) = PROP_CONST;
Jan Kratochvil d258670
+	}
Jan Kratochvil d258670
       else
Jan Kratochvil d258670
-        {
Jan Kratochvil d258670
-          length = 1;
Jan Kratochvil d258670
-        }
Jan Kratochvil d258670
+	{
Jan Kratochvil d258670
+	  TYPE_HIGH_BOUND (range_type) = 1;
Jan Kratochvil d258670
+	  TYPE_HIGH_BOUND_KIND (range_type) = PROP_CONST;
Jan Kratochvil d258670
+	}
Jan Kratochvil d258670
     }
Jan Kratochvil d258670
 
Jan Kratochvil d258670
-  index_type = objfile_type (objfile)->builtin_int;
Jan Kratochvil d258670
-  range_type = create_static_range_type (NULL, index_type, 1, length);
Jan Kratochvil d258670
   char_type = language_string_char_type (cu->language_defn, gdbarch);
Jan Kratochvil d258670
   type = create_string_type (NULL, char_type, range_type);
Jan Kratochvil d258670
 
Jan Kratochvil d258670
@@ -14864,7 +14930,8 @@
Jan Kratochvil d258670
 
Jan Kratochvil d258670
 static int
Jan Kratochvil d258670
 attr_to_dynamic_prop (const struct attribute *attr, struct die_info *die,
Jan Kratochvil d258670
-		      struct dwarf2_cu *cu, struct dynamic_prop *prop)
Jan Kratochvil d258670
+		      struct dwarf2_cu *cu, struct dynamic_prop *prop,
Jan Kratochvil d258670
+		      const gdb_byte *additional_data, int additional_data_size)
Jan Kratochvil d258670
 {
Jan Kratochvil d258670
   struct dwarf2_property_baton *baton;
Jan Kratochvil d258670
   struct obstack *obstack = &cu->objfile->objfile_obstack;
Jan Kratochvil d258670
@@ -14874,14 +14941,33 @@
Jan Kratochvil d258670
 
Jan Kratochvil d258670
   if (attr_form_is_block (attr))
Jan Kratochvil d258670
     {
Jan Kratochvil d258670
-      baton = XOBNEW (obstack, struct dwarf2_property_baton);
Jan Kratochvil d258670
+      baton = XOBNEW(obstack, struct dwarf2_property_baton);
Jan Kratochvil d258670
       baton->referenced_type = NULL;
Jan Kratochvil d258670
       baton->locexpr.per_cu = cu->per_cu;
Jan Kratochvil d258670
-      baton->locexpr.size = DW_BLOCK (attr)->size;
Jan Kratochvil d258670
-      baton->locexpr.data = DW_BLOCK (attr)->data;
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+      if (additional_data != NULL && additional_data_size > 0)
Jan Kratochvil d258670
+	{
Jan Kratochvil d258670
+	  gdb_byte *data;
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+	  data = (gdb_byte *) obstack_alloc(
Jan Kratochvil d258670
+	      &cu->objfile->objfile_obstack,
Jan Kratochvil d258670
+	      DW_BLOCK (attr)->size + additional_data_size);
Jan Kratochvil d258670
+	  memcpy (data, DW_BLOCK (attr)->data, DW_BLOCK (attr)->size);
Jan Kratochvil d258670
+	  memcpy (data + DW_BLOCK (attr)->size, additional_data,
Jan Kratochvil d258670
+		  additional_data_size);
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+	  baton->locexpr.data = data;
Jan Kratochvil d258670
+	  baton->locexpr.size = DW_BLOCK (attr)->size + additional_data_size;
Jan Kratochvil d258670
+	}
Jan Kratochvil d258670
+      else
Jan Kratochvil d258670
+	{
Jan Kratochvil d258670
+	  baton->locexpr.data = DW_BLOCK (attr)->data;
Jan Kratochvil d258670
+	  baton->locexpr.size = DW_BLOCK (attr)->size;
Jan Kratochvil d258670
+	}
Jan Kratochvil d258670
+
Jan Kratochvil d258670
       prop->data.baton = baton;
Jan Kratochvil d258670
       prop->kind = PROP_LOCEXPR;
Jan Kratochvil d258670
-      gdb_assert (prop->data.baton != NULL);
Jan Kratochvil d258670
+      gdb_assert(prop->data.baton != NULL);
Jan Kratochvil d258670
     }
Jan Kratochvil d258670
   else if (attr_form_is_ref (attr))
Jan Kratochvil d258670
     {
Jan Kratochvil d258670
@@ -14914,8 +15000,28 @@
Jan Kratochvil d258670
 		baton = XOBNEW (obstack, struct dwarf2_property_baton);
Jan Kratochvil d258670
 		baton->referenced_type = die_type (target_die, target_cu);
Jan Kratochvil d258670
 		baton->locexpr.per_cu = cu->per_cu;
Jan Kratochvil d258670
-		baton->locexpr.size = DW_BLOCK (target_attr)->size;
Jan Kratochvil d258670
-		baton->locexpr.data = DW_BLOCK (target_attr)->data;
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+		if (additional_data != NULL && additional_data_size > 0)
Jan Kratochvil d258670
+		  {
Jan Kratochvil d258670
+		    gdb_byte *data;
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+		    data = (gdb_byte *) obstack_alloc (&cu->objfile->objfile_obstack,
Jan Kratochvil d258670
+			    DW_BLOCK (target_attr)->size + additional_data_size);
Jan Kratochvil d258670
+		    memcpy (data, DW_BLOCK (target_attr)->data,
Jan Kratochvil d258670
+			    DW_BLOCK (target_attr)->size);
Jan Kratochvil d258670
+		    memcpy (data + DW_BLOCK (target_attr)->size,
Jan Kratochvil d258670
+			    additional_data, additional_data_size);
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+		    baton->locexpr.data = data;
Jan Kratochvil d258670
+		    baton->locexpr.size = (DW_BLOCK (target_attr)->size
Jan Kratochvil d258670
+					   + additional_data_size);
Jan Kratochvil d258670
+		  }
Jan Kratochvil d258670
+		else
Jan Kratochvil d258670
+		  {
Jan Kratochvil d258670
+		    baton->locexpr.data = DW_BLOCK (target_attr)->data;
Jan Kratochvil d258670
+		    baton->locexpr.size = DW_BLOCK (target_attr)->size;
Jan Kratochvil d258670
+		  }
Jan Kratochvil d258670
+
Jan Kratochvil d258670
 		prop->data.baton = baton;
Jan Kratochvil d258670
 		prop->kind = PROP_LOCEXPR;
Jan Kratochvil d258670
 		gdb_assert (prop->data.baton != NULL);
Jan Kratochvil d258670
@@ -15027,24 +15133,24 @@
Jan Kratochvil d258670
 
Jan Kratochvil d258670
   attr = dwarf2_attr (die, DW_AT_byte_stride, cu);
Jan Kratochvil d258670
   if (attr)
Jan Kratochvil d258670
-    if (!attr_to_dynamic_prop (attr, die, cu, &stride))
Jan Kratochvil d258670
+    if (!attr_to_dynamic_prop (attr, die, cu, &stride, NULL, 0))
Jan Kratochvil d258670
         complaint (&symfile_complaints, _("Missing DW_AT_byte_stride "
Jan Kratochvil d258670
                   "- DIE at 0x%x [in module %s]"),
Jan Kratochvil d258670
              die->offset.sect_off, objfile_name (cu->objfile));
Jan Kratochvil d258670
 
Jan Kratochvil d258670
   attr = dwarf2_attr (die, DW_AT_lower_bound, cu);
Jan Kratochvil d258670
   if (attr)
Jan Kratochvil d258670
-    attr_to_dynamic_prop (attr, die, cu, &low);
Jan Kratochvil d258670
+    attr_to_dynamic_prop (attr, die, cu, &low, NULL, 0);
Jan Kratochvil d258670
   else if (!low_default_is_valid)
Jan Kratochvil d258670
     complaint (&symfile_complaints, _("Missing DW_AT_lower_bound "
Jan Kratochvil d258670
 				      "- DIE at 0x%x [in module %s]"),
Jan Kratochvil d258670
 	       die->offset.sect_off, objfile_name (cu->objfile));
Jan Kratochvil d258670
 
Jan Kratochvil d258670
   attr = dwarf2_attr (die, DW_AT_upper_bound, cu);
Jan Kratochvil d258670
-  if (!attr_to_dynamic_prop (attr, die, cu, &high))
Jan Kratochvil d258670
+  if (!attr_to_dynamic_prop (attr, die, cu, &high, NULL, 0))
Jan Kratochvil d258670
     {
Jan Kratochvil d258670
       attr = dwarf2_attr (die, DW_AT_count, cu);
Jan Kratochvil d258670
-      if (attr_to_dynamic_prop (attr, die, cu, &high))
Jan Kratochvil d258670
+      if (attr_to_dynamic_prop (attr, die, cu, &high, NULL, 0))
Jan Kratochvil d258670
 	{
Jan Kratochvil d258670
 	  /* If bounds are constant do the final calculation here.  */
Jan Kratochvil d258670
 	  if (low.kind == PROP_CONST && high.kind == PROP_CONST)
Jan Kratochvil d258670
@@ -22416,7 +22522,7 @@
Jan Kratochvil d258670
   attr = dwarf2_attr (die, DW_AT_allocated, cu);
Jan Kratochvil d258670
   if (attr_form_is_block (attr))
Jan Kratochvil d258670
     {
Jan Kratochvil d258670
-      if (attr_to_dynamic_prop (attr, die, cu, &prop))
Jan Kratochvil d258670
+      if (attr_to_dynamic_prop (attr, die, cu, &prop, NULL, 0))
Jan Kratochvil d258670
         add_dyn_prop (DYN_PROP_ALLOCATED, prop, type, objfile);
Jan Kratochvil d258670
     }
Jan Kratochvil d258670
   else if (attr != NULL)
Jan Kratochvil d258670
@@ -22431,7 +22537,7 @@
Jan Kratochvil d258670
   attr = dwarf2_attr (die, DW_AT_associated, cu);
Jan Kratochvil d258670
   if (attr_form_is_block (attr))
Jan Kratochvil d258670
     {
Jan Kratochvil d258670
-      if (attr_to_dynamic_prop (attr, die, cu, &prop))
Jan Kratochvil d258670
+      if (attr_to_dynamic_prop (attr, die, cu, &prop, NULL, 0))
Jan Kratochvil d258670
         add_dyn_prop (DYN_PROP_ASSOCIATED, prop, type, objfile);
Jan Kratochvil d258670
     }
Jan Kratochvil d258670
   else if (attr != NULL)
Jan Kratochvil d258670
@@ -22444,7 +22550,7 @@
Jan Kratochvil d258670
 
Jan Kratochvil d258670
   /* Read DW_AT_data_location and set in type.  */
Jan Kratochvil d258670
   attr = dwarf2_attr (die, DW_AT_data_location, cu);
Jan Kratochvil d258670
-  if (attr_to_dynamic_prop (attr, die, cu, &prop))
Jan Kratochvil d258670
+  if (attr_to_dynamic_prop (attr, die, cu, &prop, NULL, 0))
Jan Kratochvil d258670
     add_dyn_prop (DYN_PROP_DATA_LOCATION, prop, type, objfile);
Jan Kratochvil d258670
 
Jan Kratochvil d258670
   if (dwarf2_per_objfile->die_type_hash == NULL)
Jan Kratochvil d258670
Index: gdb-7.11.90.20160907/gdb/f-typeprint.c
Jan Kratochvil d258670
===================================================================
Jan Kratochvil d258670
--- gdb-7.11.90.20160907.orig/gdb/f-typeprint.c	2016-09-07 21:52:10.272563051 +0200
Jan Kratochvil d258670
+++ gdb-7.11.90.20160907/gdb/f-typeprint.c	2016-09-07 21:53:22.713210461 +0200
Jan Kratochvil d258670
@@ -37,7 +37,7 @@
Jan Kratochvil d258670
 #endif
Jan Kratochvil d258670
 
Jan Kratochvil d258670
 static void f_type_print_varspec_suffix (struct type *, struct ui_file *, int,
Jan Kratochvil d258670
-					 int, int, int);
Jan Kratochvil d258670
+					 int, int, int, int);
Jan Kratochvil d258670
 
Jan Kratochvil d258670
 void f_type_print_varspec_prefix (struct type *, struct ui_file *,
Jan Kratochvil d258670
 				  int, int);
Jan Kratochvil d258670
@@ -54,18 +54,6 @@
Jan Kratochvil d258670
   enum type_code code;
Jan Kratochvil d258670
   int demangled_args;
Jan Kratochvil d258670
 
Jan Kratochvil d258670
-  if (type_not_associated (type))
Jan Kratochvil d258670
-    {
Jan Kratochvil d258670
-      val_print_not_associated (stream);
Jan Kratochvil d258670
-      return;
Jan Kratochvil d258670
-    }
Jan Kratochvil d258670
-
Jan Kratochvil d258670
-  if (type_not_allocated (type))
Jan Kratochvil d258670
-    {
Jan Kratochvil d258670
-      val_print_not_allocated (stream);
Jan Kratochvil d258670
-      return;
Jan Kratochvil d258670
-    }
Jan Kratochvil d258670
-
Jan Kratochvil d258670
   f_type_print_base (type, stream, show, level);
Jan Kratochvil d258670
   code = TYPE_CODE (type);
Jan Kratochvil d258670
   if ((varstring != NULL && *varstring != '\0')
Jan Kratochvil d258670
@@ -87,7 +75,7 @@
Jan Kratochvil d258670
          so don't print an additional pair of ()'s.  */
Jan Kratochvil d258670
 
Jan Kratochvil d258670
       demangled_args = varstring[strlen (varstring) - 1] == ')'; 
Jan Kratochvil d258670
-      f_type_print_varspec_suffix (type, stream, show, 0, demangled_args, 0);
Jan Kratochvil d258670
+      f_type_print_varspec_suffix (type, stream, show, 0, demangled_args, 0, 0);
Jan Kratochvil d258670
    }
Jan Kratochvil d258670
 }
Jan Kratochvil d258670
 
Jan Kratochvil d258670
@@ -157,7 +145,7 @@
Jan Kratochvil d258670
 static void
Jan Kratochvil d258670
 f_type_print_varspec_suffix (struct type *type, struct ui_file *stream,
Jan Kratochvil d258670
 			     int show, int passed_a_ptr, int demangled_args,
Jan Kratochvil d258670
-			     int arrayprint_recurse_level)
Jan Kratochvil d258670
+			     int arrayprint_recurse_level, int print_rank_only)
Jan Kratochvil d258670
 {
Jan Kratochvil d258670
   int upper_bound, lower_bound;
Jan Kratochvil d258670
 
Jan Kratochvil d258670
@@ -181,34 +169,50 @@
Jan Kratochvil d258670
 	fprintf_filtered (stream, "(");
Jan Kratochvil d258670
 
Jan Kratochvil d258670
       if (type_not_associated (type))
Jan Kratochvil d258670
-        val_print_not_associated (stream);
Jan Kratochvil d258670
+	print_rank_only = 1;
Jan Kratochvil d258670
       else if (type_not_allocated (type))
Jan Kratochvil d258670
-        val_print_not_allocated (stream);
Jan Kratochvil d258670
+	print_rank_only = 1;
Jan Kratochvil d258670
+      else if ((TYPE_ASSOCIATED_PROP (type)
Jan Kratochvil d258670
+		&& PROP_CONST != TYPE_DYN_PROP_KIND (TYPE_ASSOCIATED_PROP (type)))
Jan Kratochvil d258670
+	      || (TYPE_ALLOCATED_PROP (type)
Jan Kratochvil d258670
+		&& PROP_CONST != TYPE_DYN_PROP_KIND (TYPE_ALLOCATED_PROP (type)))
Jan Kratochvil d258670
+	      || (TYPE_DATA_LOCATION (type)
Jan Kratochvil d258670
+		  && PROP_CONST != TYPE_DYN_PROP_KIND (TYPE_DATA_LOCATION (type))))
Jan Kratochvil d258670
+	/* This case exist when we ptype a typename which has the
Jan Kratochvil d258670
+	   dynamic properties but cannot be resolved as there is
Jan Kratochvil d258670
+	   no object.  */
Jan Kratochvil d258670
+	print_rank_only = 1;
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+      if (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_ARRAY)
Jan Kratochvil d258670
+	f_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0,
Jan Kratochvil d258670
+				     0, 0, arrayprint_recurse_level,
Jan Kratochvil d258670
+				     print_rank_only);
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+      if (print_rank_only == 1)
Jan Kratochvil d258670
+	fprintf_filtered (stream, ":");
Jan Kratochvil d258670
       else
Jan Kratochvil d258670
-        {
Jan Kratochvil d258670
-          if (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_ARRAY)
Jan Kratochvil d258670
-            f_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0,
Jan Kratochvil d258670
-                                        0, 0, arrayprint_recurse_level);
Jan Kratochvil d258670
-
Jan Kratochvil d258670
-          lower_bound = f77_get_lowerbound (type);
Jan Kratochvil d258670
-          if (lower_bound != 1)	/* Not the default.  */
Jan Kratochvil d258670
-            fprintf_filtered (stream, "%d:", lower_bound);
Jan Kratochvil d258670
-
Jan Kratochvil d258670
-          /* Make sure that, if we have an assumed size array, we
Jan Kratochvil d258670
-             print out a warning and print the upperbound as '*'.  */
Jan Kratochvil d258670
-
Jan Kratochvil d258670
-          if (TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED (type))
Jan Kratochvil d258670
-            fprintf_filtered (stream, "*");
Jan Kratochvil d258670
-          else
Jan Kratochvil d258670
-            {
Jan Kratochvil d258670
-              upper_bound = f77_get_upperbound (type);
Jan Kratochvil d258670
-              fprintf_filtered (stream, "%d", upper_bound);
Jan Kratochvil d258670
-            }
Jan Kratochvil d258670
-
Jan Kratochvil d258670
-          if (TYPE_CODE (TYPE_TARGET_TYPE (type)) != TYPE_CODE_ARRAY)
Jan Kratochvil d258670
-            f_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0,
Jan Kratochvil d258670
-                                        0, 0, arrayprint_recurse_level);
Jan Kratochvil d258670
-        }
Jan Kratochvil d258670
+	{
Jan Kratochvil d258670
+	  lower_bound = f77_get_lowerbound (type);
Jan Kratochvil d258670
+	  if (lower_bound != 1)	/* Not the default.  */
Jan Kratochvil d258670
+	    fprintf_filtered (stream, "%d:", lower_bound);
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+	  /* Make sure that, if we have an assumed size array, we
Jan Kratochvil d258670
+	       print out a warning and print the upperbound as '*'.  */
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+	  if (TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED (type))
Jan Kratochvil d258670
+	    fprintf_filtered (stream, "*");
Jan Kratochvil d258670
+	  else
Jan Kratochvil d258670
+	    {
Jan Kratochvil d258670
+	      upper_bound = f77_get_upperbound (type);
Jan Kratochvil d258670
+	      fprintf_filtered (stream, "%d", upper_bound);
Jan Kratochvil d258670
+	    }
Jan Kratochvil d258670
+	}
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+      if (TYPE_CODE (TYPE_TARGET_TYPE (type)) != TYPE_CODE_ARRAY)
Jan Kratochvil d258670
+	f_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0,
Jan Kratochvil d258670
+				     0, 0, arrayprint_recurse_level,
Jan Kratochvil d258670
+				     print_rank_only);
Jan Kratochvil d258670
+
Jan Kratochvil d258670
       if (arrayprint_recurse_level == 1)
Jan Kratochvil d258670
 	fprintf_filtered (stream, ")");
Jan Kratochvil d258670
       else
Jan Kratochvil d258670
@@ -219,13 +223,14 @@
Jan Kratochvil d258670
     case TYPE_CODE_PTR:
Jan Kratochvil d258670
     case TYPE_CODE_REF:
Jan Kratochvil d258670
       f_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, 1, 0,
Jan Kratochvil d258670
-				   arrayprint_recurse_level);
Jan Kratochvil d258670
+				   arrayprint_recurse_level, 0);
Jan Kratochvil d258670
       fprintf_filtered (stream, ")");
Jan Kratochvil d258670
       break;
Jan Kratochvil d258670
 
Jan Kratochvil d258670
     case TYPE_CODE_FUNC:
Jan Kratochvil d258670
       f_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0,
Jan Kratochvil d258670
-				   passed_a_ptr, 0, arrayprint_recurse_level);
Jan Kratochvil d258670
+				   passed_a_ptr, 0, arrayprint_recurse_level,
Jan Kratochvil d258670
+				   0);
Jan Kratochvil d258670
       if (passed_a_ptr)
Jan Kratochvil d258670
 	fprintf_filtered (stream, ")");
Jan Kratochvil d258670
 
Jan Kratochvil d258670
@@ -376,7 +381,7 @@
Jan Kratochvil d258670
 	      fputs_filtered (" :: ", stream);
Jan Kratochvil d258670
 	      fputs_filtered (TYPE_FIELD_NAME (type, index), stream);
Jan Kratochvil d258670
 	      f_type_print_varspec_suffix (TYPE_FIELD_TYPE (type, index),
Jan Kratochvil d258670
-					   stream, show - 1, 0, 0, 0);
Jan Kratochvil d258670
+					   stream, show - 1, 0, 0, 0, 0);
Jan Kratochvil d258670
 	      fputs_filtered ("\n", stream);
Jan Kratochvil d258670
 	    }
Jan Kratochvil d258670
 	  fprintfi_filtered (level, stream, "End Type ");
Jan Kratochvil d258670
Index: gdb-7.11.90.20160907/gdb/gdbtypes.c
Jan Kratochvil d258670
===================================================================
Jan Kratochvil d258670
--- gdb-7.11.90.20160907.orig/gdb/gdbtypes.c	2016-09-07 21:52:53.703951202 +0200
Jan Kratochvil d258670
+++ gdb-7.11.90.20160907/gdb/gdbtypes.c	2016-09-07 21:53:22.714210470 +0200
Jan Kratochvil d258670
@@ -1816,7 +1816,8 @@
Jan Kratochvil d258670
   type = check_typedef (type);
Jan Kratochvil d258670
 
Jan Kratochvil d258670
   /* We only want to recognize references at the outermost level.  */
Jan Kratochvil d258670
-  if (top_level && TYPE_CODE (type) == TYPE_CODE_REF)
Jan Kratochvil d258670
+  if (top_level &&
Jan Kratochvil d258670
+      (TYPE_CODE (type) == TYPE_CODE_REF || TYPE_CODE (type) == TYPE_CODE_PTR))
Jan Kratochvil d258670
     type = check_typedef (TYPE_TARGET_TYPE (type));
Jan Kratochvil d258670
 
Jan Kratochvil d258670
   /* Types that have a dynamic TYPE_DATA_LOCATION are considered
Jan Kratochvil d258670
@@ -1850,6 +1851,7 @@
Jan Kratochvil d258670
       }
Jan Kratochvil d258670
 
Jan Kratochvil d258670
     case TYPE_CODE_ARRAY:
Jan Kratochvil d258670
+    case TYPE_CODE_STRING:
Jan Kratochvil d258670
       {
Jan Kratochvil d258670
 	gdb_assert (TYPE_NFIELDS (type) == 1);
Jan Kratochvil d258670
 
Jan Kratochvil d258670
@@ -1962,7 +1964,8 @@
Jan Kratochvil d258670
   struct type *ary_dim;
Jan Kratochvil d258670
   struct dynamic_prop *prop;
Jan Kratochvil d258670
 
Jan Kratochvil d258670
-  gdb_assert (TYPE_CODE (type) == TYPE_CODE_ARRAY);
Jan Kratochvil d258670
+  gdb_assert (TYPE_CODE (type) == TYPE_CODE_ARRAY
Jan Kratochvil d258670
+	      || TYPE_CODE (type) == TYPE_CODE_STRING);
Jan Kratochvil d258670
 
Jan Kratochvil d258670
   type = copy_type (type);
Jan Kratochvil d258670
 
Jan Kratochvil d258670
@@ -1987,13 +1990,17 @@
Jan Kratochvil d258670
 
Jan Kratochvil d258670
   ary_dim = check_typedef (TYPE_TARGET_TYPE (elt_type));
Jan Kratochvil d258670
 
Jan Kratochvil d258670
-  if (ary_dim != NULL && TYPE_CODE (ary_dim) == TYPE_CODE_ARRAY)
Jan Kratochvil d258670
+  if (ary_dim != NULL && (TYPE_CODE (ary_dim) == TYPE_CODE_ARRAY
Jan Kratochvil d258670
+      || TYPE_CODE (ary_dim) == TYPE_CODE_STRING))
Jan Kratochvil d258670
     elt_type = resolve_dynamic_array (ary_dim, addr_stack);
Jan Kratochvil d258670
   else
Jan Kratochvil d258670
     elt_type = TYPE_TARGET_TYPE (type);
Jan Kratochvil d258670
 
Jan Kratochvil d258670
-  return create_array_type_with_stride (type, elt_type, range_type,
Jan Kratochvil d258670
-                                        TYPE_FIELD_BITSIZE (type, 0));
Jan Kratochvil d258670
+  if (TYPE_CODE (type) == TYPE_CODE_STRING)
Jan Kratochvil d258670
+    return create_string_type (type, elt_type, range_type);
Jan Kratochvil d258670
+  else
Jan Kratochvil d258670
+    return create_array_type_with_stride (type, elt_type, range_type,
Jan Kratochvil d258670
+					  TYPE_FIELD_BITSIZE (type, 0));
Jan Kratochvil d258670
 }
Jan Kratochvil d258670
 
Jan Kratochvil d258670
 /* Resolve dynamic bounds of members of the union TYPE to static
Jan Kratochvil d258670
@@ -2123,6 +2130,28 @@
Jan Kratochvil d258670
   return resolved_type;
Jan Kratochvil d258670
 }
Jan Kratochvil d258670
 
Jan Kratochvil d258670
+/* Worker for pointer types.  */
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+static struct type *
Jan Kratochvil d258670
+resolve_dynamic_pointer (struct type *type,
Jan Kratochvil d258670
+			 struct property_addr_info *addr_stack)
Jan Kratochvil d258670
+{
Jan Kratochvil d258670
+  struct dynamic_prop *prop;
Jan Kratochvil d258670
+  CORE_ADDR value;
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+  type = copy_type (type);
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+  /* Resolve associated property.  */
Jan Kratochvil d258670
+  prop = TYPE_ASSOCIATED_PROP (type);
Jan Kratochvil d258670
+  if (prop != NULL && dwarf2_evaluate_property (prop, NULL, addr_stack, &value))
Jan Kratochvil d258670
+    {
Jan Kratochvil d258670
+      TYPE_DYN_PROP_ADDR (prop) = value;
Jan Kratochvil d258670
+      TYPE_DYN_PROP_KIND (prop) = PROP_CONST;
Jan Kratochvil d258670
+    }
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+  return type;
Jan Kratochvil d258670
+}
Jan Kratochvil d258670
+
Jan Kratochvil d258670
 /* Worker for resolved_dynamic_type.  */
Jan Kratochvil d258670
 
Jan Kratochvil d258670
 static struct type *
Jan Kratochvil d258670
@@ -2171,7 +2200,12 @@
Jan Kratochvil d258670
 	    break;
Jan Kratochvil d258670
 	  }
Jan Kratochvil d258670
 
Jan Kratochvil d258670
+        case TYPE_CODE_PTR:
Jan Kratochvil d258670
+ 	  resolved_type = resolve_dynamic_pointer (type, addr_stack);
Jan Kratochvil d258670
+ 	  break;
Jan Kratochvil d258670
+
Jan Kratochvil d258670
 	case TYPE_CODE_ARRAY:
Jan Kratochvil d258670
+	case TYPE_CODE_STRING:
Jan Kratochvil d258670
 	  resolved_type = resolve_dynamic_array (type, addr_stack);
Jan Kratochvil d258670
 	  break;
Jan Kratochvil d258670
 
Jan Kratochvil d258670
Index: gdb-7.11.90.20160907/gdb/testsuite/gdb.cp/vla-cxx.cc
Jan Kratochvil d258670
===================================================================
Jan Kratochvil d258670
--- gdb-7.11.90.20160907.orig/gdb/testsuite/gdb.cp/vla-cxx.cc	2016-09-07 21:52:10.272563051 +0200
Jan Kratochvil d258670
+++ gdb-7.11.90.20160907/gdb/testsuite/gdb.cp/vla-cxx.cc	2016-09-07 21:53:22.714210470 +0200
Jan Kratochvil d258670
@@ -15,6 +15,10 @@
Jan Kratochvil d258670
    You should have received a copy of the GNU General Public License
Jan Kratochvil d258670
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
Jan Kratochvil d258670
 
Jan Kratochvil d258670
+extern "C" {
Jan Kratochvil d258670
+#include <stddef.h>
Jan Kratochvil d258670
+}
Jan Kratochvil d258670
+
Jan Kratochvil d258670
 struct container;
Jan Kratochvil d258670
 
Jan Kratochvil d258670
 struct element
Jan Kratochvil d258670
@@ -40,11 +44,16 @@
Jan Kratochvil d258670
   typedef typeof (vla) &vlareftypedef;
Jan Kratochvil d258670
   vlareftypedef vlaref2 (vla);
Jan Kratochvil d258670
   container c;
Jan Kratochvil d258670
+  typeof (vla) *ptr = NULL;
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+  // Before pointer assignment
Jan Kratochvil d258670
+  ptr = &vla;
Jan Kratochvil d258670
 
Jan Kratochvil d258670
   for (int i = 0; i < z; ++i)
Jan Kratochvil d258670
     vla[i] = 5 + 2 * i;
Jan Kratochvil d258670
 
Jan Kratochvil d258670
   // vlas_filled
Jan Kratochvil d258670
   vla[0] = 2 * vla[0];
Jan Kratochvil d258670
+
Jan Kratochvil d258670
   return vla[2];
Jan Kratochvil d258670
 }
Jan Kratochvil d258670
Index: gdb-7.11.90.20160907/gdb/testsuite/gdb.cp/vla-cxx.exp
Jan Kratochvil d258670
===================================================================
Jan Kratochvil d258670
--- gdb-7.11.90.20160907.orig/gdb/testsuite/gdb.cp/vla-cxx.exp	2016-09-07 21:52:10.272563051 +0200
Jan Kratochvil d258670
+++ gdb-7.11.90.20160907/gdb/testsuite/gdb.cp/vla-cxx.exp	2016-09-07 21:53:22.715210479 +0200
Jan Kratochvil d258670
@@ -23,6 +23,12 @@
Jan Kratochvil d258670
     return -1
Jan Kratochvil d258670
 }
Jan Kratochvil d258670
 
Jan Kratochvil d258670
+gdb_breakpoint [gdb_get_line_number "Before pointer assignment"]
Jan Kratochvil d258670
+gdb_continue_to_breakpoint "Before pointer assignment"
Jan Kratochvil d258670
+gdb_test "ptype ptr" "int \\(\\*\\)\\\[variable length\\\]" "ptype ptr, Before pointer assignment"
Jan Kratochvil d258670
+gdb_test "print ptr" "\\(int \\(\\*\\)\\\[variable length\\\]\\) 0x0" "print ptr, Before pointer assignment"
Jan Kratochvil d258670
+gdb_test "print *ptr" "Cannot access memory at address 0x0" "print *ptr, Before pointer assignment"
Jan Kratochvil d258670
+
Jan Kratochvil d258670
 gdb_breakpoint [gdb_get_line_number "vlas_filled"]
Jan Kratochvil d258670
 gdb_continue_to_breakpoint "vlas_filled"
Jan Kratochvil d258670
 
Jan Kratochvil d258670
@@ -33,3 +39,6 @@
Jan Kratochvil d258670
 # bug being tested, it's better not to depend on the exact spelling.
Jan Kratochvil d258670
 gdb_test "print vlaref2" " = \\(.*\\) @$hex: \\{5, 7, 9\\}"
Jan Kratochvil d258670
 gdb_test "print c" " = \\{e = \\{c = @$hex\\}\\}"
Jan Kratochvil d258670
+gdb_test "ptype ptr" "int \\(\\*\\)\\\[3\\\]"
Jan Kratochvil d258670
+gdb_test "print ptr" "\\(int \\(\\*\\)\\\[3\\\]\\) $hex"
Jan Kratochvil d258670
+gdb_test "print *ptr" " = \\{5, 7, 9\\}"
Jan Kratochvil d258670
Index: gdb-7.11.90.20160907/gdb/testsuite/gdb.fortran/pointers.exp
Jan Kratochvil d258670
===================================================================
Jan Kratochvil d258670
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
Jan Kratochvil d258670
+++ gdb-7.11.90.20160907/gdb/testsuite/gdb.fortran/pointers.exp	2016-09-07 21:53:22.715210479 +0200
Jan Kratochvil d258670
@@ -0,0 +1,143 @@
Jan Kratochvil d258670
+# Copyright 2016 Free Software Foundation, Inc.
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+# This program is free software; you can redistribute it and/or modify
Jan Kratochvil d258670
+# it under the terms of the GNU General Public License as published by
Jan Kratochvil d258670
+# the Free Software Foundation; either version 3 of the License, or
Jan Kratochvil d258670
+# (at your option) any later version.
Jan Kratochvil d258670
+#
Jan Kratochvil d258670
+# This program is distributed in the hope that it will be useful,
Jan Kratochvil d258670
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
Jan Kratochvil d258670
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Jan Kratochvil d258670
+# GNU General Public License for more details.
Jan Kratochvil d258670
+#
Jan Kratochvil d258670
+# You should have received a copy of the GNU General Public License
Jan Kratochvil d258670
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+standard_testfile "pointers.f90"
Jan Kratochvil d258670
+load_lib fortran.exp
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
Jan Kratochvil d258670
+    {debug f90 quiet}] } {
Jan Kratochvil d258670
+    return -1
Jan Kratochvil d258670
+}
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+if ![runto_main] {
Jan Kratochvil d258670
+    untested "could not run to main"
Jan Kratochvil d258670
+    return -1
Jan Kratochvil d258670
+}
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+# Depending on the compiler being used, the type names can be printed differently.
Jan Kratochvil d258670
+set logical [fortran_logical4]
Jan Kratochvil d258670
+set real [fortran_real4]
Jan Kratochvil d258670
+set int [fortran_int4]
Jan Kratochvil d258670
+set complex [fortran_complex4]
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+gdb_breakpoint [gdb_get_line_number "Before pointer assignment"]
Jan Kratochvil d258670
+gdb_continue_to_breakpoint "Before pointer assignment"
Jan Kratochvil d258670
+gdb_test "print logp" "= \\(PTR TO -> \\( $logical \\)\\) 0x0" "print logp, not associated"
Jan Kratochvil d258670
+gdb_test "print *logp" "Cannot access memory at address 0x0" "print *logp, not associated"
Jan Kratochvil d258670
+gdb_test "print comp" "= \\(PTR TO -> \\( $complex \\)\\) 0x0" "print comp, not associated"
Jan Kratochvil d258670
+gdb_test "print *comp" "Cannot access memory at address 0x0" "print *comp, not associated"
Jan Kratochvil d258670
+gdb_test "print charp" "= \\(PTR TO -> \\( character\\*1 \\)\\) 0x0" "print charp, not associated"
Jan Kratochvil d258670
+gdb_test "print *charp" "Cannot access memory at address 0x0" "print *charp, not associated"
Jan Kratochvil d258670
+gdb_test "print charap" "= \\(PTR TO -> \\( character\\*3 \\)\\) 0x0" "print charap, not associated"
Jan Kratochvil d258670
+gdb_test "print *charap" "Cannot access memory at address 0x0" "print *charap, not associated"
Jan Kratochvil d258670
+gdb_test "print intp" "= \\(PTR TO -> \\( $int \\)\\) 0x0" "print intp, not associated"
Jan Kratochvil d258670
+gdb_test "print *intp" "Cannot access memory at address 0x0" "print *intp, not associated"
Jan Kratochvil d258670
+set test "print intap, not associated"
Jan Kratochvil d258670
+gdb_test_multiple "print intap" $test {
Jan Kratochvil d258670
+  -re " = \\(PTR TO -> \\( $int \\(:,:\\)\\)\\) <not associated>\r\n$gdb_prompt $" {
Jan Kratochvil d258670
+    pass $test
Jan Kratochvil d258670
+  }
Jan Kratochvil d258670
+  -re " = <not associated>\r\n$gdb_prompt $" {
Jan Kratochvil d258670
+    pass $test
Jan Kratochvil d258670
+  }
Jan Kratochvil d258670
+}
Jan Kratochvil d258670
+gdb_test "print realp" "= \\(PTR TO -> \\( $real \\)\\) 0x0" "print realp, not associated"
Jan Kratochvil d258670
+gdb_test "print *realp" "Cannot access memory at address 0x0" "print *realp, not associated"
Jan Kratochvil d258670
+gdb_test "print \$my_var = intp" "= \\(PTR TO -> \\( $int \\)\\) 0x0"
Jan Kratochvil d258670
+set test "print cyclicp1, not associated"
Jan Kratochvil d258670
+gdb_test_multiple "print cyclicp1" $test {
Jan Kratochvil d258670
+  -re "= \\( i = -?\\d+, p = 0x0 \\)\r\n$gdb_prompt $" {
Jan Kratochvil d258670
+    pass $test
Jan Kratochvil d258670
+  }
Jan Kratochvil d258670
+  -re "= \\( i = -?\\d+, p = <not associated> \\)\r\n$gdb_prompt $" {
Jan Kratochvil d258670
+    pass $test
Jan Kratochvil d258670
+  }
Jan Kratochvil d258670
+}
Jan Kratochvil d258670
+set test "print cyclicp1%p, not associated"
Jan Kratochvil d258670
+gdb_test_multiple "print cyclicp1%p" $test {
Jan Kratochvil d258670
+  -re "= \\(PTR TO -> \\( Type typewithpointer \\)\\) 0x0\r\n$gdb_prompt $" {
Jan Kratochvil d258670
+    pass $test
Jan Kratochvil d258670
+  }
Jan Kratochvil d258670
+  -re "= \\(PTR TO -> \\( Type typewithpointer \\)\\) <not associated>\r\n$gdb_prompt $" {
Jan Kratochvil d258670
+    pass $test
Jan Kratochvil d258670
+  }
Jan Kratochvil d258670
+}
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+gdb_breakpoint [gdb_get_line_number "Before value assignment"]
Jan Kratochvil d258670
+gdb_continue_to_breakpoint "Before value assignment"
Jan Kratochvil d258670
+gdb_test "print *(twop)%ivla2" "= <not allocated>"
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+gdb_breakpoint [gdb_get_line_number "After value assignment"]
Jan Kratochvil d258670
+gdb_continue_to_breakpoint "After value assignment"
Jan Kratochvil d258670
+gdb_test "print logp" "= \\(PTR TO -> \\( $logical \\)\\) $hex\( <.*>\)?"
Jan Kratochvil d258670
+gdb_test "print *logp" "= \\.TRUE\\."
Jan Kratochvil d258670
+gdb_test "print comp" "= \\(PTR TO -> \\( $complex \\)\\) $hex\( <.*>\)?"
Jan Kratochvil d258670
+gdb_test "print *comp" "= \\(1,2\\)"
Jan Kratochvil d258670
+gdb_test "print charp" "= \\(PTR TO -> \\( character\\*1 \\)\\) $hex\( <.*>\)?"
Jan Kratochvil d258670
+gdb_test "print *charp" "= 'a'"
Jan Kratochvil d258670
+gdb_test "print charap" "= \\(PTR TO -> \\( character\\*3 \\)\\) $hex\( <.*>\)?"
Jan Kratochvil d258670
+gdb_test "print *charap" "= 'abc'"
Jan Kratochvil d258670
+gdb_test "print intp" "= \\(PTR TO -> \\( $int \\)\\) $hex\( <.*>\)?"
Jan Kratochvil d258670
+gdb_test "print *intp" "= 10"
Jan Kratochvil d258670
+set test_name "print intap, associated"
Jan Kratochvil d258670
+gdb_test_multiple "print intap" $test_name {
Jan Kratochvil d258670
+  -re "= \\(\\( 1, 1, 3(, 1){7}\\) \\( 1(, 1){9}\\) \\)\r\n$gdb_prompt $" {
Jan Kratochvil d258670
+    pass $test_name
Jan Kratochvil d258670
+  }
Jan Kratochvil d258670
+  -re "= \\(PTR TO -> \\( $int \\(10,2\\)\\)\\) $hex\( <.*>\)?\r\n$gdb_prompt $" {
Jan Kratochvil d258670
+    gdb_test "print *intap" "= \\(\\( 1, 1, 3(, 1){7}\\) \\( 1(, 1){9}\\) \\)"
Jan Kratochvil d258670
+    pass $test_name
Jan Kratochvil d258670
+  }
Jan Kratochvil d258670
+}
Jan Kratochvil d258670
+set test_name "print intvlap, associated"
Jan Kratochvil d258670
+gdb_test_multiple "print intvlap" $test_name {
Jan Kratochvil d258670
+  -re "= \\(2, 2, 2, 4(, 2){6}\\)\r\n$gdb_prompt $" {
Jan Kratochvil d258670
+    pass $test_name
Jan Kratochvil d258670
+  }
Jan Kratochvil d258670
+  -re "= \\(PTR TO -> \\( $int \\(10\\)\\)\\) $hex\( <.*>\)?\r\n$gdb_prompt $" {
Jan Kratochvil d258670
+    gdb_test "print *intvlap" "= \\(2, 2, 2, 4(, 2){6}\\)"
Jan Kratochvil d258670
+    pass $test_name
Jan Kratochvil d258670
+  }
Jan Kratochvil d258670
+}
Jan Kratochvil d258670
+gdb_test "print realp" "= \\(PTR TO -> \\( $real \\)\\) $hex\( <.*>\)?"
Jan Kratochvil d258670
+gdb_test "print *realp" "= 3\\.14000\\d+"
Jan Kratochvil d258670
+gdb_test "print arrayOfPtr(2)%p" "= \\(PTR TO -> \\( Type two \\)\\) $hex\( <.*>\)?"
Jan Kratochvil d258670
+gdb_test "print *(arrayOfPtr(2)%p)" "= \\( ivla1 = \\(11, 12, 13\\), ivla2 = \\(\\( 211, 221\\) \\( 212, 222\\) \\) \\)"
Jan Kratochvil d258670
+set test_name "print arrayOfPtr(3)%p"
Jan Kratochvil d258670
+gdb_test_multiple $test_name $test_name {
Jan Kratochvil d258670
+  -re "= \\(PTR TO -> \\( Type two \\)\\) <not associated>\r\n$gdb_prompt $" {
Jan Kratochvil d258670
+    pass $test_name
Jan Kratochvil d258670
+  }
Jan Kratochvil d258670
+  -re "= \\(PTR TO -> \\( Type two \\)\\) 0x0\r\n$gdb_prompt $" {
Jan Kratochvil d258670
+    pass $test_name
Jan Kratochvil d258670
+  }
Jan Kratochvil d258670
+}
Jan Kratochvil d258670
+set test_name "print *(arrayOfPtr(3)%p), associated"
Jan Kratochvil d258670
+gdb_test_multiple "print *(arrayOfPtr(3)%p)" $test_name {
Jan Kratochvil d258670
+  -re "Cannot access memory at address 0x0\r\n$gdb_prompt $" {
Jan Kratochvil d258670
+    pass $test_name
Jan Kratochvil d258670
+  }
Jan Kratochvil d258670
+  -re "Attempt to take contents of a not associated pointer.\r\n$gdb_prompt $" {
Jan Kratochvil d258670
+    pass $test_name
Jan Kratochvil d258670
+  }
Jan Kratochvil d258670
+}
Jan Kratochvil d258670
+gdb_test "print cyclicp1" "= \\( i = 1, p = $hex\( <.*>\)? \\)"
Jan Kratochvil d258670
+gdb_test "print cyclicp1%p" "= \\(PTR TO -> \\( Type typewithpointer \\)\\) $hex\( <.*>\)?"
Jan Kratochvil d258670
+gdb_test "print *((integer*) &inta + 2)" "= 3" "print temporary pointer, array"
Jan Kratochvil d258670
+gdb_test "print *((integer*) &intvla + 3)" "= 4" "print temporary pointer, allocated vla"
Jan Kratochvil d258670
+gdb_test "print \$pc" "= \\(PTR TO -> \\( void \\(\\)\\(\\)\\)\\) $hex <pointers\\+\\d+>" "Print program counter"
Jan Kratochvil d258670
Index: gdb-7.11.90.20160907/gdb/testsuite/gdb.fortran/pointers.f90
Jan Kratochvil d258670
===================================================================
Jan Kratochvil d258670
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
Jan Kratochvil d258670
+++ gdb-7.11.90.20160907/gdb/testsuite/gdb.fortran/pointers.f90	2016-09-07 21:53:22.715210479 +0200
Jan Kratochvil d258670
@@ -0,0 +1,109 @@
Jan Kratochvil d258670
+! Copyright 2016 Free Software Foundation, Inc.
Jan Kratochvil d258670
+!
Jan Kratochvil d258670
+! This program is free software; you can redistribute it and/or modify
Jan Kratochvil d258670
+! it under the terms of the GNU General Public License as published by
Jan Kratochvil d258670
+! the Free Software Foundation; either version 3 of the License, or
Jan Kratochvil d258670
+! (at your option) any later version.
Jan Kratochvil d258670
+!
Jan Kratochvil d258670
+! This program is distributed in the hope that it will be useful,
Jan Kratochvil d258670
+! but WITHOUT ANY WARRANTY; without even the implied warranty of
Jan Kratochvil d258670
+! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Jan Kratochvil d258670
+! GNU General Public License for more details.
Jan Kratochvil d258670
+!
Jan Kratochvil d258670
+! You should have received a copy of the GNU General Public License
Jan Kratochvil d258670
+! along with this program.  If not, see <http://www.gnu.org/licenses/>.
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+program pointers
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+  type :: two
Jan Kratochvil d258670
+    integer, allocatable :: ivla1 (:)
Jan Kratochvil d258670
+    integer, allocatable :: ivla2 (:, :)
Jan Kratochvil d258670
+  end type two
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+  type :: typeWithPointer
Jan Kratochvil d258670
+    integer i
Jan Kratochvil d258670
+    type(typeWithPointer), pointer:: p
Jan Kratochvil d258670
+  end type typeWithPointer
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+  type :: twoPtr
Jan Kratochvil d258670
+    type (two), pointer :: p
Jan Kratochvil d258670
+  end type twoPtr
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+  logical, target :: logv
Jan Kratochvil d258670
+  complex, target :: comv
Jan Kratochvil d258670
+  character, target :: charv
Jan Kratochvil d258670
+  character (len=3), target :: chara
Jan Kratochvil d258670
+  integer, target :: intv
Jan Kratochvil d258670
+  integer, target, dimension (10,2) :: inta
Jan Kratochvil d258670
+  integer, target, allocatable, dimension (:) :: intvla
Jan Kratochvil d258670
+  real, target    :: realv
Jan Kratochvil d258670
+  type(two), target  :: twov
Jan Kratochvil d258670
+  type(twoPtr) :: arrayOfPtr (3)
Jan Kratochvil d258670
+  type(typeWithPointer), target:: cyclicp1,cyclicp2
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+  logical, pointer :: logp
Jan Kratochvil d258670
+  complex, pointer :: comp
Jan Kratochvil d258670
+  character, pointer:: charp
Jan Kratochvil d258670
+  character (len=3), pointer:: charap
Jan Kratochvil d258670
+  integer, pointer :: intp
Jan Kratochvil d258670
+  integer, pointer, dimension (:,:) :: intap
Jan Kratochvil d258670
+  integer, pointer, dimension (:) :: intvlap
Jan Kratochvil d258670
+  real, pointer :: realp
Jan Kratochvil d258670
+  type(two), pointer :: twop
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+  nullify (logp)
Jan Kratochvil d258670
+  nullify (comp)
Jan Kratochvil d258670
+  nullify (charp)
Jan Kratochvil d258670
+  nullify (charap)
Jan Kratochvil d258670
+  nullify (intp)
Jan Kratochvil d258670
+  nullify (intap)
Jan Kratochvil d258670
+  nullify (intvlap)
Jan Kratochvil d258670
+  nullify (realp)
Jan Kratochvil d258670
+  nullify (twop)
Jan Kratochvil d258670
+  nullify (arrayOfPtr(1)%p)
Jan Kratochvil d258670
+  nullify (arrayOfPtr(2)%p)
Jan Kratochvil d258670
+  nullify (arrayOfPtr(3)%p)
Jan Kratochvil d258670
+  nullify (cyclicp1%p)
Jan Kratochvil d258670
+  nullify (cyclicp2%p)
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+  logp => logv    ! Before pointer assignment
Jan Kratochvil d258670
+  comp => comv
Jan Kratochvil d258670
+  charp => charv
Jan Kratochvil d258670
+  charap => chara
Jan Kratochvil d258670
+  intp => intv
Jan Kratochvil d258670
+  intap => inta
Jan Kratochvil d258670
+  intvlap => intvla
Jan Kratochvil d258670
+  realp => realv
Jan Kratochvil d258670
+  twop => twov
Jan Kratochvil d258670
+  arrayOfPtr(2)%p => twov
Jan Kratochvil d258670
+  cyclicp1%i = 1
Jan Kratochvil d258670
+  cyclicp1%p => cyclicp2
Jan Kratochvil d258670
+  cyclicp2%i = 2
Jan Kratochvil d258670
+  cyclicp2%p => cyclicp1
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+  logv = associated(logp)     ! Before value assignment
Jan Kratochvil d258670
+  comv = cmplx(1,2)
Jan Kratochvil d258670
+  charv = "a"
Jan Kratochvil d258670
+  chara = "abc"
Jan Kratochvil d258670
+  intv = 10
Jan Kratochvil d258670
+  inta(:,:) = 1
Jan Kratochvil d258670
+  inta(3,1) = 3
Jan Kratochvil d258670
+  allocate (intvla(10))
Jan Kratochvil d258670
+  intvla(:) = 2
Jan Kratochvil d258670
+  intvla(4) = 4
Jan Kratochvil d258670
+  intvlap => intvla
Jan Kratochvil d258670
+  realv = 3.14
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+  allocate (twov%ivla1(3))
Jan Kratochvil d258670
+  allocate (twov%ivla2(2,2))
Jan Kratochvil d258670
+  twov%ivla1(1) = 11
Jan Kratochvil d258670
+  twov%ivla1(2) = 12
Jan Kratochvil d258670
+  twov%ivla1(3) = 13
Jan Kratochvil d258670
+  twov%ivla2(1,1) = 211
Jan Kratochvil d258670
+  twov%ivla2(2,1) = 221
Jan Kratochvil d258670
+  twov%ivla2(1,2) = 212
Jan Kratochvil d258670
+  twov%ivla2(2,2) = 222
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+  intv = intv + 1 ! After value assignment
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+end program pointers
Jan Kratochvil d258670
Index: gdb-7.11.90.20160907/gdb/testsuite/gdb.fortran/print_type.exp
Jan Kratochvil d258670
===================================================================
Jan Kratochvil d258670
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
Jan Kratochvil d258670
+++ gdb-7.11.90.20160907/gdb/testsuite/gdb.fortran/print_type.exp	2016-09-07 21:53:22.715210479 +0200
Jan Kratochvil d258670
@@ -0,0 +1,100 @@
Jan Kratochvil d258670
+# Copyright 2016 Free Software Foundation, Inc.
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+# This program is free software; you can redistribute it and/or modify
Jan Kratochvil d258670
+# it under the terms of the GNU General Public License as published by
Jan Kratochvil d258670
+# the Free Software Foundation; either version 3 of the License, or
Jan Kratochvil d258670
+# (at your option) any later version.
Jan Kratochvil d258670
+#
Jan Kratochvil d258670
+# This program is distributed in the hope that it will be useful,
Jan Kratochvil d258670
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
Jan Kratochvil d258670
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Jan Kratochvil d258670
+# GNU General Public License for more details.
Jan Kratochvil d258670
+#
Jan Kratochvil d258670
+# You should have received a copy of the GNU General Public License
Jan Kratochvil d258670
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+standard_testfile "pointers.f90"
Jan Kratochvil d258670
+load_lib fortran.exp
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
Jan Kratochvil d258670
+    {debug f90 quiet}] } {
Jan Kratochvil d258670
+    return -1
Jan Kratochvil d258670
+}
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+if ![runto_main] {
Jan Kratochvil d258670
+    untested "could not run to main"
Jan Kratochvil d258670
+    return -1
Jan Kratochvil d258670
+}
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+# Depending on the compiler being used, the type names can be printed differently.
Jan Kratochvil d258670
+set logical [fortran_logical4]
Jan Kratochvil d258670
+set real [fortran_real4]
Jan Kratochvil d258670
+set int [fortran_int4]
Jan Kratochvil d258670
+set complex [fortran_complex4]
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+gdb_breakpoint [gdb_get_line_number "Before pointer assignment"]
Jan Kratochvil d258670
+gdb_continue_to_breakpoint "Before pointer assignment"
Jan Kratochvil d258670
+gdb_test "ptype logp" "type = PTR TO -> \\( $logical \\)" "ptype logp, not associated"
Jan Kratochvil d258670
+gdb_test "ptype comp" "type = PTR TO -> \\( $complex \\)" "ptype comp, not associated"
Jan Kratochvil d258670
+gdb_test "ptype charp" "type = PTR TO -> \\( character\\*1 \\)" "ptype charp, not associated"
Jan Kratochvil d258670
+gdb_test "ptype charap" "type = PTR TO -> \\( character\\*3 \\)" "ptype charap, not associated"
Jan Kratochvil d258670
+gdb_test "ptype intp" "type = PTR TO -> \\( $int \\)" "ptype intp, not associated"
Jan Kratochvil d258670
+set test "ptype intap, not associated"
Jan Kratochvil d258670
+gdb_test_multiple "ptype intap" $test {
Jan Kratochvil d258670
+    -re "type = PTR TO -> \\( $int \\(:,:\\)\\)\r\n$gdb_prompt $" {
Jan Kratochvil d258670
+        pass $test
Jan Kratochvil d258670
+    }
Jan Kratochvil d258670
+    -re "type = $int \\(:,:\\)\r\n$gdb_prompt $" {
Jan Kratochvil d258670
+        pass $test
Jan Kratochvil d258670
+    }
Jan Kratochvil d258670
+}
Jan Kratochvil d258670
+gdb_test "ptype realp" "type = PTR TO -> \\( $real \\)" "ptype realp, not associated"
Jan Kratochvil d258670
+gdb_test "ptype twop" \
Jan Kratochvil d258670
+    [multi_line "type = PTR TO -> \\( Type two" \
Jan Kratochvil d258670
+                "    $int :: ivla1\\(:\\)" \
Jan Kratochvil d258670
+                "    $int :: ivla2\\(:,:\\)" \
Jan Kratochvil d258670
+                "End Type two \\)"] \
Jan Kratochvil d258670
+    "ptype twop, not associated"
Jan Kratochvil d258670
+gdb_test "ptype two" \
Jan Kratochvil d258670
+    [multi_line "type = Type two" \
Jan Kratochvil d258670
+                "    $int :: ivla1\\(:\\)" \
Jan Kratochvil d258670
+                "    $int :: ivla2\\(:,:\\)" \
Jan Kratochvil d258670
+                "End Type two"]
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+gdb_breakpoint [gdb_get_line_number "Before value assignment"]
Jan Kratochvil d258670
+gdb_continue_to_breakpoint "Before value assignment"
Jan Kratochvil d258670
+gdb_test "ptype twop" \
Jan Kratochvil d258670
+    [multi_line "type = PTR TO -> \\( Type two" \
Jan Kratochvil d258670
+                "    $int :: ivla1\\(:\\)" \
Jan Kratochvil d258670
+                "    $int :: ivla2\\(:,:\\)" \
Jan Kratochvil d258670
+                "End Type two \\)"]
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+gdb_breakpoint [gdb_get_line_number "After value assignment"]
Jan Kratochvil d258670
+gdb_continue_to_breakpoint "After value assignment"
Jan Kratochvil d258670
+gdb_test "ptype logv" "type = $logical"
Jan Kratochvil d258670
+gdb_test "ptype comv" "type = $complex"
Jan Kratochvil d258670
+gdb_test "ptype charv" "type = character\\*1"
Jan Kratochvil d258670
+gdb_test "ptype chara" "type = character\\*3"
Jan Kratochvil d258670
+gdb_test "ptype intv" "type = $int"
Jan Kratochvil d258670
+gdb_test "ptype inta" "type = $int \\(10,2\\)"
Jan Kratochvil d258670
+gdb_test "ptype realv" "type = $real"
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+gdb_test "ptype logp" "type = PTR TO -> \\( $logical \\)"
Jan Kratochvil d258670
+gdb_test "ptype comp" "type = PTR TO -> \\( $complex \\)"
Jan Kratochvil d258670
+gdb_test "ptype charp" "type = PTR TO -> \\( character\\*1 \\)"
Jan Kratochvil d258670
+gdb_test "ptype charap" "type = PTR TO -> \\( character\\*3 \\)"
Jan Kratochvil d258670
+gdb_test "ptype intp" "type = PTR TO -> \\( $int \\)"
Jan Kratochvil d258670
+set test "ptype intap"
Jan Kratochvil d258670
+gdb_test_multiple $test $test {
Jan Kratochvil d258670
+    -re "type = $int \\(10,2\\)\r\n$gdb_prompt $" {
Jan Kratochvil d258670
+        pass $test
Jan Kratochvil d258670
+    }
Jan Kratochvil d258670
+    -re "type = PTR TO -> \\( $int \\(10,2\\)\\)\r\n$gdb_prompt $" {
Jan Kratochvil d258670
+        pass $test
Jan Kratochvil d258670
+    }
Jan Kratochvil d258670
+}
Jan Kratochvil d258670
+gdb_test "ptype realp" "type = PTR TO -> \\( $real \\)"
Jan Kratochvil d258670
Index: gdb-7.11.90.20160907/gdb/testsuite/gdb.fortran/vla-ptype.exp
Jan Kratochvil d258670
===================================================================
Jan Kratochvil d258670
--- gdb-7.11.90.20160907.orig/gdb/testsuite/gdb.fortran/vla-ptype.exp	2016-09-07 21:52:53.705951220 +0200
Jan Kratochvil d258670
+++ gdb-7.11.90.20160907/gdb/testsuite/gdb.fortran/vla-ptype.exp	2016-09-07 21:53:22.715210479 +0200
Jan Kratochvil d258670
@@ -32,9 +32,9 @@
Jan Kratochvil d258670
 # Check the ptype of various VLA states and pointer to VLA's.
Jan Kratochvil d258670
 gdb_breakpoint [gdb_get_line_number "vla1-init"]
Jan Kratochvil d258670
 gdb_continue_to_breakpoint "vla1-init"
Jan Kratochvil d258670
-gdb_test "ptype vla1" "type = <not allocated>" "ptype vla1 not initialized"
Jan Kratochvil d258670
-gdb_test "ptype vla2" "type = <not allocated>" "ptype vla2 not initialized"
Jan Kratochvil d258670
-gdb_test "ptype pvla" "type = <not associated>" "ptype pvla not initialized"
Jan Kratochvil d258670
+gdb_test "ptype vla1" "type = $real \\(:,:,:\\)" "ptype vla1 not initialized"
Jan Kratochvil d258670
+gdb_test "ptype vla2" "type = $real \\(:,:,:\\)" "ptype vla2 not initialized"
Jan Kratochvil d258670
+gdb_test "ptype pvla" "type = $real \\(:,:,:\\)" "ptype pvla not initialized"
Jan Kratochvil d258670
 gdb_test "ptype vla1(3, 6, 9)" "no such vector element \\\(vector not allocated\\\)" \
Jan Kratochvil d258670
   "ptype vla1(3, 6, 9) not initialized"
Jan Kratochvil d258670
 gdb_test "ptype vla2(5, 45, 20)" \
Jan Kratochvil d258670
@@ -81,20 +81,20 @@
Jan Kratochvil d258670
 
Jan Kratochvil d258670
 gdb_breakpoint [gdb_get_line_number "pvla-deassociated"]
Jan Kratochvil d258670
 gdb_continue_to_breakpoint "pvla-deassociated"
Jan Kratochvil d258670
-gdb_test "ptype pvla" "type = <not associated>" "ptype pvla deassociated"
Jan Kratochvil d258670
+gdb_test "ptype pvla" "type = $real \\(:,:,:\\)" "ptype pvla deassociated"
Jan Kratochvil d258670
 gdb_test "ptype pvla(5, 45, 20)" \
Jan Kratochvil d258670
   "no such vector element \\\(vector not associated\\\)" \
Jan Kratochvil d258670
   "ptype pvla(5, 45, 20) not associated"
Jan Kratochvil d258670
 
Jan Kratochvil d258670
 gdb_breakpoint [gdb_get_line_number "vla1-deallocated"]
Jan Kratochvil d258670
 gdb_continue_to_breakpoint "vla1-deallocated"
Jan Kratochvil d258670
-gdb_test "ptype vla1" "type = <not allocated>" "ptype vla1 not allocated"
Jan Kratochvil d258670
+gdb_test "ptype vla1" "type = $real \\(:,:,:\\)" "ptype vla1 not allocated"
Jan Kratochvil d258670
 gdb_test "ptype vla1(3, 6, 9)" "no such vector element \\\(vector not allocated\\\)" \
Jan Kratochvil d258670
   "ptype vla1(3, 6, 9) not allocated"
Jan Kratochvil d258670
 
Jan Kratochvil d258670
 gdb_breakpoint [gdb_get_line_number "vla2-deallocated"]
Jan Kratochvil d258670
 gdb_continue_to_breakpoint "vla2-deallocated"
Jan Kratochvil d258670
-gdb_test "ptype vla2" "type = <not allocated>" "ptype vla2 not allocated"
Jan Kratochvil d258670
+gdb_test "ptype vla2" "type = $real \\(:,:,:\\)" "ptype vla2 not allocated"
Jan Kratochvil d258670
 gdb_test "ptype vla2(5, 45, 20)" \
Jan Kratochvil d258670
   "no such vector element \\\(vector not allocated\\\)" \
Jan Kratochvil d258670
   "ptype vla2(5, 45, 20) not allocated"
Jan Kratochvil d258670
Index: gdb-7.11.90.20160907/gdb/testsuite/gdb.fortran/vla-strings.exp
Jan Kratochvil d258670
===================================================================
Jan Kratochvil d258670
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
Jan Kratochvil d258670
+++ gdb-7.11.90.20160907/gdb/testsuite/gdb.fortran/vla-strings.exp	2016-09-07 21:53:22.716210488 +0200
Jan Kratochvil d258670
@@ -0,0 +1,103 @@
Jan Kratochvil d258670
+# Copyright 2016 Free Software Foundation, Inc.
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+# This program is free software; you can redistribute it and/or modify
Jan Kratochvil d258670
+# it under the terms of the GNU General Public License as published by
Jan Kratochvil d258670
+# the Free Software Foundation; either version 3 of the License, or
Jan Kratochvil d258670
+# (at your option) any later version.
Jan Kratochvil d258670
+#
Jan Kratochvil d258670
+# This program is distributed in the hope that it will be useful,
Jan Kratochvil d258670
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
Jan Kratochvil d258670
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Jan Kratochvil d258670
+# GNU General Public License for more details.
Jan Kratochvil d258670
+#
Jan Kratochvil d258670
+# You should have received a copy of the GNU General Public License
Jan Kratochvil d258670
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+standard_testfile ".f90"
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
Jan Kratochvil d258670
+    {debug f90 quiet}] } {
Jan Kratochvil d258670
+    return -1
Jan Kratochvil d258670
+}
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+# check that all fortran standard datatypes will be
Jan Kratochvil d258670
+# handled correctly when using as VLA's
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+if ![runto_main] {
Jan Kratochvil d258670
+    untested "could not run to main"
Jan Kratochvil d258670
+    return -1
Jan Kratochvil d258670
+}
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+gdb_breakpoint [gdb_get_line_number "var_char-allocated-1"]
Jan Kratochvil d258670
+gdb_continue_to_breakpoint "var_char-allocated-1"
Jan Kratochvil d258670
+set test "whatis var_char first time"
Jan Kratochvil d258670
+gdb_test_multiple "whatis var_char" $test {
Jan Kratochvil d258670
+    -re "type = PTR TO -> \\( character\\*10 \\)\r\n$gdb_prompt $" {
Jan Kratochvil d258670
+	    pass $test
Jan Kratochvil d258670
+    }
Jan Kratochvil d258670
+    -re "type = character\\*10\r\n$gdb_prompt $" {
Jan Kratochvil d258670
+	    pass $test
Jan Kratochvil d258670
+    }
Jan Kratochvil d258670
+}
Jan Kratochvil d258670
+set test "ptype var_char first time"
Jan Kratochvil d258670
+gdb_test_multiple "ptype var_char" $test {
Jan Kratochvil d258670
+    -re "type = PTR TO -> \\( character\\*10 \\)\r\n$gdb_prompt $" {
Jan Kratochvil d258670
+	    pass $test
Jan Kratochvil d258670
+    }
Jan Kratochvil d258670
+    -re "type = character\\*10\r\n$gdb_prompt $" {
Jan Kratochvil d258670
+	    pass $test
Jan Kratochvil d258670
+    }
Jan Kratochvil d258670
+}
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+gdb_test "next" "\\d+.*var_char = 'foo'.*" \
Jan Kratochvil d258670
+  "next to allocation status of var_char"
Jan Kratochvil d258670
+gdb_test "print l" " = \\.TRUE\\." "print allocation status first time"
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+gdb_breakpoint [gdb_get_line_number "var_char-filled-1"]
Jan Kratochvil d258670
+gdb_continue_to_breakpoint "var_char-filled-1"
Jan Kratochvil d258670
+set test "print var_char, var_char-filled-1"
Jan Kratochvil d258670
+gdb_test_multiple "print var_char" $test {
Jan Kratochvil d258670
+    -re "= \\(PTR TO -> \\( character\\*3 \\)\\) $hex\r\n$gdb_prompt $" {
Jan Kratochvil d258670
+        gdb_test "print *var_char" "= 'foo'" "print *var_char, var_char-filled-1"
Jan Kratochvil d258670
+	    pass $test
Jan Kratochvil d258670
+    }
Jan Kratochvil d258670
+    -re "= 'foo'\r\n$gdb_prompt $" {
Jan Kratochvil d258670
+	    pass $test
Jan Kratochvil d258670
+    }
Jan Kratochvil d258670
+}
Jan Kratochvil d258670
+set test "ptype var_char, var_char-filled-1"
Jan Kratochvil d258670
+gdb_test_multiple "ptype var_char" $test {
Jan Kratochvil d258670
+    -re "type = PTR TO -> \\( character\\*3 \\)\r\n$gdb_prompt $" {
Jan Kratochvil d258670
+	    pass $test
Jan Kratochvil d258670
+    }
Jan Kratochvil d258670
+    -re "type = character\\*3\r\n$gdb_prompt $" {
Jan Kratochvil d258670
+	    pass $test
Jan Kratochvil d258670
+    }
Jan Kratochvil d258670
+}
Jan Kratochvil d258670
+gdb_test "print var_char(1)" " = 102 'f'" "print var_char(1)"
Jan Kratochvil d258670
+gdb_test "print var_char(3)" " = 111 'o'" "print var_char(3)"
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+gdb_breakpoint [gdb_get_line_number "var_char-filled-2"]
Jan Kratochvil d258670
+gdb_continue_to_breakpoint "var_char-filled-2"
Jan Kratochvil d258670
+set test "print var_char, var_char-filled-2"
Jan Kratochvil d258670
+gdb_test_multiple "print var_char" $test {
Jan Kratochvil d258670
+    -re "= \\(PTR TO -> \\( character\\*6 \\)\\) $hex\r\n$gdb_prompt $" {
Jan Kratochvil d258670
+        gdb_test "print *var_char" "= 'foobar'" "print *var_char, var_char-filled-2"
Jan Kratochvil d258670
+	    pass $test
Jan Kratochvil d258670
+    }
Jan Kratochvil d258670
+    -re "= 'foobar'\r\n$gdb_prompt $" {
Jan Kratochvil d258670
+	    pass $test
Jan Kratochvil d258670
+    }
Jan Kratochvil d258670
+}
Jan Kratochvil d258670
+set test "ptype var_char, var_char-filled-2"
Jan Kratochvil d258670
+gdb_test_multiple "ptype var_char" $test {
Jan Kratochvil d258670
+    -re "type = PTR TO -> \\( character\\*6 \\)\r\n$gdb_prompt $" {
Jan Kratochvil d258670
+	    pass $test
Jan Kratochvil d258670
+    }
Jan Kratochvil d258670
+    -re "type = character\\*6\r\n$gdb_prompt $" {
Jan Kratochvil d258670
+	    pass $test
Jan Kratochvil d258670
+    }
Jan Kratochvil d258670
+}
Jan Kratochvil d258670
Index: gdb-7.11.90.20160907/gdb/testsuite/gdb.fortran/vla-strings.f90
Jan Kratochvil d258670
===================================================================
Jan Kratochvil d258670
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
Jan Kratochvil d258670
+++ gdb-7.11.90.20160907/gdb/testsuite/gdb.fortran/vla-strings.f90	2016-09-07 21:53:22.716210488 +0200
Jan Kratochvil d258670
@@ -0,0 +1,39 @@
Jan Kratochvil d258670
+! Copyright 2016 Free Software Foundation, Inc.
Jan Kratochvil d258670
+!
Jan Kratochvil d258670
+! This program is free software; you can redistribute it and/or modify
Jan Kratochvil d258670
+! it under the terms of the GNU General Public License as published by
Jan Kratochvil d258670
+! the Free Software Foundation; either version 3 of the License, or
Jan Kratochvil d258670
+! (at your option) any later version.
Jan Kratochvil d258670
+!
Jan Kratochvil d258670
+! This program is distributed in the hope that it will be useful,
Jan Kratochvil d258670
+! but WITHOUT ANY WARRANTY; without even the implied warranty of
Jan Kratochvil d258670
+! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Jan Kratochvil d258670
+! GNU General Public License for more details.
Jan Kratochvil d258670
+!
Jan Kratochvil d258670
+! You should have received a copy of the GNU General Public License
Jan Kratochvil d258670
+! along with this program.  If not, see <http://www.gnu.org/licenses/>.
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+program vla_strings
Jan Kratochvil d258670
+  character(len=:), target, allocatable   :: var_char
Jan Kratochvil d258670
+  character(len=:), pointer               :: var_char_p
Jan Kratochvil d258670
+  logical                                 :: l
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+  allocate(character(len=10) :: var_char)
Jan Kratochvil d258670
+  l = allocated(var_char)                 ! var_char-allocated-1
Jan Kratochvil d258670
+  var_char = 'foo'
Jan Kratochvil d258670
+  deallocate(var_char)                    ! var_char-filled-1
Jan Kratochvil d258670
+  l = allocated(var_char)                 ! var_char-deallocated
Jan Kratochvil d258670
+  allocate(character(len=42) :: var_char)
Jan Kratochvil d258670
+  l = allocated(var_char)
Jan Kratochvil d258670
+  var_char = 'foobar'
Jan Kratochvil d258670
+  var_char = ''                           ! var_char-filled-2
Jan Kratochvil d258670
+  var_char = 'bar'                        ! var_char-empty
Jan Kratochvil d258670
+  deallocate(var_char)
Jan Kratochvil d258670
+  allocate(character(len=21) :: var_char)
Jan Kratochvil d258670
+  l = allocated(var_char)                 ! var_char-allocated-3
Jan Kratochvil d258670
+  var_char = 'johndoe'
Jan Kratochvil d258670
+  var_char_p => var_char
Jan Kratochvil d258670
+  l = associated(var_char_p)              ! var_char_p-associated
Jan Kratochvil d258670
+  var_char_p => null()
Jan Kratochvil d258670
+  l = associated(var_char_p)              ! var_char_p-not-associated
Jan Kratochvil d258670
+end program vla_strings
Jan Kratochvil d258670
Index: gdb-7.11.90.20160907/gdb/testsuite/gdb.fortran/vla-type.exp
Jan Kratochvil d258670
===================================================================
Jan Kratochvil d258670
--- gdb-7.11.90.20160907.orig/gdb/testsuite/gdb.fortran/vla-type.exp	2016-09-07 21:52:10.272563051 +0200
Jan Kratochvil d258670
+++ gdb-7.11.90.20160907/gdb/testsuite/gdb.fortran/vla-type.exp	2016-09-07 21:53:22.716210488 +0200
Jan Kratochvil d258670
@@ -132,7 +132,10 @@
Jan Kratochvil d258670
                      "End Type one" ]
Jan Kratochvil d258670
 
Jan Kratochvil d258670
 # Check allocation status of dynamic array and it's dynamic members
Jan Kratochvil d258670
-gdb_test "ptype fivedynarr" "type = <not allocated>"
Jan Kratochvil d258670
+gdb_test "ptype fivedynarr" \
Jan Kratochvil d258670
+         [multi_line "type = Type five" \
Jan Kratochvil d258670
+                     "    Type one :: tone" \
Jan Kratochvil d258670
+                     "End Type five \\(:\\)" ]
Jan Kratochvil d258670
 gdb_test "next" ""
Jan Kratochvil d258670
 gdb_test "ptype fivedynarr(2)" \
Jan Kratochvil d258670
          [multi_line "type = Type five" \
Jan Kratochvil d258670
@@ -141,7 +144,7 @@
Jan Kratochvil d258670
          "ptype fivedynarr(2), tone is not allocated"
Jan Kratochvil d258670
 gdb_test "ptype fivedynarr(2)%tone" \
Jan Kratochvil d258670
          [multi_line "type = Type one" \
Jan Kratochvil d258670
-                     "    $int :: ivla\\(<not allocated>\\)" \
Jan Kratochvil d258670
+                     "    $int :: ivla\\(:,:,:\\)" \
Jan Kratochvil d258670
                      "End Type one" ] \
Jan Kratochvil d258670
          "ptype fivedynarr(2)%tone, not allocated"
Jan Kratochvil d258670
 
Jan Kratochvil d258670
Index: gdb-7.11.90.20160907/gdb/testsuite/gdb.fortran/vla-value.exp
Jan Kratochvil d258670
===================================================================
Jan Kratochvil d258670
--- gdb-7.11.90.20160907.orig/gdb/testsuite/gdb.fortran/vla-value.exp	2016-09-07 21:52:10.272563051 +0200
Jan Kratochvil d258670
+++ gdb-7.11.90.20160907/gdb/testsuite/gdb.fortran/vla-value.exp	2016-09-07 21:53:22.716210488 +0200
Jan Kratochvil d258670
@@ -14,6 +14,7 @@
Jan Kratochvil d258670
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
Jan Kratochvil d258670
 
Jan Kratochvil d258670
 standard_testfile "vla.f90"
Jan Kratochvil d258670
+load_lib "fortran.exp"
Jan Kratochvil d258670
 
Jan Kratochvil d258670
 if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
Jan Kratochvil d258670
      {debug f90 quiet}] } {
Jan Kratochvil d258670
@@ -25,12 +26,15 @@
Jan Kratochvil d258670
     return -1
Jan Kratochvil d258670
 }
Jan Kratochvil d258670
 
Jan Kratochvil d258670
+# Depending on the compiler being used, the type names can be printed differently.
Jan Kratochvil d258670
+set real [fortran_real4]
Jan Kratochvil d258670
+
Jan Kratochvil d258670
 # Try to access values in non allocated VLA
Jan Kratochvil d258670
 gdb_breakpoint [gdb_get_line_number "vla1-init"]
Jan Kratochvil d258670
 gdb_continue_to_breakpoint "vla1-init"
Jan Kratochvil d258670
 gdb_test "print vla1" " = <not allocated>" "print non-allocated vla1"
Jan Kratochvil d258670
 gdb_test "print &vla1" \
Jan Kratochvil d258670
-  " = \\\(PTR TO -> \\\( real\\\(kind=4\\\) \\\(<not allocated>\\\)\\\)\\\) $hex" \
Jan Kratochvil d258670
+  " = \\\(PTR TO -> \\\( $real \\\(:,:,:\\\)\\\)\\\) $hex" \
Jan Kratochvil d258670
   "print non-allocated &vla1"
Jan Kratochvil d258670
 gdb_test "print vla1(1,1,1)" "no such vector element \\\(vector not allocated\\\)" \
Jan Kratochvil d258670
   "print member in non-allocated vla1 (1)"
Jan Kratochvil d258670
@@ -51,7 +55,7 @@
Jan Kratochvil d258670
 	"step over value assignment of vla1"
Jan Kratochvil d258670
 }
Jan Kratochvil d258670
 gdb_test "print &vla1" \
Jan Kratochvil d258670
-  " = \\\(PTR TO -> \\\( real\\\(kind=4\\\) \\\(10,10,10\\\)\\\)\\\) $hex" \
Jan Kratochvil d258670
+  " = \\\(PTR TO -> \\\( $real \\\(10,10,10\\\)\\\)\\\) $hex" \
Jan Kratochvil d258670
   "print allocated &vla1"
Jan Kratochvil d258670
 gdb_test "print vla1(3, 6, 9)" " = 1311" "print allocated vla1(3,6,9)"
Jan Kratochvil d258670
 gdb_test "print vla1(1, 3, 8)" " = 1311" "print allocated vla1(1,3,8)"
Jan Kratochvil d258670
@@ -71,7 +75,7 @@
Jan Kratochvil d258670
 # Try to access values in undefined pointer to VLA (dangling)
Jan Kratochvil d258670
 gdb_test "print pvla" " = <not associated>" "print undefined pvla"
Jan Kratochvil d258670
 gdb_test "print &pvla" \
Jan Kratochvil d258670
-  " = \\\(PTR TO -> \\\( real\\\(kind=4\\\) \\\(<not associated>\\\)\\\)\\\) $hex" \
Jan Kratochvil d258670
+  " = \\\(PTR TO -> \\\( $real \\\(:,:,:\\\)\\\)\\\) $hex" \
Jan Kratochvil d258670
   "print non-associated &pvla"
Jan Kratochvil d258670
 gdb_test "print pvla(1, 3, 8)" "no such vector element \\\(vector not associated\\\)" \
Jan Kratochvil d258670
   "print undefined pvla(1,3,8)"
Jan Kratochvil d258670
@@ -80,7 +84,7 @@
Jan Kratochvil d258670
 gdb_breakpoint [gdb_get_line_number "pvla-associated"]
Jan Kratochvil d258670
 gdb_continue_to_breakpoint "pvla-associated"
Jan Kratochvil d258670
 gdb_test "print &pvla" \
Jan Kratochvil d258670
-  " = \\\(PTR TO -> \\\( real\\\(kind=4\\\) \\\(10,10,10\\\)\\\)\\\) $hex" \
Jan Kratochvil d258670
+  " = \\\(PTR TO -> \\\( $real \\\(10,10,10\\\)\\\)\\\) $hex" \
Jan Kratochvil d258670
   "print associated &pvla"
Jan Kratochvil d258670
 gdb_test "print pvla(3, 6, 9)" " = 42" "print associated pvla(3,6,9)"
Jan Kratochvil d258670
 gdb_test "print pvla(1, 3, 8)" " = 1001" "print associated pvla(1,3,8)"
Jan Kratochvil d258670
Index: gdb-7.11.90.20160907/gdb/testsuite/gdb.mi/mi-var-child-f.exp
Jan Kratochvil d258670
===================================================================
Jan Kratochvil d258670
--- gdb-7.11.90.20160907.orig/gdb/testsuite/gdb.mi/mi-var-child-f.exp	2016-09-07 21:52:10.272563051 +0200
Jan Kratochvil d258670
+++ gdb-7.11.90.20160907/gdb/testsuite/gdb.mi/mi-var-child-f.exp	2016-09-07 21:53:22.716210488 +0200
Jan Kratochvil d258670
@@ -17,6 +17,7 @@
Jan Kratochvil d258670
 
Jan Kratochvil d258670
 load_lib mi-support.exp
Jan Kratochvil d258670
 set MIFLAGS "-i=mi"
Jan Kratochvil d258670
+load_lib "fortran.exp"
Jan Kratochvil d258670
 
Jan Kratochvil d258670
 if { [skip_fortran_tests] } { return -1 }
Jan Kratochvil d258670
 
Jan Kratochvil d258670
@@ -40,10 +41,8 @@
Jan Kratochvil d258670
 mi_create_varobj "array" "array" "create local variable array"
Jan Kratochvil d258670
 
Jan Kratochvil d258670
 
Jan Kratochvil d258670
-# Depending on the compiler version being used, the name of the 4-byte integer
Jan Kratochvil d258670
-# and real types can be printed differently.  For instance, gfortran-4.1 uses
Jan Kratochvil d258670
-# "int4" whereas gfortran-4.3 uses "integer(kind=4)".
Jan Kratochvil d258670
-set int4 "(int4|integer\\(kind=4\\))"
Jan Kratochvil d258670
+# Depending on the compiler being used, the type names can be printed differently.
Jan Kratochvil d258670
+set int4 [fortran_int4]
Jan Kratochvil d258670
 
Jan Kratochvil d258670
 set children [list [list "array.-1" "-1" 2 "$int4 \\(2\\)"] \
Jan Kratochvil d258670
 		  [list "array.0" "0" 2 "$int4 \\(2\\)"] \
Jan Kratochvil d258670
Index: gdb-7.11.90.20160907/gdb/testsuite/gdb.mi/mi-vla-fortran.exp
Jan Kratochvil d258670
===================================================================
Jan Kratochvil d258670
--- gdb-7.11.90.20160907.orig/gdb/testsuite/gdb.mi/mi-vla-fortran.exp	2016-09-07 21:52:10.272563051 +0200
Jan Kratochvil d258670
+++ gdb-7.11.90.20160907/gdb/testsuite/gdb.mi/mi-vla-fortran.exp	2016-09-07 21:53:22.716210488 +0200
Jan Kratochvil d258670
@@ -17,7 +17,9 @@
Jan Kratochvil d258670
 # Array (VLA).
Jan Kratochvil d258670
 
Jan Kratochvil d258670
 load_lib mi-support.exp
Jan Kratochvil d258670
+load_lib fortran.exp
Jan Kratochvil d258670
 set MIFLAGS "-i=mi"
Jan Kratochvil d258670
+load_lib "fortran.exp"
Jan Kratochvil d258670
 
Jan Kratochvil d258670
 gdb_exit
Jan Kratochvil d258670
 if [mi_gdb_start] {
Jan Kratochvil d258670
@@ -32,6 +34,9 @@
Jan Kratochvil d258670
      return -1
Jan Kratochvil d258670
 }
Jan Kratochvil d258670
 
Jan Kratochvil d258670
+# Depending on the compiler being used, the type names can be printed differently.
Jan Kratochvil d258670
+set real [fortran_real4]
Jan Kratochvil d258670
+
Jan Kratochvil d258670
 mi_delete_breakpoints
Jan Kratochvil d258670
 mi_gdb_reinitialize_dir $srcdir/$subdir
Jan Kratochvil d258670
 mi_gdb_load ${binfile}
Jan Kratochvil d258670
@@ -46,10 +51,10 @@
Jan Kratochvil d258670
 mi_gdb_test "500-data-evaluate-expression vla1" \
Jan Kratochvil d258670
   "500\\^done,value=\"<not allocated>\"" "evaluate not allocated vla"
Jan Kratochvil d258670
 
Jan Kratochvil d258670
-mi_create_varobj_checked vla1_not_allocated vla1 "<not allocated>" \
Jan Kratochvil d258670
+mi_create_varobj_checked vla1_not_allocated vla1 "$real \\(:\\)" \
Jan Kratochvil d258670
   "create local variable vla1_not_allocated"
Jan Kratochvil d258670
 mi_gdb_test "501-var-info-type vla1_not_allocated" \
Jan Kratochvil d258670
-  "501\\^done,type=\"<not allocated>\"" \
Jan Kratochvil d258670
+  "501\\^done,type=\"$real \\(:\\)\"" \
Jan Kratochvil d258670
   "info type variable vla1_not_allocated"
Jan Kratochvil d258670
 mi_gdb_test "502-var-show-format vla1_not_allocated" \
Jan Kratochvil d258670
   "502\\^done,format=\"natural\"" \
Jan Kratochvil d258670
@@ -58,7 +63,7 @@
Jan Kratochvil d258670
   "503\\^done,value=\"\\\[0\\\]\"" \
Jan Kratochvil d258670
   "eval variable vla1_not_allocated"
Jan Kratochvil d258670
 mi_list_array_varobj_children_with_index "vla1_not_allocated" "0" "1" \
Jan Kratochvil d258670
-    "real\\\(kind=4\\\)" "get children of vla1_not_allocated"
Jan Kratochvil d258670
+    "$real" "get children of vla1_not_allocated"
Jan Kratochvil d258670
 
Jan Kratochvil d258670
 
Jan Kratochvil d258670
 
Jan Kratochvil d258670
@@ -71,10 +76,10 @@
Jan Kratochvil d258670
 mi_gdb_test "510-data-evaluate-expression vla1" \
Jan Kratochvil d258670
   "510\\^done,value=\"\\(.*\\)\"" "evaluate allocated vla"
Jan Kratochvil d258670
 
Jan Kratochvil d258670
-mi_create_varobj_checked vla1_allocated vla1 "real\\\(kind=4\\\) \\\(5\\\)" \
Jan Kratochvil d258670
+mi_create_varobj_checked vla1_allocated vla1 "$real \\\(5\\\)" \
Jan Kratochvil d258670
   "create local variable vla1_allocated"
Jan Kratochvil d258670
 mi_gdb_test "511-var-info-type vla1_allocated" \
Jan Kratochvil d258670
-  "511\\^done,type=\"real\\\(kind=4\\\) \\\(5\\\)\"" \
Jan Kratochvil d258670
+  "511\\^done,type=\"$real \\\(5\\\)\"" \
Jan Kratochvil d258670
   "info type variable vla1_allocated"
Jan Kratochvil d258670
 mi_gdb_test "512-var-show-format vla1_allocated" \
Jan Kratochvil d258670
   "512\\^done,format=\"natural\"" \
Jan Kratochvil d258670
@@ -83,7 +88,7 @@
Jan Kratochvil d258670
   "513\\^done,value=\"\\\[5\\\]\"" \
Jan Kratochvil d258670
   "eval variable vla1_allocated"
Jan Kratochvil d258670
 mi_list_array_varobj_children_with_index "vla1_allocated" "5" "1" \
Jan Kratochvil d258670
-    "real\\\(kind=4\\\)" "get children of vla1_allocated"
Jan Kratochvil d258670
+    "$real" "get children of vla1_allocated"
Jan Kratochvil d258670
 
Jan Kratochvil d258670
 
Jan Kratochvil d258670
 set bp_lineno [gdb_get_line_number "vla1-filled"]
Jan Kratochvil d258670
@@ -136,10 +141,10 @@
Jan Kratochvil d258670
     -re "580\\^done,value=\"<not associated>\".*${mi_gdb_prompt}$" {
Jan Kratochvil d258670
 	pass $test
Jan Kratochvil d258670
 
Jan Kratochvil d258670
-	mi_create_varobj_checked pvla2_not_associated pvla2 "<not associated>" \
Jan Kratochvil d258670
+	mi_create_varobj_checked pvla2_not_associated pvla2 "$real \\(:,:\\)" \
Jan Kratochvil d258670
 	    "create local variable pvla2_not_associated"
Jan Kratochvil d258670
 	mi_gdb_test "581-var-info-type pvla2_not_associated" \
Jan Kratochvil d258670
-	    "581\\^done,type=\"<not associated>\"" \
Jan Kratochvil d258670
+	    "581\\^done,type=\"$real \\(:,:\\)\"" \
Jan Kratochvil d258670
 	    "info type variable pvla2_not_associated"
Jan Kratochvil d258670
 	mi_gdb_test "582-var-show-format pvla2_not_associated" \
Jan Kratochvil d258670
 	    "582\\^done,format=\"natural\"" \
Jan Kratochvil d258670
@@ -148,7 +153,7 @@
Jan Kratochvil d258670
 	    "583\\^done,value=\"\\\[0\\\]\"" \
Jan Kratochvil d258670
 	    "eval variable pvla2_not_associated"
Jan Kratochvil d258670
 	mi_list_array_varobj_children_with_index "pvla2_not_associated" "0" "1" \
Jan Kratochvil d258670
-	    "real\\\(kind=4\\\)" "get children of pvla2_not_associated"
Jan Kratochvil d258670
+	    "$real" "get children of pvla2_not_associated"
Jan Kratochvil d258670
     }
Jan Kratochvil d258670
     -re "580\\^error,msg=\"value contents too large \\(\[0-9\]+ bytes\\).*${mi_gdb_prompt}$" {
Jan Kratochvil d258670
 	# Undefined behaviour in gfortran.
Jan Kratochvil d258670
@@ -173,9 +178,9 @@
Jan Kratochvil d258670
   "evaluate associated vla"
Jan Kratochvil d258670
 
Jan Kratochvil d258670
 mi_create_varobj_checked pvla2_associated pvla2 \
Jan Kratochvil d258670
-  "real\\\(kind=4\\\) \\\(5,2\\\)" "create local variable pvla2_associated"
Jan Kratochvil d258670
+  "$real \\\(5,2\\\)" "create local variable pvla2_associated"
Jan Kratochvil d258670
 mi_gdb_test "591-var-info-type pvla2_associated" \
Jan Kratochvil d258670
-  "591\\^done,type=\"real\\\(kind=4\\\) \\\(5,2\\\)\"" \
Jan Kratochvil d258670
+  "591\\^done,type=\"$real \\\(5,2\\\)\"" \
Jan Kratochvil d258670
   "info type variable pvla2_associated"
Jan Kratochvil d258670
 mi_gdb_test "592-var-show-format pvla2_associated" \
Jan Kratochvil d258670
   "592\\^done,format=\"natural\"" \
Jan Kratochvil d258670
Index: gdb-7.11.90.20160907/gdb/typeprint.c
Jan Kratochvil d258670
===================================================================
Jan Kratochvil d258670
--- gdb-7.11.90.20160907.orig/gdb/typeprint.c	2016-09-07 21:52:10.272563051 +0200
Jan Kratochvil d258670
+++ gdb-7.11.90.20160907/gdb/typeprint.c	2016-09-07 21:53:22.717210497 +0200
Jan Kratochvil d258670
@@ -485,6 +485,25 @@
Jan Kratochvil d258670
       printf_filtered (" */\n");    
Jan Kratochvil d258670
     }
Jan Kratochvil d258670
 
Jan Kratochvil d258670
+  /* Resolve any dynamic target type, as we might print
Jan Kratochvil d258670
+     additional information about the target.
Jan Kratochvil d258670
+     For example, in Fortran and C we are printing the dimension of the
Jan Kratochvil d258670
+     dynamic array the pointer is pointing to.  */
Jan Kratochvil d258670
+  if (TYPE_CODE (type) == TYPE_CODE_PTR
Jan Kratochvil d258670
+      && is_dynamic_type (type) == 1)
Jan Kratochvil d258670
+    {
Jan Kratochvil d258670
+      CORE_ADDR addr;
Jan Kratochvil d258670
+      if (NULL != TYPE_DATA_LOCATION (TYPE_TARGET_TYPE(type)))
Jan Kratochvil d258670
+	addr = value_address (val);
Jan Kratochvil d258670
+      else
Jan Kratochvil d258670
+	addr = value_as_address (val);
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+      if (addr != 0
Jan Kratochvil d258670
+	  && type_not_associated (type) == 0)
Jan Kratochvil d258670
+	TYPE_TARGET_TYPE (type) = resolve_dynamic_type (TYPE_TARGET_TYPE (type),
Jan Kratochvil d258670
+							NULL, addr);
Jan Kratochvil d258670
+    }
Jan Kratochvil d258670
+
Jan Kratochvil d258670
   LA_PRINT_TYPE (type, "", gdb_stdout, show, 0, &flags);
Jan Kratochvil d258670
   printf_filtered ("\n");
Jan Kratochvil d258670
 
Jan Kratochvil d258670
Index: gdb-7.11.90.20160907/gdb/valops.c
Jan Kratochvil d258670
===================================================================
Jan Kratochvil d258670
--- gdb-7.11.90.20160907.orig/gdb/valops.c	2016-09-07 21:52:53.707951238 +0200
Jan Kratochvil d258670
+++ gdb-7.11.90.20160907/gdb/valops.c	2016-09-07 21:53:22.717210497 +0200
Jan Kratochvil d258670
@@ -1562,6 +1562,19 @@
Jan Kratochvil d258670
   if (TYPE_CODE (base_type) == TYPE_CODE_PTR)
Jan Kratochvil d258670
     {
Jan Kratochvil d258670
       struct type *enc_type;
Jan Kratochvil d258670
+      CORE_ADDR addr;
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+      if (type_not_associated (base_type))
Jan Kratochvil d258670
+        error (_("Attempt to take contents of a not associated pointer."));
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+      if (NULL != TYPE_DATA_LOCATION (TYPE_TARGET_TYPE (base_type)))
Jan Kratochvil d258670
+	addr = value_address (arg1);
Jan Kratochvil d258670
+      else
Jan Kratochvil d258670
+	addr = value_as_address (arg1);
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+      if (addr != 0)
Jan Kratochvil d258670
+	TYPE_TARGET_TYPE (base_type) =
Jan Kratochvil d258670
+	    resolve_dynamic_type (TYPE_TARGET_TYPE (base_type), NULL, addr);
Jan Kratochvil d258670
 
Jan Kratochvil d258670
       /* We may be pointing to something embedded in a larger object.
Jan Kratochvil d258670
          Get the real type of the enclosing object.  */
Jan Kratochvil d258670
@@ -1577,8 +1590,7 @@
Jan Kratochvil d258670
       else
Jan Kratochvil d258670
 	/* Retrieve the enclosing object pointed to.  */
Jan Kratochvil d258670
 	arg2 = value_at_lazy (enc_type, 
Jan Kratochvil d258670
-			      (value_as_address (arg1)
Jan Kratochvil d258670
-			       - value_pointed_to_offset (arg1)));
Jan Kratochvil d258670
+			      (addr - value_pointed_to_offset (arg1)));
Jan Kratochvil d258670
 
Jan Kratochvil d258670
       enc_type = value_type (arg2);
Jan Kratochvil d258670
       return readjust_indirect_value_type (arg2, enc_type, base_type, arg1);
Jan Kratochvil d258670
Index: gdb-7.11.90.20160907/gdb/valprint.c
Jan Kratochvil d258670
===================================================================
Jan Kratochvil d258670
--- gdb-7.11.90.20160907.orig/gdb/valprint.c	2016-09-07 21:52:10.273563060 +0200
Jan Kratochvil d258670
+++ gdb-7.11.90.20160907/gdb/valprint.c	2016-09-07 21:53:22.718210506 +0200
Jan Kratochvil d258670
@@ -1141,12 +1141,6 @@
Jan Kratochvil d258670
       return 0;
Jan Kratochvil d258670
     }
Jan Kratochvil d258670
 
Jan Kratochvil d258670
-  if (type_not_associated (value_type (val)))
Jan Kratochvil d258670
-    {
Jan Kratochvil d258670
-      val_print_not_associated (stream);
Jan Kratochvil d258670
-      return 0;
Jan Kratochvil d258670
-    }
Jan Kratochvil d258670
-
Jan Kratochvil d258670
   if (type_not_allocated (value_type (val)))
Jan Kratochvil d258670
     {
Jan Kratochvil d258670
       val_print_not_allocated (stream);