689258
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
689258
From: Fedora GDB patches <invalid@email.com>
689258
Date: Fri, 27 Oct 2017 21:07:50 +0200
689258
Subject: gdb-vla-intel-fortran-vla-strings.patch
689258
689258
;;=push
689258
689258
git diff --stat -p gdb/master...gdb/users/bheckel/fortran-vla-strings
689258
0ad7d8d1a3a36c6e04e3b6d37d8825f18d595723
689258
689258
 gdb/NEWS                                  |   2 +
689258
 gdb/c-valprint.c                          |  22 +++++
689258
 gdb/dwarf2read.c                          | 158 +++++++++++++++++++++++++-----
689258
 gdb/f-typeprint.c                         |  93 +++++++++---------
689258
 gdb/gdbtypes.c                            |  44 ++++++++-
689258
 gdb/testsuite/gdb.cp/vla-cxx.cc           |   9 ++
689258
 gdb/testsuite/gdb.cp/vla-cxx.exp          |   9 ++
689258
 gdb/testsuite/gdb.fortran/pointers.exp    | 143 +++++++++++++++++++++++++++
689258
 gdb/testsuite/gdb.fortran/pointers.f90    | 109 +++++++++++++++++++++
689258
 gdb/testsuite/gdb.fortran/print_type.exp  | 100 +++++++++++++++++++
689258
 gdb/testsuite/gdb.fortran/vla-ptype.exp   |  12 +--
689258
 gdb/testsuite/gdb.fortran/vla-strings.exp | 103 +++++++++++++++++++
689258
 gdb/testsuite/gdb.fortran/vla-strings.f90 |  39 ++++++++
689258
 gdb/testsuite/gdb.fortran/vla-type.exp    |   7 +-
689258
 gdb/testsuite/gdb.fortran/vla-value.exp   |  12 ++-
689258
 gdb/testsuite/gdb.mi/mi-var-child-f.exp   |   7 +-
689258
 gdb/testsuite/gdb.mi/mi-vla-fortran.exp   |  27 ++---
689258
 gdb/typeprint.c                           |  19 ++++
689258
 gdb/valops.c                              |  16 ++-
689258
 gdb/valprint.c                            |   6 --
689258
 20 files changed, 827 insertions(+), 110 deletions(-)
689258
689258
diff --git a/gdb/NEWS b/gdb/NEWS
689258
--- a/gdb/NEWS
689258
+++ b/gdb/NEWS
689258
@@ -109,6 +109,8 @@ SH-5/SH64 running OpenBSD 	SH-5/SH64 support in sh*-*-openbsd*
689258
 
689258
 *** Changes in GDB 8.1
689258
 
689258
+* Fortran: Support pointers to dynamic types.
689258
+
689258
 * GDB now supports dynamically creating arbitrary register groups specified
689258
   in XML target descriptions.  This allows for finer grain grouping of
689258
   registers on systems with a large amount of registers.
689258
diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c
689258
--- a/gdb/c-valprint.c
689258
+++ b/gdb/c-valprint.c
689258
@@ -653,6 +653,28 @@ c_value_print (struct value *val, struct ui_file *stream,
689258
       else
689258
 	{
689258
 	  /* normal case */
689258
+	  if (TYPE_CODE (type) == TYPE_CODE_PTR
689258
+	      && 1 == is_dynamic_type (type))
689258
+	    {
689258
+	      CORE_ADDR addr;
689258
+	      if (NULL != TYPE_DATA_LOCATION (TYPE_TARGET_TYPE (type)))
689258
+		addr = value_address (val);
689258
+	      else
689258
+		addr = value_as_address (val);
689258
+
689258
+	      /* We resolve the target-type only when the
689258
+	         pointer is associated.  */
689258
+	      if ((addr != 0)
689258
+		  && (0 == type_not_associated (type)))
689258
+		  TYPE_TARGET_TYPE (type) =
689258
+		      resolve_dynamic_type (TYPE_TARGET_TYPE (type),
689258
+					    NULL, addr);
689258
+	    }
689258
+	  else
689258
+	    {
689258
+	      /* Do nothing. References are already resolved from the beginning,
689258
+	         only pointers are resolved when we actual need the target.  */
689258
+	    }
689258
 	  fprintf_filtered (stream, "(");
689258
 	  type_print (value_type (val), "", stream, -1);
689258
 	  fprintf_filtered (stream, ") ");
689258
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
689258
--- a/gdb/dwarf2read.c
689258
+++ b/gdb/dwarf2read.c
689258
@@ -1789,7 +1789,8 @@ static void read_signatured_type (struct signatured_type *);
689258
 
689258
 static int attr_to_dynamic_prop (const struct attribute *attr,
689258
 				 struct die_info *die, struct dwarf2_cu *cu,
689258
-				 struct dynamic_prop *prop);
689258
+				 struct dynamic_prop *prop, const gdb_byte *additional_data,
689258
+				 int additional_data_size);
689258
 
689258
 /* memory allocation interface */
689258
 
689258
@@ -13648,7 +13649,7 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu)
689258
     {
689258
       newobj->static_link
689258
 	= XOBNEW (&objfile->objfile_obstack, struct dynamic_prop);
689258
-      attr_to_dynamic_prop (attr, die, cu, newobj->static_link);
689258
+      attr_to_dynamic_prop (attr, die, cu, newobj->static_link, NULL, 0);
689258
     }
689258
 
689258
   cu->list_in_scope = &local_symbols;
689258
@@ -16329,7 +16330,8 @@ read_array_type (struct die_info *die, struct dwarf2_cu *cu)
689258
 
689258
       byte_stride_prop
689258
 	= (struct dynamic_prop *) alloca (sizeof (struct dynamic_prop));
689258
-      stride_ok = attr_to_dynamic_prop (attr, die, cu, byte_stride_prop);
689258
+      stride_ok = attr_to_dynamic_prop (attr, die, cu, byte_stride_prop,
689258
+					NULL, 0);
689258
       if (!stride_ok)
