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