689258
 	{
689258
 	  complaint (_("unable to read array DW_AT_byte_stride "
689258
@@ -17090,29 +17092,90 @@ read_tag_string_type (struct die_info *die, struct dwarf2_cu *cu)
689258
   struct gdbarch *gdbarch = get_objfile_arch (objfile);
689258
   struct type *type, *range_type, *index_type, *char_type;
689258
   struct attribute *attr;
689258
-  unsigned int length;
689258
+  unsigned int length = UINT_MAX;
689258
+
689258
+  index_type = objfile_type (objfile)->builtin_int;
689258
+  range_type = create_static_range_type (NULL, index_type, 1, length);
689258
 
689258
+  /* If DW_AT_string_length is defined, the length is stored in memory.  */
689258
   attr = dwarf2_attr (die, DW_AT_string_length, cu);
689258
   if (attr)
689258
     {
689258
-      length = DW_UNSND (attr);
689258
+      if (attr_form_is_block (attr))
689258
+	{
689258
+	  struct attribute *byte_size, *bit_size;
689258
+	  struct dynamic_prop high;
689258
+
689258
+	  byte_size = dwarf2_attr (die, DW_AT_byte_size, cu);
689258
+	  bit_size = dwarf2_attr (die, DW_AT_bit_size, cu);
689258
+
689258
+	  /* DW_AT_byte_size should never occur in combination with
689258
+	     DW_AT_bit_size.  */
689258
+	  if (byte_size != NULL && bit_size != NULL)
689258
+	    complaint (_("DW_AT_byte_size AND "
689258
+			 "DW_AT_bit_size found together at the same time."));
689258
+
689258
+	  /* If DW_AT_string_length AND DW_AT_byte_size exist together,
689258
+	     DW_AT_byte_size describes the number of bytes that should be read
689258
+	     from the length memory location.  */
689258
+	  if (byte_size != NULL)
689258
+	    {
689258
+	      /* Build new dwarf2_locexpr_baton structure with additions to the
689258
+		 data attribute, to reflect DWARF specialities to get address
689258
+		 sizes.  */
689258
+	      const gdb_byte append_ops[] =
689258
+		{
689258
+		/* DW_OP_deref_size: size of an address on the target machine
689258
+		   (bytes), where the size will be specified by the next
689258
+		   operand.  */
689258
+		DW_OP_deref_size,
689258
+		/* Operand for DW_OP_deref_size.  */
689258
+		DW_UNSND(byte_size) };
689258
+
689258
+	      if (!attr_to_dynamic_prop (attr, die, cu, &high, append_ops,
689258
+					 ARRAY_SIZE(append_ops)))
689258
+		complaint (_("Could not parse DW_AT_byte_size"));
689258
+	    }
689258
+	  else if (bit_size != NULL)
689258
+	    complaint (_("DW_AT_string_length AND "
689258
+			 "DW_AT_bit_size found but not supported yet."));
689258
+	  /* If DW_AT_string_length WITHOUT DW_AT_byte_size exist, the default
689258
+	     is the address size of the target machine.  */
689258
+	  else
689258
+	    {
689258
+	      const gdb_byte append_ops[] =
689258
+		{ DW_OP_deref };
689258
+
689258
+	      if (!attr_to_dynamic_prop (attr, die, cu, &high, append_ops,
689258
+					 ARRAY_SIZE(append_ops)))
689258
+		complaint (_("Could not parse DW_AT_string_length"));
689258
+	    }
689258
+
689258
+	  TYPE_RANGE_DATA (range_type)->high = high;
689258
+	}
689258
+      else
689258
+	{
689258
+	  TYPE_HIGH_BOUND (range_type) = DW_UNSND(attr);
689258
+	  TYPE_HIGH_BOUND_KIND (range_type) = PROP_CONST;
689258
+	}
689258
     }
689258
   else
689258
     {
689258
-      /* Check for the DW_AT_byte_size attribute.  */
689258
+      /* Check for the DW_AT_byte_size attribute, which represents the length
689258
+	 in this case.  */
689258
       attr = dwarf2_attr (die, DW_AT_byte_size, cu);
689258
       if (attr)
689258
-        {
689258
-          length = DW_UNSND (attr);
689258
-        }
689258
+	{
689258
+	  TYPE_HIGH_BOUND (range_type) = DW_UNSND(attr);
689258
+	  TYPE_HIGH_BOUND_KIND (range_type) = PROP_CONST;
689258
+	}
689258
       else
689258
-        {
689258
-          length = 1;
689258
-        }
689258
+	{
689258
+	  TYPE_HIGH_BOUND (range_type) = 1;
689258
+	  TYPE_HIGH_BOUND_KIND (range_type) = PROP_CONST;
689258
+	}
689258
     }
689258
 
689258
-  index_type = objfile_type (objfile)->builtin_int;
689258
-  range_type = create_static_range_type (NULL, index_type, 1, length);
689258
   char_type = language_string_char_type (cu->language_defn, gdbarch);
689258
   type = create_string_type (NULL, char_type, range_type);
689258
 
689258
@@ -17460,7 +17523,8 @@ read_base_type (struct die_info *die, struct dwarf2_cu *cu)
689258
 
689258
 static int
689258
 attr_to_dynamic_prop (const struct attribute *attr, struct die_info *die,
689258
-		      struct dwarf2_cu *cu, struct dynamic_prop *prop)
689258
+		      struct dwarf2_cu *cu, struct dynamic_prop *prop,
689258
+		      const gdb_byte *additional_data, int additional_data_size)
689258
 {
689258
   struct dwarf2_property_baton *baton;
689258
   struct obstack *obstack
689258
@@ -17471,14 +17535,33 @@ attr_to_dynamic_prop (const struct attribute *attr, struct die_info *die,
689258
 
689258
   if (attr_form_is_block (attr))
689258
     {
689258
-      baton = XOBNEW (obstack, struct dwarf2_property_baton);
689258
+      baton = XOBNEW(obstack, struct dwarf2_property_baton);
689258
       baton->referenced_type = NULL;
689258
       baton->locexpr.per_cu = cu->per_cu;
689258
-      baton->locexpr.size = DW_BLOCK (attr)->size;
689258
-      baton->locexpr.data = DW_BLOCK (attr)->data;
689258
+
689258
+      if (additional_data != NULL && additional_data_size > 0)
689258
+	{
689258
+	  gdb_byte *data;
689258
+
689258
+	  data = (gdb_byte *) obstack_alloc(
689258
+	      &cu->per_cu->dwarf2_per_objfile->objfile->objfile_obstack,
689258
+	      DW_BLOCK (attr)->size + additional_data_size);
689258
+	  memcpy (data, DW_BLOCK (attr)->data, DW_BLOCK (attr)->size);
689258
+	  memcpy (data + DW_BLOCK (attr)->size, additional_data,
689258
+		  additional_data_size);
689258
+
689258
+	  baton->locexpr.data = data;
689258
+	  baton->locexpr.size = DW_BLOCK (attr)->size + additional_data_size;
689258
+	}
689258
+      else
689258
+	{
689258
+	  baton->locexpr.data = DW_BLOCK (attr)->data;
689258
+	  baton->locexpr.size = DW_BLOCK (attr)->size;
689258
+	}
689258
+
689258
       prop->data.baton = baton;
689258
       prop->kind = PROP_LOCEXPR;
689258
-      gdb_assert (prop->data.baton != NULL);
689258
+      gdb_assert(prop->data.baton != NULL);
689258
     }
689258
   else if (attr_form_is_ref (attr))
689258
     {
689258
@@ -17511,8 +17594,28 @@ attr_to_dynamic_prop (const struct attribute *attr, struct die_info *die,
689258
 		baton = XOBNEW (obstack, struct dwarf2_property_baton);
689258
 		baton->referenced_type = die_type (target_die, target_cu);
689258
 		baton->locexpr.per_cu = cu->per_cu;
689258
-		baton->locexpr.size = DW_BLOCK (target_attr)->size;
689258
-		baton->locexpr.data = DW_BLOCK (target_attr)->data;
689258
+
689258
+		if (additional_data != NULL && additional_data_size > 0)
689258
+		  {
689258
+		    gdb_byte *data;
689258
+
689258
+		    data = (gdb_byte *) obstack_alloc (&cu->per_cu->dwarf2_per_objfile->objfile->objfile_obstack,
689258
+			    DW_BLOCK (target_attr)->size + additional_data_size);
689258
+		    memcpy (data, DW_BLOCK (target_attr)->data,
689258
+			    DW_BLOCK (target_attr)->size);
689258
+		    memcpy (data + DW_BLOCK (target_attr)->size,
689258
+			    additional_data, additional_data_size);
689258
+
689258
+		    baton->locexpr.data = data;
689258
+		    baton->locexpr.size = (DW_BLOCK (target_attr)->size
689258
+					   + additional_data_size);
689258
+		  }
689258
+		else
689258
+		  {
689258
+		    baton->locexpr.data = DW_BLOCK (target_attr)->data;
689258
+		    baton->locexpr.size = DW_BLOCK (target_attr)->size;
689258
+		  }
689258
+
689258
 		prop->data.baton = baton;
689258
 		prop->kind = PROP_LOCEXPR;
689258
 		gdb_assert (prop->data.baton != NULL);
689258
@@ -17623,7 +17726,7 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu)
689258
 
689258
   attr = dwarf2_attr (die, DW_AT_byte_stride, cu);
689258
   if (attr)
689258
-    if (!attr_to_dynamic_prop (attr, die, cu, &stride))
689258
+    if (!attr_to_dynamic_prop (attr, die, cu, &stride, NULL, 0))
689258
         complaint (_("Missing DW_AT_byte_stride "
689258
 		     "- DIE at 0x%s [in module %s]"),
689258
 		   sect_offset_str (die->sect_off),
689258
@@ -17631,7 +17734,7 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu)
689258
 
689258
   attr = dwarf2_attr (die, DW_AT_lower_bound, cu);
689258
   if (attr)
689258
-    attr_to_dynamic_prop (attr, die, cu, &low);
689258
+    attr_to_dynamic_prop (attr, die, cu, &low, NULL, 0);
689258
   else if (!low_default_is_valid)
689258
     complaint (_("Missing DW_AT_lower_bound "
689258
 				      "- DIE at %s [in module %s]"),
689258
@@ -17639,10 +17742,10 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu)
689258
 	       objfile_name (cu->per_cu->dwarf2_per_objfile->objfile));
689258
 
689258
   attr = dwarf2_attr (die, DW_AT_upper_bound, cu);
689258
-  if (!attr_to_dynamic_prop (attr, die, cu, &high))
689258
+  if (!attr_to_dynamic_prop (attr, die, cu, &high, NULL, 0))
689258
     {
689258
       attr = dwarf2_attr (die, DW_AT_count, cu);
689258
-      if (attr_to_dynamic_prop (attr, die, cu, &high))
689258
+      if (attr_to_dynamic_prop (attr, die, cu, &high, NULL, 0))
689258
 	{
689258
 	  /* If bounds are constant do the final calculation here.  */
689258
 	  if (low.kind == PROP_CONST && high.kind == PROP_CONST)
689258
@@ -25143,7 +25246,7 @@ set_die_type (struct die_info *die, struct type *type, struct dwarf2_cu *cu)
689258
   attr = dwarf2_attr (die, DW_AT_allocated, cu);
689258
   if (attr_form_is_block (attr))
689258
     {
689258
-      if (attr_to_dynamic_prop (attr, die, cu, &prop))
689258
+      if (attr_to_dynamic_prop (attr, die, cu, &prop, NULL, 0))
689258
         add_dyn_prop (DYN_PROP_ALLOCATED, prop, type);
689258
     }
689258
   else if (attr != NULL)
689258
@@ -25157,7 +25260,7 @@ set_die_type (struct die_info *die, struct type *type, struct dwarf2_cu *cu)
689258
   attr = dwarf2_attr (die, DW_AT_associated, cu);
689258
   if (attr_form_is_block (attr))
689258
     {
689258
-      if (attr_to_dynamic_prop (attr, die, cu, &prop))
689258
+      if (attr_to_dynamic_prop (attr, die, cu, &prop, NULL, 0))
689258
         add_dyn_prop (DYN_PROP_ASSOCIATED, prop, type);
689258
     }
689258
   else if (attr != NULL)
689258
@@ -25169,7 +25272,7 @@ set_die_type (struct die_info *die, struct type *type, struct dwarf2_cu *cu)
689258
 
689258
   /* Read DW_AT_data_location and set in type.  */
689258
   attr = dwarf2_attr (die, DW_AT_data_location, cu);
689258
-  if (attr_to_dynamic_prop (attr, die, cu, &prop))
689258
+  if (attr_to_dynamic_prop (attr, die, cu, &prop, NULL, 0))
689258
     add_dyn_prop (DYN_PROP_DATA_LOCATION, prop, type);
689258
 
689258
   if (dwarf2_per_objfile->die_type_hash == NULL)
689258
diff --git a/gdb/f-typeprint.c b/gdb/f-typeprint.c
689258
--- a/gdb/f-typeprint.c
689258
+++ b/gdb/f-typeprint.c
689258
@@ -37,7 +37,7 @@ static void f_type_print_args (struct type *, struct ui_file *);
689258
 #endif
689258
 
689258
 static void f_type_print_varspec_suffix (struct type *, struct ui_file *, int,
689258
-					 int, int, int);
689258
+					 int, int, int, int);
689258
 
689258
 void f_type_print_varspec_prefix (struct type *, struct ui_file *,
689258
 				  int, int);
689258
@@ -53,18 +53,6 @@ f_print_type (struct type *type, const char *varstring, struct ui_file *stream,
689258
 {
689258
   enum type_code code;
689258
 
689258
-  if (type_not_associated (type))
689258
-    {
689258
-      val_print_not_associated (stream);
689258
-      return;
689258
-    }
689258
-
689258
-  if (type_not_allocated (type))
689258
-    {
689258
-      val_print_not_allocated (stream);
689258
-      return;
689258
-    }
689258
-
689258
   f_type_print_base (type, stream, show, level);
689258
   code = TYPE_CODE (type);
689258
   if ((varstring != NULL && *varstring != '\0')
689258
@@ -89,7 +77,7 @@ f_print_type (struct type *type, const char *varstring, struct ui_file *stream,
689258
 
689258
       demangled_args = (*varstring != '\0'
689258
 			&& varstring[strlen (varstring) - 1] == ')');
689258
-      f_type_print_varspec_suffix (type, stream, show, 0, demangled_args, 0);
689258
+      f_type_print_varspec_suffix (type, stream, show, 0, demangled_args, 0, 0);
689258
    }
689258
 }
689258
 
689258
@@ -159,7 +147,7 @@ f_type_print_varspec_prefix (struct type *type, struct ui_file *stream,
689258
 static void
689258
 f_type_print_varspec_suffix (struct type *type, struct ui_file *stream,
689258
 			     int show, int passed_a_ptr, int demangled_args,
689258
-			     int arrayprint_recurse_level)
689258
+			     int arrayprint_recurse_level, int print_rank_only)
689258
 {
689258
   int upper_bound, lower_bound;
689258
 
689258
@@ -183,34 +171,50 @@ f_type_print_varspec_suffix (struct type *type, struct ui_file *stream,
689258
 	fprintf_filtered (stream, "(");
689258
 
689258
       if (type_not_associated (type))
689258
-        val_print_not_associated (stream);
689258
+	print_rank_only = 1;
689258
       else if (type_not_allocated (type))
689258
-        val_print_not_allocated (stream);
689258
+	print_rank_only = 1;
689258
+      else if ((TYPE_ASSOCIATED_PROP (type)
689258
+		&& PROP_CONST != TYPE_DYN_PROP_KIND (TYPE_ASSOCIATED_PROP (type)))
689258
+	      || (TYPE_ALLOCATED_PROP (type)
689258
+		&& PROP_CONST != TYPE_DYN_PROP_KIND (TYPE_ALLOCATED_PROP (type)))
689258
+	      || (TYPE_DATA_LOCATION (type)
689258
+		  && PROP_CONST != TYPE_DYN_PROP_KIND (TYPE_DATA_LOCATION (type))))
689258
+	/* This case exist when we ptype a typename which has the
689258
+	   dynamic properties but cannot be resolved as there is
689258
+	   no object.  */
689258
+	print_rank_only = 1;
689258
+
689258
+      if (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_ARRAY)
689258
+	f_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0,
689258
+				     0, 0, arrayprint_recurse_level,
689258
+				     print_rank_only);
689258
+
689258
+      if (print_rank_only == 1)
689258
+	fprintf_filtered (stream, ":");
689258
       else
689258
-        {
689258
-          if (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_ARRAY)
689258
-            f_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0,
689258
-                                        0, 0, arrayprint_recurse_level);
689258
-
689258
-          lower_bound = f77_get_lowerbound (type);
689258
-          if (lower_bound != 1)	/* Not the default.  */
689258
-            fprintf_filtered (stream, "%d:", lower_bound);
689258
-
689258
-          /* Make sure that, if we have an assumed size array, we
689258
-             print out a warning and print the upperbound as '*'.  */
689258
-
689258
-          if (TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED (type))
689258
-            fprintf_filtered (stream, "*");
689258
-          else
689258
-            {
689258
-              upper_bound = f77_get_upperbound (type);
689258
-              fprintf_filtered (stream, "%d", upper_bound);
689258
-            }
689258
-
689258
-          if (TYPE_CODE (TYPE_TARGET_TYPE (type)) != TYPE_CODE_ARRAY)
689258
-            f_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0,
689258
-                                        0, 0, arrayprint_recurse_level);
689258
-        }
689258
+	{
689258
+	  lower_bound = f77_get_lowerbound (type);
689258
+	  if (lower_bound != 1)	/* Not the default.  */
689258
+	    fprintf_filtered (stream, "%d:", lower_bound);
689258
+
689258
+	  /* Make sure that, if we have an assumed size array, we
689258
+	       print out a warning and print the upperbound as '*'.  */
689258
+
689258
+	  if (TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED (type))
689258
+	    fprintf_filtered (stream, "*");
689258
+	  else
689258
+	    {
689258
+	      upper_bound = f77_get_upperbound (type);
689258
+	      fprintf_filtered (stream, "%d", upper_bound);
689258
+	    }
689258
+	}
689258
+
689258
+      if (TYPE_CODE (TYPE_TARGET_TYPE (type)) != TYPE_CODE_ARRAY)
689258
+	f_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0,
689258
+				     0, 0, arrayprint_recurse_level,
689258
+				     print_rank_only);
689258
+
689258
       if (arrayprint_recurse_level == 1)
689258
 	fprintf_filtered (stream, ")");
689258
       else
689258
@@ -221,13 +225,14 @@ f_type_print_varspec_suffix (struct type *type, struct ui_file *stream,
689258
     case TYPE_CODE_PTR:
689258
     case TYPE_CODE_REF:
689258
       f_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, 1, 0,
689258
-				   arrayprint_recurse_level);
689258
+				   arrayprint_recurse_level, 0);
689258
       fprintf_filtered (stream, ")");
689258
       break;
689258
 
689258
     case TYPE_CODE_FUNC:
689258
       f_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0,
689258
-				   passed_a_ptr, 0, arrayprint_recurse_level);
689258
+				   passed_a_ptr, 0, arrayprint_recurse_level,
689258
+				   0);
689258
       if (passed_a_ptr)
689258
 	fprintf_filtered (stream, ")");
689258
 
689258
@@ -388,7 +393,7 @@ f_type_print_base (struct type *type, struct ui_file *stream, int show,
689258
 	      fputs_filtered (" :: ", stream);
689258
 	      fputs_filtered (TYPE_FIELD_NAME (type, index), stream);
689258
 	      f_type_print_varspec_suffix (TYPE_FIELD_TYPE (type, index),
689258
-					   stream, show - 1, 0, 0, 0);
689258
+					   stream, show - 1, 0, 0, 0, 0);
689258
 	      fputs_filtered ("\n", stream);
689258
 	    }
689258
 	  fprintfi_filtered (level, stream, "End Type ");
689258
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
689258
--- a/gdb/gdbtypes.c
689258
+++ b/gdb/gdbtypes.c
689258
@@ -1904,7 +1904,8 @@ is_dynamic_type_internal (struct type *type, int top_level)
689258
   type = check_typedef (type);
689258
 
689258
   /* We only want to recognize references at the outermost level.  */
689258
-  if (top_level && TYPE_CODE (type) == TYPE_CODE_REF)
689258
+  if (top_level &&
689258
+      (TYPE_CODE (type) == TYPE_CODE_REF || TYPE_CODE (type) == TYPE_CODE_PTR))
689258
     type = check_typedef (TYPE_TARGET_TYPE (type));
689258
 
689258
   /* Types that have a dynamic TYPE_DATA_LOCATION are considered
689258
@@ -1938,6 +1939,7 @@ is_dynamic_type_internal (struct type *type, int top_level)
689258
       }
689258
 
689258
     case TYPE_CODE_ARRAY:
689258
+    case TYPE_CODE_STRING:
689258
       {
689258
 	gdb_assert (TYPE_NFIELDS (type) == 1);
689258
 
689258
@@ -2056,7 +2058,8 @@ resolve_dynamic_array (struct type *type,
689258
   struct dynamic_prop *prop;
689258
   unsigned int bit_stride = 0;
689258
 
689258
-  gdb_assert (TYPE_CODE (type) == TYPE_CODE_ARRAY);
689258
+  gdb_assert (TYPE_CODE (type) == TYPE_CODE_ARRAY
689258
+	      || TYPE_CODE (type) == TYPE_CODE_STRING);
689258
 
689258
   type = copy_type (type);
689258
 
689258
@@ -2081,11 +2084,15 @@ resolve_dynamic_array (struct type *type,
689258
 
689258
   ary_dim = check_typedef (TYPE_TARGET_TYPE (elt_type));
689258
 
689258
-  if (ary_dim != NULL && TYPE_CODE (ary_dim) == TYPE_CODE_ARRAY)
689258
+  if (ary_dim != NULL && (TYPE_CODE (ary_dim) == TYPE_CODE_ARRAY
689258
+      || TYPE_CODE (ary_dim) == TYPE_CODE_STRING))
689258
     elt_type = resolve_dynamic_array (ary_dim, addr_stack);
689258
   else
689258
     elt_type = TYPE_TARGET_TYPE (type);
689258
 
689258
+  if (TYPE_CODE (type) == TYPE_CODE_STRING)
689258
+    return create_string_type (type, elt_type, range_type);
689258
+
689258
   prop = get_dyn_prop (DYN_PROP_BYTE_STRIDE, type);
689258
   if (prop != NULL)
689258
     {
689258
@@ -2240,6 +2247,28 @@ resolve_dynamic_struct (struct type *type,
689258
   return resolved_type;
689258
 }
689258
 
689258
+/* Worker for pointer types.  */
689258
+
689258
+static struct type *
689258
+resolve_dynamic_pointer (struct type *type,
689258
+			 struct property_addr_info *addr_stack)
689258
+{
689258
+  struct dynamic_prop *prop;
689258
+  CORE_ADDR value;
689258
+
689258
+  type = copy_type (type);
689258
+
689258
+  /* Resolve associated property.  */
689258
+  prop = TYPE_ASSOCIATED_PROP (type);
689258
+  if (prop != NULL && dwarf2_evaluate_property (prop, NULL, addr_stack, &value))
689258
+    {
689258
+      TYPE_DYN_PROP_ADDR (prop) = value;
689258
+      TYPE_DYN_PROP_KIND (prop) = PROP_CONST;
689258
+    }
689258
+
689258
+  return type;
689258
+}
689258
+
689258
 /* Worker for resolved_dynamic_type.  */
689258
 
689258
 static struct type *
689258
@@ -2288,7 +2317,12 @@ resolve_dynamic_type_internal (struct type *type,
689258
 	    break;
689258
 	  }
689258
 
689258
+        case TYPE_CODE_PTR:
689258
+ 	  resolved_type = resolve_dynamic_pointer (type, addr_stack);
689258
+ 	  break;
689258
+
689258
 	case TYPE_CODE_ARRAY:
689258
+	case TYPE_CODE_STRING:
689258
 	  resolved_type = resolve_dynamic_array (type, addr_stack);
689258
 	  break;
689258
 
689258
diff --git a/gdb/testsuite/gdb.cp/vla-cxx.cc b/gdb/testsuite/gdb.cp/vla-cxx.cc
689258
--- a/gdb/testsuite/gdb.cp/vla-cxx.cc
689258
+++ b/gdb/testsuite/gdb.cp/vla-cxx.cc
689258
@@ -15,6 +15,10 @@
689258
    You should have received a copy of the GNU General Public License
689258
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
689258
 
689258
+extern "C" {
689258
+#include <stddef.h>
689258
+}
689258
+
689258
 struct container;
689258
 
689258
 struct element
689258
@@ -40,11 +44,16 @@ int main(int argc, char **argv)
689258
   typedef typeof (vla) &vlareftypedef;
689258
   vlareftypedef vlaref2 (vla);
689258
   container c;
689258
+  typeof (vla) *ptr = NULL;
689258
+
689258
+  // Before pointer assignment
689258
+  ptr = &vla;
689258
 
689258
   for (int i = 0; i < z; ++i)
689258
     vla[i] = 5 + 2 * i;
689258
 
689258
   // vlas_filled
689258
   vla[0] = 2 * vla[0];
689258
+
689258
   return vla[2];
689258
 }
689258
diff --git a/gdb/testsuite/gdb.cp/vla-cxx.exp b/gdb/testsuite/gdb.cp/vla-cxx.exp
689258
--- a/gdb/testsuite/gdb.cp/vla-cxx.exp
689258
+++ b/gdb/testsuite/gdb.cp/vla-cxx.exp
689258
@@ -23,6 +23,12 @@ if ![runto_main] {
689258
     return -1
689258
 }
689258
 
689258
+gdb_breakpoint [gdb_get_line_number "Before pointer assignment"]
689258
+gdb_continue_to_breakpoint "Before pointer assignment"
689258
+gdb_test "ptype ptr" "int \\(\\*\\)\\\[variable length\\\]" "ptype ptr, Before pointer assignment"
689258
+gdb_test "print ptr" "\\(int \\(\\*\\)\\\[variable length\\\]\\) 0x0" "print ptr, Before pointer assignment"
689258
+gdb_test "print *ptr" "Cannot access memory at address 0x0" "print *ptr, Before pointer assignment"
689258
+
689258
 gdb_breakpoint [gdb_get_line_number "vlas_filled"]
689258
 gdb_continue_to_breakpoint "vlas_filled"
689258
 
689258
@@ -33,3 +39,6 @@ gdb_test "print vlaref" " = \\(int \\(&\\)\\\[3\\\]\\) @$hex: \\{5, 7, 9\\}"
689258
 # bug being tested, it's better not to depend on the exact spelling.
689258
 gdb_test "print vlaref2" " = \\(.*\\) @$hex: \\{5, 7, 9\\}"
689258
 gdb_test "print c" " = \\{e = \\{c = @$hex\\}\\}"
689258
+gdb_test "ptype ptr" "int \\(\\*\\)\\\[3\\\]"
689258
+gdb_test "print ptr" "\\(int \\(\\*\\)\\\[3\\\]\\) $hex"
689258
+gdb_test "print *ptr" " = \\{5, 7, 9\\}"
689258
diff --git a/gdb/testsuite/gdb.fortran/pointers.exp b/gdb/testsuite/gdb.fortran/pointers.exp
689258
new file mode 100644
689258
--- /dev/null
689258
+++ b/gdb/testsuite/gdb.fortran/pointers.exp
689258
@@ -0,0 +1,143 @@
689258
+# Copyright 2016 Free Software Foundation, Inc.
689258
+
689258
+# This program is free software; you can redistribute it and/or modify
689258
+# it under the terms of the GNU General Public License as published by
689258
+# the Free Software Foundation; either version 3 of the License, or
689258
+# (at your option) any later version.
689258
+#
689258
+# This program is distributed in the hope that it will be useful,
689258
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
689258
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
689258
+# GNU General Public License for more details.
689258
+#
689258
+# You should have received a copy of the GNU General Public License
689258
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
689258
+
689258
+standard_testfile "pointers.f90"
689258
+load_lib fortran.exp
689258
+
689258
+if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
689258
+    {debug f90 quiet}] } {
689258
+    return -1
689258
+}
689258
+
689258
+if ![runto_main] {
689258
+    untested "could not run to main"
689258
+    return -1
689258
+}
689258
+
689258
+# Depending on the compiler being used, the type names can be printed differently.
689258
+set logical [fortran_logical4]
689258
+set real [fortran_real4]
689258
+set int [fortran_int4]
689258
+set complex [fortran_complex4]
689258
+
689258
+
689258
+gdb_breakpoint [gdb_get_line_number "Before pointer assignment"]
689258
+gdb_continue_to_breakpoint "Before pointer assignment"
689258
+gdb_test "print logp" "= \\(PTR TO -> \\( $logical \\)\\) 0x0" "print logp, not associated"
689258
+gdb_test "print *logp" "Cannot access memory at address 0x0" "print *logp, not associated"
689258
+gdb_test "print comp" "= \\(PTR TO -> \\( $complex \\)\\) 0x0" "print comp, not associated"
689258
+gdb_test "print *comp" "Cannot access memory at address 0x0" "print *comp, not associated"
689258
+gdb_test "print charp" "= \\(PTR TO -> \\( character\\*1 \\)\\) 0x0" "print charp, not associated"
689258
+gdb_test "print *charp" "Cannot access memory at address 0x0" "print *charp, not associated"
689258
+gdb_test "print charap" "= \\(PTR TO -> \\( character\\*3 \\)\\) 0x0" "print charap, not associated"
689258
+gdb_test "print *charap" "Cannot access memory at address 0x0" "print *charap, not associated"
689258
+gdb_test "print intp" "= \\(PTR TO -> \\( $int \\)\\) 0x0" "print intp, not associated"
689258
+gdb_test "print *intp" "Cannot access memory at address 0x0" "print *intp, not associated"
689258
+set test "print intap, not associated"
689258
+gdb_test_multiple "print intap" $test {
689258
+  -re " = \\(PTR TO -> \\( $int \\(:,:\\)\\)\\) <not associated>\r\n$gdb_prompt $" {
689258
+    pass $test
689258
+  }
689258
+  -re " = <not associated>\r\n$gdb_prompt $" {
689258
+    pass $test
689258
+  }
689258
+}
689258
+gdb_test "print realp" "= \\(PTR TO -> \\( $real \\)\\) 0x0" "print realp, not associated"
689258
+gdb_test "print *realp" "Cannot access memory at address 0x0" "print *realp, not associated"
689258
+gdb_test "print \$my_var = intp" "= \\(PTR TO -> \\( $int \\)\\) 0x0"
689258
+set test "print cyclicp1, not associated"
689258
+gdb_test_multiple "print cyclicp1" $test {
689258
+  -re "= \\( i = -?\\d+, p = 0x0 \\)\r\n$gdb_prompt $" {
689258
+    pass $test
689258
+  }
689258
+  -re "= \\( i = -?\\d+, p = <not associated> \\)\r\n$gdb_prompt $" {
689258
+    pass $test
689258
+  }
689258
+}
689258
+set test "print cyclicp1%p, not associated"
689258
+gdb_test_multiple "print cyclicp1%p" $test {
689258
+  -re "= \\(PTR TO -> \\( Type typewithpointer \\)\\) 0x0\r\n$gdb_prompt $" {
689258
+    pass $test
689258
+  }
689258
+  -re "= \\(PTR TO -> \\( Type typewithpointer \\)\\) <not associated>\r\n$gdb_prompt $" {
689258
+    pass $test
689258
+  }
689258
+}
689258
+
689258
+
689258
+gdb_breakpoint [gdb_get_line_number "Before value assignment"]
689258
+gdb_continue_to_breakpoint "Before value assignment"
689258
+gdb_test "print *(twop)%ivla2" "= <not allocated>"
689258
+
689258
+
689258
+gdb_breakpoint [gdb_get_line_number "After value assignment"]
689258
+gdb_continue_to_breakpoint "After value assignment"
689258
+gdb_test "print logp" "= \\(PTR TO -> \\( $logical \\)\\) $hex\( <.*>\)?"
689258
+gdb_test "print *logp" "= \\.TRUE\\."
689258
+gdb_test "print comp" "= \\(PTR TO -> \\( $complex \\)\\) $hex\( <.*>\)?"
689258
+gdb_test "print *comp" "= \\(1,2\\)"
689258
+gdb_test "print charp" "= \\(PTR TO -> \\( character\\*1 \\)\\) $hex\( <.*>\)?"
689258
+gdb_test "print *charp" "= 'a'"
689258
+gdb_test "print charap" "= \\(PTR TO -> \\( character\\*3 \\)\\) $hex\( <.*>\)?"
689258
+gdb_test "print *charap" "= 'abc'"
689258
+gdb_test "print intp" "= \\(PTR TO -> \\( $int \\)\\) $hex\( <.*>\)?"
689258
+gdb_test "print *intp" "= 10"
689258
+set test_name "print intap, associated"
689258
+gdb_test_multiple "print intap" $test_name {
689258
+  -re "= \\(\\( 1, 1, 3(, 1){7}\\) \\( 1(, 1){9}\\) \\)\r\n$gdb_prompt $" {
689258
+    pass $test_name
689258
+  }
689258
+  -re "= \\(PTR TO -> \\( $int \\(10,2\\)\\)\\) $hex\( <.*>\)?\r\n$gdb_prompt $" {
689258
+    gdb_test "print *intap" "= \\(\\( 1, 1, 3(, 1){7}\\) \\( 1(, 1){9}\\) \\)"
689258
+    pass $test_name
689258
+  }
689258
+}
689258
+set test_name "print intvlap, associated"
689258
+gdb_test_multiple "print intvlap" $test_name {
689258
+  -re "= \\(2, 2, 2, 4(, 2){6}\\)\r\n$gdb_prompt $" {
689258
+    pass $test_name
689258
+  }
689258
+  -re "= \\(PTR TO -> \\( $int \\(10\\)\\)\\) $hex\( <.*>\)?\r\n$gdb_prompt $" {
689258
+    gdb_test "print *intvlap" "= \\(2, 2, 2, 4(, 2){6}\\)"
689258
+    pass $test_name
689258
+  }
689258
+}
689258
+gdb_test "print realp" "= \\(PTR TO -> \\( $real \\)\\) $hex\( <.*>\)?"
689258
+gdb_test "print *realp" "= 3\\.14000\\d+"
689258
+gdb_test "print arrayOfPtr(2)%p" "= \\(PTR TO -> \\( Type two \\)\\) $hex\( <.*>\)?"
689258
+gdb_test "print *(arrayOfPtr(2)%p)" "= \\( ivla1 = \\(11, 12, 13\\), ivla2 = \\(\\( 211, 221\\) \\( 212, 222\\) \\) \\)"
689258
+set test_name "print arrayOfPtr(3)%p"
689258
+gdb_test_multiple $test_name $test_name {
689258
+  -re "= \\(PTR TO -> \\( Type two \\)\\) <not associated>\r\n$gdb_prompt $" {
689258
+    pass $test_name
689258
+  }
689258
+  -re "= \\(PTR TO -> \\( Type two \\)\\) 0x0\r\n$gdb_prompt $" {
689258
+    pass $test_name
689258
+  }
689258
+}
689258
+set test_name "print *(arrayOfPtr(3)%p), associated"
689258
+gdb_test_multiple "print *(arrayOfPtr(3)%p)" $test_name {
689258
+  -re "Cannot access memory at address 0x0\r\n$gdb_prompt $" {
689258
+    pass $test_name
689258
+  }
689258
+  -re "Attempt to take contents of a not associated pointer.\r\n$gdb_prompt $" {
689258
+    pass $test_name
689258
+  }
689258
+}
689258
+gdb_test "print cyclicp1" "= \\( i = 1, p = $hex\( <.*>\)? \\)"
689258
+gdb_test "print cyclicp1%p" "= \\(PTR TO -> \\( Type typewithpointer \\)\\) $hex\( <.*>\)?"
689258
+gdb_test "print *((integer*) &inta + 2)" "= 3" "print temporary pointer, array"
689258
+gdb_test "print *((integer*) &intvla + 3)" "= 4" "print temporary pointer, allocated vla"
689258
+gdb_test "print \$pc" "= \\(PTR TO -> \\( void \\(\\)\\(\\)\\)\\) $hex <pointers\\+\\d+>" "Print program counter"
689258
diff --git a/gdb/testsuite/gdb.fortran/pointers.f90 b/gdb/testsuite/gdb.fortran/pointers.f90
689258
new file mode 100644
689258
--- /dev/null
689258
+++ b/gdb/testsuite/gdb.fortran/pointers.f90
689258
@@ -0,0 +1,109 @@
689258
+! Copyright 2016 Free Software Foundation, Inc.
689258
+!
689258
+! This program is free software; you can redistribute it and/or modify
689258
+! it under the terms of the GNU General Public License as published by
689258
+! the Free Software Foundation; either version 3 of the License, or
689258
+! (at your option) any later version.
689258
+!
689258
+! This program is distributed in the hope that it will be useful,
689258
+! but WITHOUT ANY WARRANTY; without even the implied warranty of
689258
+! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
689258
+! GNU General Public License for more details.
689258
+!
689258
+! You should have received a copy of the GNU General Public License
689258
+! along with this program.  If not, see <http://www.gnu.org/licenses/>.
689258
+
689258
+program pointers
689258
+
689258
+  type :: two
689258
+    integer, allocatable :: ivla1 (:)
689258
+    integer, allocatable :: ivla2 (:, :)
689258
+  end type two
689258
+
689258
+  type :: typeWithPointer
689258
+    integer i
689258
+    type(typeWithPointer), pointer:: p
689258
+  end type typeWithPointer
689258
+
689258
+  type :: twoPtr
689258
+    type (two), pointer :: p
689258
+  end type twoPtr
689258
+
689258
+  logical, target :: logv
689258
+  complex, target :: comv
689258
+  character, target :: charv
689258
+  character (len=3), target :: chara
689258
+  integer, target :: intv
689258
+  integer, target, dimension (10,2) :: inta
689258
+  integer, target, allocatable, dimension (:) :: intvla
689258
+  real, target    :: realv
689258
+  type(two), target  :: twov
689258
+  type(twoPtr) :: arrayOfPtr (3)
689258
+  type(typeWithPointer), target:: cyclicp1,cyclicp2
689258
+
689258
+  logical, pointer :: logp
689258
+  complex, pointer :: comp
689258
+  character, pointer:: charp
689258
+  character (len=3), pointer:: charap
689258
+  integer, pointer :: intp
689258
+  integer, pointer, dimension (:,:) :: intap
689258
+  integer, pointer, dimension (:) :: intvlap
689258
+  real, pointer :: realp
689258
+  type(two), pointer :: twop
689258
+
689258
+  nullify (logp)
689258
+  nullify (comp)
689258
+  nullify (charp)
689258
+  nullify (charap)
689258
+  nullify (intp)
689258
+  nullify (intap)
689258
+  nullify (intvlap)
689258
+  nullify (realp)
689258
+  nullify (twop)
689258
+  nullify (arrayOfPtr(1)%p)
689258
+  nullify (arrayOfPtr(2)%p)
689258
+  nullify (arrayOfPtr(3)%p)
689258
+  nullify (cyclicp1%p)
689258
+  nullify (cyclicp2%p)
689258
+
689258
+  logp => logv    ! Before pointer assignment
689258
+  comp => comv
689258
+  charp => charv
689258
+  charap => chara
689258
+  intp => intv
689258
+  intap => inta
689258
+  intvlap => intvla
689258
+  realp => realv
689258
+  twop => twov
689258
+  arrayOfPtr(2)%p => twov
689258
+  cyclicp1%i = 1
689258
+  cyclicp1%p => cyclicp2
689258
+  cyclicp2%i = 2
689258
+  cyclicp2%p => cyclicp1
689258
+
689258
+  logv = associated(logp)     ! Before value assignment
689258
+  comv = cmplx(1,2)
689258
+  charv = "a"
689258
+  chara = "abc"
689258
+  intv = 10
689258
+  inta(:,:) = 1
689258
+  inta(3,1) = 3
689258
+  allocate (intvla(10))
689258
+  intvla(:) = 2
689258
+  intvla(4) = 4
689258
+  intvlap => intvla
689258
+  realv = 3.14
689258
+
689258
+  allocate (twov%ivla1(3))
689258
+  allocate (twov%ivla2(2,2))
689258
+  twov%ivla1(1) = 11
689258
+  twov%ivla1(2) = 12
689258
+  twov%ivla1(3) = 13
689258
+  twov%ivla2(1,1) = 211
689258
+  twov%ivla2(2,1) = 221
689258
+  twov%ivla2(1,2) = 212
689258
+  twov%ivla2(2,2) = 222
689258
+
689258
+  intv = intv + 1 ! After value assignment
689258
+
689258
+end program pointers
689258
diff --git a/gdb/testsuite/gdb.fortran/print_type.exp b/gdb/testsuite/gdb.fortran/print_type.exp
689258
new file mode 100644
689258
--- /dev/null
689258
+++ b/gdb/testsuite/gdb.fortran/print_type.exp
689258
@@ -0,0 +1,100 @@
689258
+# Copyright 2016 Free Software Foundation, Inc.
689258
+
689258
+# This program is free software; you can redistribute it and/or modify
689258
+# it under the terms of the GNU General Public License as published by
689258
+# the Free Software Foundation; either version 3 of the License, or
689258
+# (at your option) any later version.
689258
+#
689258
+# This program is distributed in the hope that it will be useful,
689258
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
689258
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
689258
+# GNU General Public License for more details.
689258
+#
689258
+# You should have received a copy of the GNU General Public License
689258
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
689258
+
689258
+standard_testfile "pointers.f90"
689258
+load_lib fortran.exp
689258
+
689258
+if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
689258
+    {debug f90 quiet}] } {
689258
+    return -1
689258
+}
689258
+
689258
+
689258
+if ![runto_main] {
689258
+    untested "could not run to main"
689258
+    return -1
689258
+}
689258
+
689258
+# Depending on the compiler being used, the type names can be printed differently.
689258
+set logical [fortran_logical4]
689258
+set real [fortran_real4]
689258
+set int [fortran_int4]
689258
+set complex [fortran_complex4]
689258
+
689258
+gdb_breakpoint [gdb_get_line_number "Before pointer assignment"]
689258
+gdb_continue_to_breakpoint "Before pointer assignment"
689258
+gdb_test "ptype logp" "type = PTR TO -> \\( $logical \\)" "ptype logp, not associated"
689258
+gdb_test "ptype comp" "type = PTR TO -> \\( $complex \\)" "ptype comp, not associated"
689258
+gdb_test "ptype charp" "type = PTR TO -> \\( character\\*1 \\)" "ptype charp, not associated"
689258
+gdb_test "ptype charap" "type = PTR TO -> \\( character\\*3 \\)" "ptype charap, not associated"
689258
+gdb_test "ptype intp" "type = PTR TO -> \\( $int \\)" "ptype intp, not associated"
689258
+set test "ptype intap, not associated"
689258
+gdb_test_multiple "ptype intap" $test {
689258
+    -re "type = PTR TO -> \\( $int \\(:,:\\)\\)\r\n$gdb_prompt $" {
689258
+        pass $test
689258
+    }
689258
+    -re "type = $int \\(:,:\\)\r\n$gdb_prompt $" {
689258
+        pass $test
689258
+    }
689258
+}
689258
+gdb_test "ptype realp" "type = PTR TO -> \\( $real \\)" "ptype realp, not associated"
689258
+gdb_test "ptype twop" \
689258
+    [multi_line "type = PTR TO -> \\( Type two" \
689258
+                "    $int :: ivla1\\(:\\)" \
689258
+                "    $int :: ivla2\\(:,:\\)" \
689258
+                "End Type two \\)"] \
689258
+    "ptype twop, not associated"
689258
+gdb_test "ptype two" \
689258
+    [multi_line "type = Type two" \
689258
+                "    $int :: ivla1\\(:\\)" \
689258
+                "    $int :: ivla2\\(:,:\\)" \
689258
+                "End Type two"]
689258
+
689258
+
689258
+gdb_breakpoint [gdb_get_line_number "Before value assignment"]
689258
+gdb_continue_to_breakpoint "Before value assignment"
689258
+gdb_test "ptype twop" \
689258
+    [multi_line "type = PTR TO -> \\( Type two" \
689258
+                "    $int :: ivla1\\(:\\)" \
689258
+                "    $int :: ivla2\\(:,:\\)" \
689258
+                "End Type two \\)"]
689258
+
689258
+
689258
+gdb_breakpoint [gdb_get_line_number "After value assignment"]
689258
+gdb_continue_to_breakpoint "After value assignment"
689258
+gdb_test "ptype logv" "type = $logical"
689258
+gdb_test "ptype comv" "type = $complex"
689258
+gdb_test "ptype charv" "type = character\\*1"
689258
+gdb_test "ptype chara" "type = character\\*3"
689258
+gdb_test "ptype intv" "type = $int"
689258
+gdb_test "ptype inta" "type = $int \\(10,2\\)"
689258
+gdb_test "ptype realv" "type = $real"
689258
+
689258
+
689258
+gdb_test "ptype logp" "type = PTR TO -> \\( $logical \\)"
689258
+gdb_test "ptype comp" "type = PTR TO -> \\( $complex \\)"
689258
+gdb_test "ptype charp" "type = PTR TO -> \\( character\\*1 \\)"
689258
+gdb_test "ptype charap" "type = PTR TO -> \\( character\\*3 \\)"
689258
+gdb_test "ptype intp" "type = PTR TO -> \\( $int \\)"
689258
+set test "ptype intap"
689258
+gdb_test_multiple $test $test {
689258
+    -re "type = $int \\(10,2\\)\r\n$gdb_prompt $" {
689258
+        pass $test
689258
+    }
689258
+    -re "type = PTR TO -> \\( $int \\(10,2\\)\\)\r\n$gdb_prompt $" {
689258
+        pass $test
689258
+    }
689258
+}
689258
+gdb_test "ptype realp" "type = PTR TO -> \\( $real \\)"
689258
diff --git a/gdb/testsuite/gdb.fortran/vla-ptype.exp b/gdb/testsuite/gdb.fortran/vla-ptype.exp
689258
--- a/gdb/testsuite/gdb.fortran/vla-ptype.exp
689258
+++ b/gdb/testsuite/gdb.fortran/vla-ptype.exp
689258
@@ -32,9 +32,9 @@ set real [fortran_real4]
689258
 # Check the ptype of various VLA states and pointer to VLA's.
689258
 gdb_breakpoint [gdb_get_line_number "vla1-init"]
689258
 gdb_continue_to_breakpoint "vla1-init"
689258
-gdb_test "ptype vla1" "type = <not allocated>" "ptype vla1 not initialized"
689258
-gdb_test "ptype vla2" "type = <not allocated>" "ptype vla2 not initialized"
689258
-gdb_test "ptype pvla" "type = <not associated>" "ptype pvla not initialized"
689258
+gdb_test "ptype vla1" "type = $real \\(:,:,:\\)" "ptype vla1 not initialized"
689258
+gdb_test "ptype vla2" "type = $real \\(:,:,:\\)" "ptype vla2 not initialized"
689258
+gdb_test "ptype pvla" "type = $real \\(:,:,:\\)" "ptype pvla not initialized"
689258
 gdb_test "ptype vla1(3, 6, 9)" "no such vector element \\\(vector not allocated\\\)" \
689258
   "ptype vla1(3, 6, 9) not initialized"
689258
 gdb_test "ptype vla2(5, 45, 20)" \
689258
@@ -81,20 +81,20 @@ gdb_test "ptype vla2(5, 45, 20)" "type = $real" \
689258
 
689258
 gdb_breakpoint [gdb_get_line_number "pvla-deassociated"]
689258
 gdb_continue_to_breakpoint "pvla-deassociated"
689258
-gdb_test "ptype pvla" "type = <not associated>" "ptype pvla deassociated"
689258
+gdb_test "ptype pvla" "type = $real \\(:,:,:\\)" "ptype pvla deassociated"
689258
 gdb_test "ptype pvla(5, 45, 20)" \
689258
   "no such vector element \\\(vector not associated\\\)" \
689258
   "ptype pvla(5, 45, 20) not associated"
689258
 
689258
 gdb_breakpoint [gdb_get_line_number "vla1-deallocated"]
689258
 gdb_continue_to_breakpoint "vla1-deallocated"
689258
-gdb_test "ptype vla1" "type = <not allocated>" "ptype vla1 not allocated"
689258
+gdb_test "ptype vla1" "type = $real \\(:,:,:\\)" "ptype vla1 not allocated"
689258
 gdb_test "ptype vla1(3, 6, 9)" "no such vector element \\\(vector not allocated\\\)" \
689258
   "ptype vla1(3, 6, 9) not allocated"
689258
 
689258
 gdb_breakpoint [gdb_get_line_number "vla2-deallocated"]
689258
 gdb_continue_to_breakpoint "vla2-deallocated"
689258
-gdb_test "ptype vla2" "type = <not allocated>" "ptype vla2 not allocated"
689258
+gdb_test "ptype vla2" "type = $real \\(:,:,:\\)" "ptype vla2 not allocated"
689258
 gdb_test "ptype vla2(5, 45, 20)" \
689258
   "no such vector element \\\(vector not allocated\\\)" \
689258
   "ptype vla2(5, 45, 20) not allocated"
689258
diff --git a/gdb/testsuite/gdb.fortran/vla-strings.exp b/gdb/testsuite/gdb.fortran/vla-strings.exp
689258
new file mode 100644
689258
--- /dev/null
689258
+++ b/gdb/testsuite/gdb.fortran/vla-strings.exp
689258
@@ -0,0 +1,103 @@
689258
+# Copyright 2016 Free Software Foundation, Inc.
689258
+
689258
+# This program is free software; you can redistribute it and/or modify
689258
+# it under the terms of the GNU General Public License as published by
689258
+# the Free Software Foundation; either version 3 of the License, or
689258
+# (at your option) any later version.
689258
+#
689258
+# This program is distributed in the hope that it will be useful,
689258
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
689258
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
689258
+# GNU General Public License for more details.
689258
+#
689258
+# You should have received a copy of the GNU General Public License
689258
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
689258
+
689258
+standard_testfile ".f90"
689258
+
689258
+if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
689258
+    {debug f90 quiet}] } {
689258
+    return -1
689258
+}
689258
+
689258
+# check that all fortran standard datatypes will be
689258
+# handled correctly when using as VLA's
689258
+
689258
+if ![runto_main] {
689258
+    untested "could not run to main"
689258
+    return -1
689258
+}
689258
+
689258
+gdb_breakpoint [gdb_get_line_number "var_char-allocated-1"]
689258
+gdb_continue_to_breakpoint "var_char-allocated-1"
689258
+set test "whatis var_char first time"
689258
+gdb_test_multiple "whatis var_char" $test {
689258
+    -re "type = PTR TO -> \\( character\\*10 \\)\r\n$gdb_prompt $" {
689258
+	    pass $test
689258
+    }
689258
+    -re "type = character\\*10\r\n$gdb_prompt $" {
689258
+	    pass $test
689258
+    }
689258
+}
689258
+set test "ptype var_char first time"
689258
+gdb_test_multiple "ptype var_char" $test {
689258
+    -re "type = PTR TO -> \\( character\\*10 \\)\r\n$gdb_prompt $" {
689258
+	    pass $test
689258
+    }
689258
+    -re "type = character\\*10\r\n$gdb_prompt $" {
689258
+	    pass $test
689258
+    }
689258
+}
689258
+
689258
+
689258
+gdb_test "next" "\\d+.*var_char = 'foo'.*" \
689258
+  "next to allocation status of var_char"
689258
+gdb_test "print l" " = \\.TRUE\\." "print allocation status first time"
689258
+
689258
+
689258
+gdb_breakpoint [gdb_get_line_number "var_char-filled-1"]
689258
+gdb_continue_to_breakpoint "var_char-filled-1"
689258
+set test "print var_char, var_char-filled-1"
689258
+gdb_test_multiple "print var_char" $test {
689258
+    -re "= \\(PTR TO -> \\( character\\*3 \\)\\) $hex\r\n$gdb_prompt $" {
689258
+        gdb_test "print *var_char" "= 'foo'" "print *var_char, var_char-filled-1"
689258
+	    pass $test
689258
+    }
689258
+    -re "= 'foo'\r\n$gdb_prompt $" {
689258
+	    pass $test
689258
+    }
689258
+}
689258
+set test "ptype var_char, var_char-filled-1"
689258
+gdb_test_multiple "ptype var_char" $test {
689258
+    -re "type = PTR TO -> \\( character\\*3 \\)\r\n$gdb_prompt $" {
689258
+	    pass $test
689258
+    }
689258
+    -re "type = character\\*3\r\n$gdb_prompt $" {
689258
+	    pass $test
689258
+    }
689258
+}
689258
+gdb_test "print var_char(1)" " = 102 'f'" "print var_char(1)"
689258
+gdb_test "print var_char(3)" " = 111 'o'" "print var_char(3)"
689258
+
689258
+
689258
+gdb_breakpoint [gdb_get_line_number "var_char-filled-2"]
689258
+gdb_continue_to_breakpoint "var_char-filled-2"
689258
+set test "print var_char, var_char-filled-2"
689258
+gdb_test_multiple "print var_char" $test {
689258
+    -re "= \\(PTR TO -> \\( character\\*6 \\)\\) $hex\r\n$gdb_prompt $" {
689258
+        gdb_test "print *var_char" "= 'foobar'" "print *var_char, var_char-filled-2"
689258
+	    pass $test
689258
+    }
689258
+    -re "= 'foobar'\r\n$gdb_prompt $" {
689258
+	    pass $test
689258
+    }
689258
+}
689258
+set test "ptype var_char, var_char-filled-2"
689258
+gdb_test_multiple "ptype var_char" $test {
689258
+    -re "type = PTR TO -> \\( character\\*6 \\)\r\n$gdb_prompt $" {
689258
+	    pass $test
689258
+    }
689258
+    -re "type = character\\*6\r\n$gdb_prompt $" {
689258
+	    pass $test
689258
+    }
689258
+}
689258
diff --git a/gdb/testsuite/gdb.fortran/vla-strings.f90 b/gdb/testsuite/gdb.fortran/vla-strings.f90
689258
new file mode 100644
689258
--- /dev/null
689258
+++ b/gdb/testsuite/gdb.fortran/vla-strings.f90
689258
@@ -0,0 +1,39 @@
689258
+! Copyright 2016 Free Software Foundation, Inc.
689258
+!
689258
+! This program is free software; you can redistribute it and/or modify
689258
+! it under the terms of the GNU General Public License as published by
689258
+! the Free Software Foundation; either version 3 of the License, or
689258
+! (at your option) any later version.
689258
+!
689258
+! This program is distributed in the hope that it will be useful,
689258
+! but WITHOUT ANY WARRANTY; without even the implied warranty of
689258
+! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
689258
+! GNU General Public License for more details.
689258
+!
689258
+! You should have received a copy of the GNU General Public License
689258
+! along with this program.  If not, see <http://www.gnu.org/licenses/>.
689258
+
689258
+program vla_strings
689258
+  character(len=:), target, allocatable   :: var_char
689258
+  character(len=:), pointer               :: var_char_p
689258
+  logical                                 :: l
689258
+
689258
+  allocate(character(len=10) :: var_char)
689258
+  l = allocated(var_char)                 ! var_char-allocated-1
689258
+  var_char = 'foo'
689258
+  deallocate(var_char)                    ! var_char-filled-1
689258
+  l = allocated(var_char)                 ! var_char-deallocated
689258
+  allocate(character(len=42) :: var_char)
689258
+  l = allocated(var_char)
689258
+  var_char = 'foobar'
689258
+  var_char = ''                           ! var_char-filled-2
689258
+  var_char = 'bar'                        ! var_char-empty
689258
+  deallocate(var_char)
689258
+  allocate(character(len=21) :: var_char)
689258
+  l = allocated(var_char)                 ! var_char-allocated-3
689258
+  var_char = 'johndoe'
689258
+  var_char_p => var_char
689258
+  l = associated(var_char_p)              ! var_char_p-associated
689258
+  var_char_p => null()
689258
+  l = associated(var_char_p)              ! var_char_p-not-associated
689258
+end program vla_strings
689258
diff --git a/gdb/testsuite/gdb.fortran/vla-type.exp b/gdb/testsuite/gdb.fortran/vla-type.exp
689258
--- a/gdb/testsuite/gdb.fortran/vla-type.exp
689258
+++ b/gdb/testsuite/gdb.fortran/vla-type.exp
689258
@@ -132,7 +132,10 @@ gdb_test "ptype fivearr(2)%tone" \
689258
                      "End Type one" ]
689258
 
689258
 # Check allocation status of dynamic array and it's dynamic members
689258
-gdb_test "ptype fivedynarr" "type = <not allocated>"
689258
+gdb_test "ptype fivedynarr" \
689258
+         [multi_line "type = Type five" \
689258
+                     "    Type one :: tone" \
689258
+                     "End Type five \\(:\\)" ]
689258
 gdb_test "next" ""
689258
 gdb_test "ptype fivedynarr(2)" \
689258
          [multi_line "type = Type five" \
689258
@@ -141,7 +144,7 @@ gdb_test "ptype fivedynarr(2)" \
689258
          "ptype fivedynarr(2), tone is not allocated"
689258
 gdb_test "ptype fivedynarr(2)%tone" \
689258
          [multi_line "type = Type one" \
689258
-                     "    $int :: ivla\\(<not allocated>\\)" \
689258
+                     "    $int :: ivla\\(:,:,:\\)" \
689258
                      "End Type one" ] \
689258
          "ptype fivedynarr(2)%tone, not allocated"
689258
 
689258
diff --git a/gdb/testsuite/gdb.fortran/vla-value.exp b/gdb/testsuite/gdb.fortran/vla-value.exp
689258
--- a/gdb/testsuite/gdb.fortran/vla-value.exp
689258
+++ b/gdb/testsuite/gdb.fortran/vla-value.exp
689258
@@ -35,7 +35,7 @@ gdb_breakpoint [gdb_get_line_number "vla1-init"]
689258
 gdb_continue_to_breakpoint "vla1-init"
689258
 gdb_test "print vla1" " = <not allocated>" "print non-allocated vla1"
689258
 gdb_test "print &vla1" \
689258
-  " = \\\(PTR TO -> \\\( $real \\\(<not allocated>\\\)\\\)\\\) $hex" \
689258
+  " = \\\(PTR TO -> \\\( $real \\\(:,:,:\\\)\\\)\\\) $hex" \
689258
   "print non-allocated &vla1"
689258
 gdb_test "print vla1(1,1,1)" "no such vector element \\\(vector not allocated\\\)" \
689258
   "print member in non-allocated vla1 (1)"
689258
@@ -76,7 +76,7 @@ gdb_test "print vla1(9, 9, 9)" " = 999" \
689258
 # Try to access values in undefined pointer to VLA (dangling)
689258
 gdb_test "print pvla" " = <not associated>" "print undefined pvla"
689258
 gdb_test "print &pvla" \
689258
-  " = \\\(PTR TO -> \\\( $real \\\(<not associated>\\\)\\\)\\\) $hex" \
689258
+  " = \\\(PTR TO -> \\\( $real \\\(:,:,:\\\)\\\)\\\) $hex" \
689258
   "print non-associated &pvla"
689258
 gdb_test "print pvla(1, 3, 8)" "no such vector element \\\(vector not associated\\\)" \
689258
   "print undefined pvla(1,3,8)"
689258
diff --git a/gdb/testsuite/gdb.mi/mi-vla-fortran.exp b/gdb/testsuite/gdb.mi/mi-vla-fortran.exp
689258
--- a/gdb/testsuite/gdb.mi/mi-vla-fortran.exp
689258
+++ b/gdb/testsuite/gdb.mi/mi-vla-fortran.exp
689258
@@ -51,10 +51,10 @@ mi_expect_stop "breakpoint-hit" "vla" "" ".*vla.f90" "$bp_lineno" \
689258
 mi_gdb_test "500-data-evaluate-expression vla1" \
689258
   "500\\^done,value=\"<not allocated>\"" "evaluate not allocated vla, before allocation"
689258
 
689258
-mi_create_varobj_checked vla1_not_allocated vla1 "<not allocated>" \
689258
+mi_create_varobj_checked vla1_not_allocated vla1 "$real \\(:\\)" \
689258
   "create local variable vla1_not_allocated"
689258
 mi_gdb_test "501-var-info-type vla1_not_allocated" \
689258
-  "501\\^done,type=\"<not allocated>\"" \
689258
+  "501\\^done,type=\"$real \\(:\\)\"" \
689258
   "info type variable vla1_not_allocated"
689258
 mi_gdb_test "502-var-show-format vla1_not_allocated" \
689258
   "502\\^done,format=\"natural\"" \
689258
@@ -146,10 +146,10 @@ gdb_expect {
689258
     -re "580\\^done,value=\"<not associated>\".*${mi_gdb_prompt}$" {
689258
 	pass $test
689258
 
689258
-	mi_create_varobj_checked pvla2_not_associated pvla2 "<not associated>" \
689258
+	mi_create_varobj_checked pvla2_not_associated pvla2 "$real \\(:,:\\)" \
689258
 	    "create local variable pvla2_not_associated"
689258
 	mi_gdb_test "581-var-info-type pvla2_not_associated" \
689258
-	    "581\\^done,type=\"<not associated>\"" \
689258
+	    "581\\^done,type=\"$real \\(:,:\\)\"" \
689258
 	    "info type variable pvla2_not_associated"
689258
 	mi_gdb_test "582-var-show-format pvla2_not_associated" \
689258
 	    "582\\^done,format=\"natural\"" \
689258
diff --git a/gdb/typeprint.c b/gdb/typeprint.c
689258
--- a/gdb/typeprint.c
689258
+++ b/gdb/typeprint.c
689258
@@ -589,6 +589,25 @@ whatis_exp (const char *exp, int show)
689258
       printf_filtered (" */\n");    
689258
     }
689258
 
689258
+  /* Resolve any dynamic target type, as we might print
689258
+     additional information about the target.
689258
+     For example, in Fortran and C we are printing the dimension of the
689258
+     dynamic array the pointer is pointing to.  */
689258
+  if (TYPE_CODE (type) == TYPE_CODE_PTR
689258
+      && is_dynamic_type (type) == 1)
689258
+    {
689258
+      CORE_ADDR addr;
689258
+      if (NULL != TYPE_DATA_LOCATION (TYPE_TARGET_TYPE(type)))
689258
+	addr = value_address (val);
689258
+      else
689258
+	addr = value_as_address (val);
689258
+
689258
+      if (addr != 0
689258
+	  && type_not_associated (type) == 0)
689258
+	TYPE_TARGET_TYPE (type) = resolve_dynamic_type (TYPE_TARGET_TYPE (type),
689258
+							NULL, addr);
689258
+    }
689258
+
689258
   LA_PRINT_TYPE (type, "", gdb_stdout, show, 0, &flags);
689258
   printf_filtered ("\n");
689258
 }
689258
diff --git a/gdb/valops.c b/gdb/valops.c
689258
--- a/gdb/valops.c
689258
+++ b/gdb/valops.c
689258
@@ -1565,6 +1565,19 @@ value_ind (struct value *arg1)
689258
   if (TYPE_CODE (base_type) == TYPE_CODE_PTR)
689258
     {
689258
       struct type *enc_type;
689258
+      CORE_ADDR addr;
689258
+
689258
+      if (type_not_associated (base_type))
689258
+        error (_("Attempt to take contents of a not associated pointer."));
689258
+
689258
+      if (NULL != TYPE_DATA_LOCATION (TYPE_TARGET_TYPE (base_type)))
689258
+	addr = value_address (arg1);
689258
+      else
689258
+	addr = value_as_address (arg1);
689258
+
689258
+      if (addr != 0)
689258
+	TYPE_TARGET_TYPE (base_type) =
689258
+	    resolve_dynamic_type (TYPE_TARGET_TYPE (base_type), NULL, addr);
689258
 
689258
       /* We may be pointing to something embedded in a larger object.
689258
          Get the real type of the enclosing object.  */
689258
@@ -1580,8 +1593,7 @@ value_ind (struct value *arg1)
689258
       else
689258
 	/* Retrieve the enclosing object pointed to.  */
689258
 	arg2 = value_at_lazy (enc_type, 
689258
-			      (value_as_address (arg1)
689258
-			       - value_pointed_to_offset (arg1)));
689258
+			      (addr - value_pointed_to_offset (arg1)));
689258
 
689258
       enc_type = value_type (arg2);
689258
       return readjust_indirect_value_type (arg2, enc_type, base_type, arg1);
689258
diff --git a/gdb/valprint.c b/gdb/valprint.c
689258
--- a/gdb/valprint.c
689258
+++ b/gdb/valprint.c
689258
@@ -1108,12 +1108,6 @@ value_check_printable (struct value *val, struct ui_file *stream,
689258
       return 0;
689258
     }
689258
 
689258
-  if (type_not_associated (value_type (val)))
689258
-    {
689258
-      val_print_not_associated (stream);
689258
-      return 0;
689258
-    }
689258
-
689258
   if (type_not_allocated (value_type (val)))
689258
     {
689258
       val_print_not_allocated (stream);