Blame SOURCES/gdb-vla-intel-fortran-vla-strings.patch

7d6eda
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
7d6eda
From: Fedora GDB patches <invalid@email.com>
7d6eda
Date: Fri, 27 Oct 2017 21:07:50 +0200
7d6eda
Subject: gdb-vla-intel-fortran-vla-strings.patch
7d6eda
7d6eda
;;=push
7d6eda
7d6eda
git diff --stat -p gdb/master...gdb/users/bheckel/fortran-vla-strings
7d6eda
0ad7d8d1a3a36c6e04e3b6d37d8825f18d595723
7d6eda
7d6eda
 gdb/NEWS                                  |   2 +
7d6eda
 gdb/c-valprint.c                          |  22 +++++
7d6eda
 gdb/dwarf2read.c                          | 158 +++++++++++++++++++++++++-----
7d6eda
 gdb/f-typeprint.c                         |  93 +++++++++---------
7d6eda
 gdb/gdbtypes.c                            |  44 ++++++++-
7d6eda
 gdb/testsuite/gdb.cp/vla-cxx.cc           |   9 ++
7d6eda
 gdb/testsuite/gdb.cp/vla-cxx.exp          |   9 ++
7d6eda
 gdb/testsuite/gdb.fortran/pointers.exp    | 143 +++++++++++++++++++++++++++
7d6eda
 gdb/testsuite/gdb.fortran/pointers.f90    | 109 +++++++++++++++++++++
7d6eda
 gdb/testsuite/gdb.fortran/print_type.exp  | 100 +++++++++++++++++++
7d6eda
 gdb/testsuite/gdb.fortran/vla-ptype.exp   |  12 +--
7d6eda
 gdb/testsuite/gdb.fortran/vla-strings.exp | 103 +++++++++++++++++++
7d6eda
 gdb/testsuite/gdb.fortran/vla-strings.f90 |  39 ++++++++
7d6eda
 gdb/testsuite/gdb.fortran/vla-type.exp    |   7 +-
7d6eda
 gdb/testsuite/gdb.fortran/vla-value.exp   |  12 ++-
7d6eda
 gdb/testsuite/gdb.mi/mi-var-child-f.exp   |   7 +-
7d6eda
 gdb/testsuite/gdb.mi/mi-vla-fortran.exp   |  27 ++---
7d6eda
 gdb/typeprint.c                           |  19 ++++
7d6eda
 gdb/valops.c                              |  16 ++-
7d6eda
 gdb/valprint.c                            |   6 --
7d6eda
 20 files changed, 827 insertions(+), 110 deletions(-)
7d6eda
7d6eda
diff --git a/gdb/NEWS b/gdb/NEWS
7d6eda
--- a/gdb/NEWS
7d6eda
+++ b/gdb/NEWS
7d6eda
@@ -805,6 +805,8 @@ SH-5/SH64 running OpenBSD 	SH-5/SH64 support in sh*-*-openbsd*
7d6eda
 
7d6eda
 *** Changes in GDB 8.1
7d6eda
 
7d6eda
+* Fortran: Support pointers to dynamic types.
7d6eda
+
7d6eda
 * GDB now supports dynamically creating arbitrary register groups specified
7d6eda
   in XML target descriptions.  This allows for finer grain grouping of
7d6eda
   registers on systems with a large amount of registers.
7d6eda
diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c
7d6eda
--- a/gdb/c-valprint.c
7d6eda
+++ b/gdb/c-valprint.c
7d6eda
@@ -649,6 +649,28 @@ c_value_print (struct value *val, struct ui_file *stream,
7d6eda
       else
7d6eda
 	{
7d6eda
 	  /* normal case */
7d6eda
+	  if (TYPE_CODE (type) == TYPE_CODE_PTR
7d6eda
+	      && 1 == is_dynamic_type (type))
7d6eda
+	    {
7d6eda
+	      CORE_ADDR addr;
7d6eda
+	      if (NULL != TYPE_DATA_LOCATION (TYPE_TARGET_TYPE (type)))
7d6eda
+		addr = value_address (val);
7d6eda
+	      else
7d6eda
+		addr = value_as_address (val);
7d6eda
+
7d6eda
+	      /* We resolve the target-type only when the
7d6eda
+	         pointer is associated.  */
7d6eda
+	      if ((addr != 0)
7d6eda
+		  && (0 == type_not_associated (type)))
7d6eda
+		  TYPE_TARGET_TYPE (type) =
7d6eda
+		      resolve_dynamic_type (TYPE_TARGET_TYPE (type),
7d6eda
+					    NULL, addr);
7d6eda
+	    }
7d6eda
+	  else
7d6eda
+	    {
7d6eda
+	      /* Do nothing. References are already resolved from the beginning,
7d6eda
+	         only pointers are resolved when we actual need the target.  */
7d6eda
+	    }
7d6eda
 	  fprintf_filtered (stream, "(");
7d6eda
 	  type_print (value_type (val), "", stream, -1);
7d6eda
 	  fprintf_filtered (stream, ") ");
7d6eda
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
7d6eda
--- a/gdb/dwarf2read.c
7d6eda
+++ b/gdb/dwarf2read.c
7d6eda
@@ -1827,7 +1827,10 @@ static void read_signatured_type (struct signatured_type *);
7d6eda
 
7d6eda
 static int attr_to_dynamic_prop (const struct attribute *attr,
7d6eda
 				 struct die_info *die, struct dwarf2_cu *cu,
7d6eda
-				 struct dynamic_prop *prop, struct type *type);
7d6eda
+				 struct dynamic_prop *prop,
7d6eda
+				 struct type *default_type,
7d6eda
+				 const gdb_byte *additional_data,
7d6eda
+				 int additional_data_size);
7d6eda
 
7d6eda
 /* memory allocation interface */
7d6eda
 
7d6eda
@@ -13799,7 +13802,7 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu)
7d6eda
       newobj->static_link
7d6eda
 	= XOBNEW (&objfile->objfile_obstack, struct dynamic_prop);
7d6eda
       attr_to_dynamic_prop (attr, die, cu, newobj->static_link,
7d6eda
-			    dwarf2_per_cu_addr_type (cu->per_cu));
7d6eda
+			    dwarf2_per_cu_addr_type (cu->per_cu), NULL, 0);
7d6eda
     }
7d6eda
 
7d6eda
   cu->list_in_scope = cu->get_builder ()->get_local_symbols ();
7d6eda
@@ -16565,7 +16568,7 @@ read_array_type (struct die_info *die, struct dwarf2_cu *cu)
7d6eda
       byte_stride_prop
7d6eda
 	= (struct dynamic_prop *) alloca (sizeof (struct dynamic_prop));
7d6eda
       stride_ok = attr_to_dynamic_prop (attr, die, cu, byte_stride_prop,
7d6eda
-					prop_type);
7d6eda
+					prop_type, NULL, 0);
7d6eda
       if (!stride_ok)
7d6eda
 	{
7d6eda
 	  complaint (_("unable to read array DW_AT_byte_stride "
7d6eda
@@ -17325,7 +17328,7 @@ read_tag_string_type (struct die_info *die, struct dwarf2_cu *cu)
7d6eda
   struct attribute *attr;
7d6eda
   struct dynamic_prop prop;
7d6eda
   bool length_is_constant = true;
7d6eda
-  LONGEST length;
7d6eda
+  ULONGEST length = UINT_MAX;
7d6eda
 
7d6eda
   /* There are a couple of places where bit sizes might be made use of
7d6eda
      when parsing a DW_TAG_string_type, however, no producer that we know
7d6eda
@@ -17346,6 +17349,10 @@ read_tag_string_type (struct die_info *die, struct dwarf2_cu *cu)
7d6eda
 	}
7d6eda
     }
7d6eda
 
7d6eda
+  index_type = objfile_type (objfile)->builtin_int;
7d6eda
+  range_type = create_static_range_type (NULL, index_type, 1, length);
7d6eda
+
7d6eda
+  /* If DW_AT_string_length is defined, the length is stored in memory.  */
7d6eda
   attr = dwarf2_attr (die, DW_AT_string_length, cu);
7d6eda
   if (attr != nullptr && !attr_form_is_constant (attr))
7d6eda
     {
7d6eda
@@ -17372,13 +17379,71 @@ read_tag_string_type (struct die_info *die, struct dwarf2_cu *cu)
7d6eda
 	}
7d6eda
 
7d6eda
       /* Convert the attribute into a dynamic property.  */
7d6eda
-      if (!attr_to_dynamic_prop (attr, die, cu, &prop, prop_type))
7d6eda
+      if (!attr_to_dynamic_prop (attr, die, cu, &prop, prop_type, NULL, 0))
7d6eda
 	length = 1;
7d6eda
       else
7d6eda
 	length_is_constant = false;
7d6eda
     }
7d6eda
   else if (attr != nullptr)
7d6eda
     {
7d6eda
+      if (attr_form_is_block (attr))
7d6eda
+	{
7d6eda
+	  struct attribute *byte_size, *bit_size;
7d6eda
+	  struct dynamic_prop high;
7d6eda
+
7d6eda
+	  byte_size = dwarf2_attr (die, DW_AT_byte_size, cu);
7d6eda
+	  bit_size = dwarf2_attr (die, DW_AT_bit_size, cu);
7d6eda
+
7d6eda
+	  /* DW_AT_byte_size should never occur in combination with
7d6eda
+	     DW_AT_bit_size.  */
7d6eda
+	  if (byte_size != NULL && bit_size != NULL)
7d6eda
+	    complaint (_("DW_AT_byte_size AND "
7d6eda
+			 "DW_AT_bit_size found together at the same time."));
7d6eda
+
7d6eda
+	  /* If DW_AT_string_length AND DW_AT_byte_size exist together,
7d6eda
+	     DW_AT_byte_size describes the number of bytes that should be read
7d6eda
+	     from the length memory location.  */
7d6eda
+	  if (byte_size != NULL)
7d6eda
+	    {
7d6eda
+	      /* Build new dwarf2_locexpr_baton structure with additions to the
7d6eda
+		 data attribute, to reflect DWARF specialities to get address
7d6eda
+		 sizes.  */
7d6eda
+	      const gdb_byte append_ops[] =
7d6eda
+		{
7d6eda
+		/* DW_OP_deref_size: size of an address on the target machine
7d6eda
+		   (bytes), where the size will be specified by the next
7d6eda
+		   operand.  */
7d6eda
+		DW_OP_deref_size,
7d6eda
+		/* Operand for DW_OP_deref_size.  */
7d6eda
+		(gdb_byte) DW_UNSND(byte_size) };
7d6eda
+
7d6eda
+	      if (!attr_to_dynamic_prop (attr, die, cu, &high, index_type,
7d6eda
+					 append_ops, ARRAY_SIZE(append_ops)))
7d6eda
+		complaint (_("Could not parse DW_AT_byte_size"));
7d6eda
+	    }
7d6eda
+	  else if (bit_size != NULL)
7d6eda
+	    complaint (_("DW_AT_string_length AND "
7d6eda
+			 "DW_AT_bit_size found but not supported yet."));
7d6eda
+	  /* If DW_AT_string_length WITHOUT DW_AT_byte_size exist, the default
7d6eda
+	     is the address size of the target machine.  */
7d6eda
+	  else
7d6eda
+	    {
7d6eda
+	      const gdb_byte append_ops[] =
7d6eda
+		{ DW_OP_deref };
7d6eda
+
7d6eda
+	      if (!attr_to_dynamic_prop (attr, die, cu, &high, index_type,
7d6eda
+					 append_ops, ARRAY_SIZE(append_ops)))
7d6eda
+		complaint (_("Could not parse DW_AT_string_length"));
7d6eda
+	    }
7d6eda
+
7d6eda
+	  TYPE_RANGE_DATA (range_type)->high = high;
7d6eda
+	}
7d6eda
+      else
7d6eda
+	{
7d6eda
+	  TYPE_HIGH_BOUND (range_type) = DW_UNSND(attr);
7d6eda
+	  TYPE_HIGH_BOUND_KIND (range_type) = PROP_CONST;
7d6eda
+	}
7d6eda
+
7d6eda
       /* This DW_AT_string_length just contains the length with no
7d6eda
 	 indirection.  There's no need to create a dynamic property in this
7d6eda
 	 case.  Pass 0 for the default value as we know it will not be
7d6eda
@@ -17392,6 +17457,20 @@ read_tag_string_type (struct die_info *die, struct dwarf2_cu *cu)
7d6eda
     }
7d6eda
   else
7d6eda
     {
7d6eda
+      /* Check for the DW_AT_byte_size attribute, which represents the length
7d6eda
+	 in this case.  */
7d6eda
+      attr = dwarf2_attr (die, DW_AT_byte_size, cu);
7d6eda
+      if (attr)
7d6eda
+	{
7d6eda
+	  TYPE_HIGH_BOUND (range_type) = DW_UNSND(attr);
7d6eda
+	  TYPE_HIGH_BOUND_KIND (range_type) = PROP_CONST;
7d6eda
+	}
7d6eda
+      else
7d6eda
+	{
7d6eda
+	  TYPE_HIGH_BOUND (range_type) = 1;
7d6eda
+	  TYPE_HIGH_BOUND_KIND (range_type) = PROP_CONST;
7d6eda
+	}
7d6eda
+
7d6eda
       /* Use 1 as a fallback length if we have nothing else.  */
7d6eda
       length = 1;
7d6eda
     }
7d6eda
@@ -17407,6 +17486,7 @@ read_tag_string_type (struct die_info *die, struct dwarf2_cu *cu)
7d6eda
       low_bound.data.const_val = 1;
7d6eda
       range_type = create_range_type (NULL, index_type, &low_bound, &prop, 0);
7d6eda
     }
7d6eda
+
7d6eda
   char_type = language_string_char_type (cu->language_defn, gdbarch);
7d6eda
   type = create_string_type (NULL, char_type, range_type);
7d6eda
 
7d6eda
@@ -17858,7 +17938,8 @@ read_base_type (struct die_info *die, struct dwarf2_cu *cu)
7d6eda
 static int
7d6eda
 attr_to_dynamic_prop (const struct attribute *attr, struct die_info *die,
7d6eda
 		      struct dwarf2_cu *cu, struct dynamic_prop *prop,
7d6eda
-		      struct type *default_type)
7d6eda
+		      struct type *default_type,
7d6eda
+		      const gdb_byte *additional_data, int additional_data_size)
7d6eda
 {
7d6eda
   struct dwarf2_property_baton *baton;
7d6eda
   struct obstack *obstack
7d6eda
@@ -17885,9 +17966,30 @@ attr_to_dynamic_prop (const struct attribute *attr, struct die_info *die,
7d6eda
 	  baton->locexpr.is_reference = false;
7d6eda
 	  break;
7d6eda
 	}
7d6eda
+
7d6eda
+      if (additional_data != NULL && additional_data_size > 0)
7d6eda
+	{
7d6eda
+	  gdb_byte *data;
7d6eda
+
7d6eda
+	  data = (gdb_byte *) obstack_alloc(
7d6eda
+	      &cu->per_cu->dwarf2_per_objfile->objfile->objfile_obstack,
7d6eda
+	      DW_BLOCK (attr)->size + additional_data_size);
7d6eda
+	  memcpy (data, DW_BLOCK (attr)->data, DW_BLOCK (attr)->size);
7d6eda
+	  memcpy (data + DW_BLOCK (attr)->size, additional_data,
7d6eda
+		  additional_data_size);
7d6eda
+
7d6eda
+	  baton->locexpr.data = data;
7d6eda
+	  baton->locexpr.size = DW_BLOCK (attr)->size + additional_data_size;
7d6eda
+	}
7d6eda
+      else
7d6eda
+	{
7d6eda
+	  baton->locexpr.data = DW_BLOCK (attr)->data;
7d6eda
+	  baton->locexpr.size = DW_BLOCK (attr)->size;
7d6eda
+	}
7d6eda
+
7d6eda
       prop->data.baton = baton;
7d6eda
       prop->kind = PROP_LOCEXPR;
7d6eda
-      gdb_assert (prop->data.baton != NULL);
7d6eda
+      gdb_assert(prop->data.baton != NULL);
7d6eda
     }
7d6eda
   else if (attr_form_is_ref (attr))
7d6eda
     {
7d6eda
@@ -17920,9 +18022,29 @@ attr_to_dynamic_prop (const struct attribute *attr, struct die_info *die,
7d6eda
 		baton = XOBNEW (obstack, struct dwarf2_property_baton);
7d6eda
 		baton->property_type = die_type (target_die, target_cu);
7d6eda
 		baton->locexpr.per_cu = cu->per_cu;
7d6eda
-		baton->locexpr.size = DW_BLOCK (target_attr)->size;
7d6eda
-		baton->locexpr.data = DW_BLOCK (target_attr)->data;
7d6eda
 		baton->locexpr.is_reference = true;
7d6eda
+
7d6eda
+		if (additional_data != NULL && additional_data_size > 0)
7d6eda
+		  {
7d6eda
+		    gdb_byte *data;
7d6eda
+
7d6eda
+		    data = (gdb_byte *) obstack_alloc (&cu->per_cu->dwarf2_per_objfile->objfile->objfile_obstack,
7d6eda
+			    DW_BLOCK (target_attr)->size + additional_data_size);
7d6eda
+		    memcpy (data, DW_BLOCK (target_attr)->data,
7d6eda
+			    DW_BLOCK (target_attr)->size);
7d6eda
+		    memcpy (data + DW_BLOCK (target_attr)->size,
7d6eda
+			    additional_data, additional_data_size);
7d6eda
+
7d6eda
+		    baton->locexpr.data = data;
7d6eda
+		    baton->locexpr.size = (DW_BLOCK (target_attr)->size
7d6eda
+					   + additional_data_size);
7d6eda
+		  }
7d6eda
+		else
7d6eda
+		  {
7d6eda
+		    baton->locexpr.data = DW_BLOCK (target_attr)->data;
7d6eda
+		    baton->locexpr.size = DW_BLOCK (target_attr)->size;
7d6eda
+		  }
7d6eda
+
7d6eda
 		prop->data.baton = baton;
7d6eda
 		prop->kind = PROP_LOCEXPR;
7d6eda
 		gdb_assert (prop->data.baton != NULL);
7d6eda
@@ -18099,8 +18221,8 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu)
7d6eda
     }
7d6eda
 
7d6eda
   attr = dwarf2_attr (die, DW_AT_lower_bound, cu);
7d6eda
-  if (attr != nullptr)
7d6eda
-    attr_to_dynamic_prop (attr, die, cu, &low, base_type);
7d6eda
+  if (attr)
7d6eda
+    attr_to_dynamic_prop (attr, die, cu, &low, base_type, NULL, 0);
7d6eda
   else if (!low_default_is_valid)
7d6eda
     complaint (_("Missing DW_AT_lower_bound "
7d6eda
 				      "- DIE at %s [in module %s]"),
7d6eda
@@ -18109,10 +18231,10 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu)
7d6eda
 
7d6eda
   struct attribute *attr_ub, *attr_count;
7d6eda
   attr = attr_ub = dwarf2_attr (die, DW_AT_upper_bound, cu);
7d6eda
-  if (!attr_to_dynamic_prop (attr, die, cu, &high, base_type))
7d6eda
+  if (!attr_to_dynamic_prop (attr, die, cu, &high, base_type, NULL, 0))
7d6eda
     {
7d6eda
       attr = attr_count = dwarf2_attr (die, DW_AT_count, cu);
7d6eda
-      if (attr_to_dynamic_prop (attr, die, cu, &high, base_type))
7d6eda
+      if (attr_to_dynamic_prop (attr, die, cu, &high, base_type, NULL, 0))
7d6eda
 	{
7d6eda
 	  /* If bounds are constant do the final calculation here.  */
7d6eda
 	  if (low.kind == PROP_CONST && high.kind == PROP_CONST)
7d6eda
@@ -18164,7 +18286,7 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu)
7d6eda
       struct type *prop_type
7d6eda
 	= dwarf2_per_cu_addr_sized_int_type (cu->per_cu, false);
7d6eda
       attr_to_dynamic_prop (attr_byte_stride, die, cu, &byte_stride_prop,
7d6eda
-			    prop_type);
7d6eda
+			    prop_type, NULL, 0);
7d6eda
     }
7d6eda
 
7d6eda
   struct dynamic_prop bit_stride_prop;
7d6eda
@@ -18185,7 +18307,7 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu)
7d6eda
 	  struct type *prop_type
7d6eda
 	    = dwarf2_per_cu_addr_sized_int_type (cu->per_cu, false);
7d6eda
 	  attr_to_dynamic_prop (attr_bit_stride, die, cu, &bit_stride_prop,
7d6eda
-				prop_type);
7d6eda
+				prop_type, NULL, 0);
7d6eda
 	}
7d6eda
     }
7d6eda
 
7d6eda
@@ -25879,7 +26001,7 @@ set_die_type (struct die_info *die, struct type *type, struct dwarf2_cu *cu)
7d6eda
     {
7d6eda
       struct type *prop_type
7d6eda
 	= dwarf2_per_cu_addr_sized_int_type (cu->per_cu, false);
7d6eda
-      if (attr_to_dynamic_prop (attr, die, cu, &prop, prop_type))
7d6eda
+      if (attr_to_dynamic_prop (attr, die, cu, &prop, prop_type, NULL, 0))
7d6eda
         add_dyn_prop (DYN_PROP_ALLOCATED, prop, type);
7d6eda
     }
7d6eda
   else if (attr != NULL)
7d6eda
@@ -25895,7 +26017,7 @@ set_die_type (struct die_info *die, struct type *type, struct dwarf2_cu *cu)
7d6eda
     {
7d6eda
       struct type *prop_type
7d6eda
 	= dwarf2_per_cu_addr_sized_int_type (cu->per_cu, false);
7d6eda
-      if (attr_to_dynamic_prop (attr, die, cu, &prop, prop_type))
7d6eda
+      if (attr_to_dynamic_prop (attr, die, cu, &prop, prop_type, NULL, 0))
7d6eda
         add_dyn_prop (DYN_PROP_ASSOCIATED, prop, type);
7d6eda
     }
7d6eda
   else if (attr != NULL)
7d6eda
@@ -25908,7 +26030,7 @@ set_die_type (struct die_info *die, struct type *type, struct dwarf2_cu *cu)
7d6eda
   /* Read DW_AT_data_location and set in type.  */
7d6eda
   attr = dwarf2_attr (die, DW_AT_data_location, cu);
7d6eda
   if (attr_to_dynamic_prop (attr, die, cu, &prop,
7d6eda
-			    dwarf2_per_cu_addr_type (cu->per_cu)))
7d6eda
+			    dwarf2_per_cu_addr_type (cu->per_cu), NULL, 0))
7d6eda
     add_dyn_prop (DYN_PROP_DATA_LOCATION, prop, type);
7d6eda
 
7d6eda
   if (dwarf2_per_objfile->die_type_hash == NULL)
7d6eda
diff --git a/gdb/f-typeprint.c b/gdb/f-typeprint.c
7d6eda
--- a/gdb/f-typeprint.c
7d6eda
+++ b/gdb/f-typeprint.c
7d6eda
@@ -197,15 +197,14 @@ f_type_print_varspec_suffix (struct type *type, struct ui_file *stream,
7d6eda
 	print_rank_only = true;
7d6eda
       else if ((TYPE_ASSOCIATED_PROP (type)
7d6eda
 		&& PROP_CONST != TYPE_DYN_PROP_KIND (TYPE_ASSOCIATED_PROP (type)))
7d6eda
-	       || (TYPE_ALLOCATED_PROP (type)
7d6eda
-		   && PROP_CONST != TYPE_DYN_PROP_KIND (TYPE_ALLOCATED_PROP (type)))
7d6eda
-	       || (TYPE_DATA_LOCATION (type)
7d6eda
-		   && PROP_CONST != TYPE_DYN_PROP_KIND (TYPE_DATA_LOCATION (type))))
7d6eda
-	{
7d6eda
-	  /* This case exist when we ptype a typename which has the dynamic
7d6eda
-	     properties but cannot be resolved as there is no object.  */
7d6eda
-	  print_rank_only = true;
7d6eda
-	}
7d6eda
+	      || (TYPE_ALLOCATED_PROP (type)
7d6eda
+		&& PROP_CONST != TYPE_DYN_PROP_KIND (TYPE_ALLOCATED_PROP (type)))
7d6eda
+	      || (TYPE_DATA_LOCATION (type)
7d6eda
+		  && PROP_CONST != TYPE_DYN_PROP_KIND (TYPE_DATA_LOCATION (type))))
7d6eda
+	/* This case exist when we ptype a typename which has the
7d6eda
+	   dynamic properties but cannot be resolved as there is
7d6eda
+	   no object.  */
7d6eda
+	print_rank_only = true;
7d6eda
 
7d6eda
       if (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_ARRAY)
7d6eda
 	f_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0,
7d6eda
@@ -217,8 +216,9 @@ f_type_print_varspec_suffix (struct type *type, struct ui_file *stream,
7d6eda
       else
7d6eda
 	{
7d6eda
 	  LONGEST lower_bound = f77_get_lowerbound (type);
7d6eda
+
7d6eda
 	  if (lower_bound != 1)	/* Not the default.  */
7d6eda
-            fprintf_filtered (stream, "%s:", plongest (lower_bound));
7d6eda
+	    fprintf_filtered (stream, "%s:", plongest (lower_bound));
7d6eda
 
7d6eda
 	  /* Make sure that, if we have an assumed size array, we
7d6eda
 	       print out a warning and print the upperbound as '*'.  */
7d6eda
@@ -229,7 +229,7 @@ f_type_print_varspec_suffix (struct type *type, struct ui_file *stream,
7d6eda
 	    {
7d6eda
 	      LONGEST upper_bound = f77_get_upperbound (type);
7d6eda
 
7d6eda
-              fputs_filtered (plongest (upper_bound), stream);
7d6eda
+	      fprintf_filtered (stream, "%s", plongest (upper_bound));
7d6eda
 	    }
7d6eda
 	}
7d6eda
 
7d6eda
@@ -249,7 +249,7 @@ f_type_print_varspec_suffix (struct type *type, struct ui_file *stream,
7d6eda
     case TYPE_CODE_REF:
7d6eda
       f_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, 1, 0,
7d6eda
 				   arrayprint_recurse_level, false);
7d6eda
-      fprintf_filtered (stream, " )");
7d6eda
+      fprintf_filtered (stream, ")");
7d6eda
       break;
7d6eda
 
7d6eda
     case TYPE_CODE_FUNC:
7d6eda
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
7d6eda
--- a/gdb/gdbtypes.c
7d6eda
+++ b/gdb/gdbtypes.c
7d6eda
@@ -1939,7 +1939,8 @@ is_dynamic_type_internal (struct type *type, int top_level)
7d6eda
   type = check_typedef (type);
7d6eda
 
7d6eda
   /* We only want to recognize references at the outermost level.  */
7d6eda
-  if (top_level && TYPE_CODE (type) == TYPE_CODE_REF)
7d6eda
+  if (top_level &&
7d6eda
+      (TYPE_CODE (type) == TYPE_CODE_REF || TYPE_CODE (type) == TYPE_CODE_PTR))
7d6eda
     type = check_typedef (TYPE_TARGET_TYPE (type));
7d6eda
 
7d6eda
   /* Types that have a dynamic TYPE_DATA_LOCATION are considered
7d6eda
@@ -1972,10 +1973,10 @@ is_dynamic_type_internal (struct type *type, int top_level)
7d6eda
 		|| is_dynamic_type_internal (TYPE_TARGET_TYPE (type), 0));
7d6eda
       }
7d6eda
 
7d6eda
-    case TYPE_CODE_STRING:
7d6eda
       /* Strings are very much like an array of characters, and can be
7d6eda
 	 treated as one here.  */
7d6eda
     case TYPE_CODE_ARRAY:
7d6eda
+    case TYPE_CODE_STRING:
7d6eda
       {
7d6eda
 	gdb_assert (TYPE_NFIELDS (type) == 1);
7d6eda
 
7d6eda
@@ -2139,11 +2140,15 @@ resolve_dynamic_array_or_string (struct type *type,
7d6eda
 
7d6eda
   ary_dim = check_typedef (TYPE_TARGET_TYPE (elt_type));
7d6eda
 
7d6eda
-  if (ary_dim != NULL && TYPE_CODE (ary_dim) == TYPE_CODE_ARRAY)
7d6eda
+  if (ary_dim != NULL && (TYPE_CODE (ary_dim) == TYPE_CODE_ARRAY
7d6eda
+      || TYPE_CODE (ary_dim) == TYPE_CODE_STRING))
7d6eda
     elt_type = resolve_dynamic_array_or_string (ary_dim, addr_stack);
7d6eda
   else
7d6eda
     elt_type = TYPE_TARGET_TYPE (type);
7d6eda
 
7d6eda
+  if (TYPE_CODE (type) == TYPE_CODE_STRING)
7d6eda
+    return create_string_type (type, elt_type, range_type);
7d6eda
+
7d6eda
   prop = get_dyn_prop (DYN_PROP_BYTE_STRIDE, type);
7d6eda
   if (prop != NULL)
7d6eda
     {
7d6eda
@@ -2295,6 +2300,28 @@ resolve_dynamic_struct (struct type *type,
7d6eda
   return resolved_type;
7d6eda
 }
7d6eda
 
7d6eda
+/* Worker for pointer types.  */
7d6eda
+
7d6eda
+static struct type *
7d6eda
+resolve_dynamic_pointer (struct type *type,
7d6eda
+			 struct property_addr_info *addr_stack)
7d6eda
+{
7d6eda
+  struct dynamic_prop *prop;
7d6eda
+  CORE_ADDR value;
7d6eda
+
7d6eda
+  type = copy_type (type);
7d6eda
+
7d6eda
+  /* Resolve associated property.  */
7d6eda
+  prop = TYPE_ASSOCIATED_PROP (type);
7d6eda
+  if (prop != NULL && dwarf2_evaluate_property (prop, NULL, addr_stack, &value))
7d6eda
+    {
7d6eda
+      TYPE_DYN_PROP_ADDR (prop) = value;
7d6eda
+      TYPE_DYN_PROP_KIND (prop) = PROP_CONST;
7d6eda
+    }
7d6eda
+
7d6eda
+  return type;
7d6eda
+}
7d6eda
+
7d6eda
 /* Worker for resolved_dynamic_type.  */
7d6eda
 
7d6eda
 static struct type *
7d6eda
@@ -2349,6 +2376,9 @@ resolve_dynamic_type_internal (struct type *type,
7d6eda
 	case TYPE_CODE_ARRAY:
7d6eda
 	  resolved_type = resolve_dynamic_array_or_string (type, addr_stack);
7d6eda
 	  break;
7d6eda
+        case TYPE_CODE_PTR:
7d6eda
+ 	  resolved_type = resolve_dynamic_pointer (type, addr_stack);
7d6eda
+ 	  break;
7d6eda
 
7d6eda
 	case TYPE_CODE_RANGE:
7d6eda
 	  resolved_type = resolve_dynamic_range (type, addr_stack);
7d6eda
diff --git a/gdb/testsuite/gdb.cp/vla-cxx.cc b/gdb/testsuite/gdb.cp/vla-cxx.cc
7d6eda
--- a/gdb/testsuite/gdb.cp/vla-cxx.cc
7d6eda
+++ b/gdb/testsuite/gdb.cp/vla-cxx.cc
7d6eda
@@ -15,6 +15,10 @@
7d6eda
    You should have received a copy of the GNU General Public License
7d6eda
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
7d6eda
 
7d6eda
+extern "C" {
7d6eda
+#include <stddef.h>
7d6eda
+}
7d6eda
+
7d6eda
 struct container;
7d6eda
 
7d6eda
 struct element
7d6eda
@@ -40,11 +44,16 @@ int main(int argc, char **argv)
7d6eda
   typedef typeof (vla) &vlareftypedef;
7d6eda
   vlareftypedef vlaref2 (vla);
7d6eda
   container c;
7d6eda
+  typeof (vla) *ptr = NULL;
7d6eda
+
7d6eda
+  // Before pointer assignment
7d6eda
+  ptr = &vla;
7d6eda
 
7d6eda
   for (int i = 0; i < z; ++i)
7d6eda
     vla[i] = 5 + 2 * i;
7d6eda
 
7d6eda
   // vlas_filled
7d6eda
   vla[0] = 2 * vla[0];
7d6eda
+
7d6eda
   return vla[2];
7d6eda
 }
7d6eda
diff --git a/gdb/testsuite/gdb.cp/vla-cxx.exp b/gdb/testsuite/gdb.cp/vla-cxx.exp
7d6eda
--- a/gdb/testsuite/gdb.cp/vla-cxx.exp
7d6eda
+++ b/gdb/testsuite/gdb.cp/vla-cxx.exp
7d6eda
@@ -23,6 +23,12 @@ if ![runto_main] {
7d6eda
     return -1
7d6eda
 }
7d6eda
 
7d6eda
+gdb_breakpoint [gdb_get_line_number "Before pointer assignment"]
7d6eda
+gdb_continue_to_breakpoint "Before pointer assignment"
7d6eda
+gdb_test "ptype ptr" "int \\(\\*\\)\\\[variable length\\\]" "ptype ptr, Before pointer assignment"
7d6eda
+gdb_test "print ptr" "\\(int \\(\\*\\)\\\[variable length\\\]\\) 0x0" "print ptr, Before pointer assignment"
7d6eda
+gdb_test "print *ptr" "Cannot access memory at address 0x0" "print *ptr, Before pointer assignment"
7d6eda
+
7d6eda
 gdb_breakpoint [gdb_get_line_number "vlas_filled"]
7d6eda
 gdb_continue_to_breakpoint "vlas_filled"
7d6eda
 
7d6eda
@@ -33,3 +39,6 @@ gdb_test "print vlaref" " = \\(int \\(&\\)\\\[3\\\]\\) @$hex: \\{5, 7, 9\\}"
7d6eda
 # bug being tested, it's better not to depend on the exact spelling.
7d6eda
 gdb_test "print vlaref2" " = \\(.*\\) @$hex: \\{5, 7, 9\\}"
7d6eda
 gdb_test "print c" " = \\{e = \\{c = @$hex\\}\\}"
7d6eda
+gdb_test "ptype ptr" "int \\(\\*\\)\\\[3\\\]"
7d6eda
+gdb_test "print ptr" "\\(int \\(\\*\\)\\\[3\\\]\\) $hex"
7d6eda
+gdb_test "print *ptr" " = \\{5, 7, 9\\}"
7d6eda
diff --git a/gdb/testsuite/gdb.fortran/pointers.exp b/gdb/testsuite/gdb.fortran/pointers.exp
7d6eda
new file mode 100644
7d6eda
--- /dev/null
7d6eda
+++ b/gdb/testsuite/gdb.fortran/pointers.exp
7d6eda
@@ -0,0 +1,143 @@
7d6eda
+# Copyright 2016 Free Software Foundation, Inc.
7d6eda
+
7d6eda
+# This program is free software; you can redistribute it and/or modify
7d6eda
+# it under the terms of the GNU General Public License as published by
7d6eda
+# the Free Software Foundation; either version 3 of the License, or
7d6eda
+# (at your option) any later version.
7d6eda
+#
7d6eda
+# This program is distributed in the hope that it will be useful,
7d6eda
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
7d6eda
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
7d6eda
+# GNU General Public License for more details.
7d6eda
+#
7d6eda
+# You should have received a copy of the GNU General Public License
7d6eda
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
7d6eda
+
7d6eda
+standard_testfile "pointers.f90"
7d6eda
+load_lib fortran.exp
7d6eda
+
7d6eda
+if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
7d6eda
+    {debug f90 quiet}] } {
7d6eda
+    return -1
7d6eda
+}
7d6eda
+
7d6eda
+if ![runto_main] {
7d6eda
+    untested "could not run to main"
7d6eda
+    return -1
7d6eda
+}
7d6eda
+
7d6eda
+# Depending on the compiler being used, the type names can be printed differently.
7d6eda
+set logical [fortran_logical4]
7d6eda
+set real [fortran_real4]
7d6eda
+set int [fortran_int4]
7d6eda
+set complex [fortran_complex4]
7d6eda
+
7d6eda
+
7d6eda
+gdb_breakpoint [gdb_get_line_number "Before pointer assignment"]
7d6eda
+gdb_continue_to_breakpoint "Before pointer assignment"
7d6eda
+gdb_test "print logp" "= \\(PTR TO -> \\( $logical\\)\\) 0x0" "print logp, not associated"
7d6eda
+gdb_test "print *logp" "Cannot access memory at address 0x0" "print *logp, not associated"
7d6eda
+gdb_test "print comp" "= \\(PTR TO -> \\( $complex\\)\\) 0x0" "print comp, not associated"
7d6eda
+gdb_test "print *comp" "Cannot access memory at address 0x0" "print *comp, not associated"
7d6eda
+gdb_test "print charp" "= \\(PTR TO -> \\( character\\*1\\)\\) 0x0" "print charp, not associated"
7d6eda
+gdb_test "print *charp" "Cannot access memory at address 0x0" "print *charp, not associated"
7d6eda
+gdb_test "print charap" "= \\(PTR TO -> \\( character\\*3\\)\\) 0x0" "print charap, not associated"
7d6eda
+gdb_test "print *charap" "Cannot access memory at address 0x0" "print *charap, not associated"
7d6eda
+gdb_test "print intp" "= \\(PTR TO -> \\( $int\\)\\) 0x0" "print intp, not associated"
7d6eda
+gdb_test "print *intp" "Cannot access memory at address 0x0" "print *intp, not associated"
7d6eda
+set test "print intap, not associated"
7d6eda
+gdb_test_multiple "print intap" $test {
7d6eda
+  -re " = \\(PTR TO -> \\( $int \\(:,:\\)\\)\\) <not associated>\r\n$gdb_prompt $" {
7d6eda
+    pass $test
7d6eda
+  }
7d6eda
+  -re " = <not associated>\r\n$gdb_prompt $" {
7d6eda
+    pass $test
7d6eda
+  }
7d6eda
+}
7d6eda
+gdb_test "print realp" "= \\(PTR TO -> \\( $real\\)\\) 0x0" "print realp, not associated"
7d6eda
+gdb_test "print *realp" "Cannot access memory at address 0x0" "print *realp, not associated"
7d6eda
+gdb_test "print \$my_var = intp" "= \\(PTR TO -> \\( $int\\)\\) 0x0"
7d6eda
+set test "print cyclicp1, not associated"
7d6eda
+gdb_test_multiple "print cyclicp1" $test {
7d6eda
+  -re "= \\( i = -?\\d+, p = 0x0 \\)\r\n$gdb_prompt $" {
7d6eda
+    pass $test
7d6eda
+  }
7d6eda
+  -re "= \\( i = -?\\d+, p = <not associated> \\)\r\n$gdb_prompt $" {
7d6eda
+    pass $test
7d6eda
+  }
7d6eda
+}
7d6eda
+set test "print cyclicp1%p, not associated"
7d6eda
+gdb_test_multiple "print cyclicp1%p" $test {
7d6eda
+  -re "= \\(PTR TO -> \\( Type typewithpointer\\)\\) 0x0\r\n$gdb_prompt $" {
7d6eda
+    pass $test
7d6eda
+  }
7d6eda
+  -re "= \\(PTR TO -> \\( Type typewithpointer\\)\\) <not associated>\r\n$gdb_prompt $" {
7d6eda
+    pass $test
7d6eda
+  }
7d6eda
+}
7d6eda
+
7d6eda
+
7d6eda
+gdb_breakpoint [gdb_get_line_number "Before value assignment"]
7d6eda
+gdb_continue_to_breakpoint "Before value assignment"
7d6eda
+gdb_test "print *(twop)%ivla2" "= <not allocated>"
7d6eda
+
7d6eda
+
7d6eda
+gdb_breakpoint [gdb_get_line_number "After value assignment"]
7d6eda
+gdb_continue_to_breakpoint "After value assignment"
7d6eda
+gdb_test "print logp" "= \\(PTR TO -> \\( $logical\\)\\) $hex\( <.*>\)?"
7d6eda
+gdb_test "print *logp" "= \\.TRUE\\."
7d6eda
+gdb_test "print comp" "= \\(PTR TO -> \\( $complex\\)\\) $hex\( <.*>\)?"
7d6eda
+gdb_test "print *comp" "= \\(1,2\\)"
7d6eda
+gdb_test "print charp" "= \\(PTR TO -> \\( character\\*1\\)\\) $hex\( <.*>\)?"
7d6eda
+gdb_test "print *charp" "= 'a'"
7d6eda
+gdb_test "print charap" "= \\(PTR TO -> \\( character\\*3\\)\\) $hex\( <.*>\)?"
7d6eda
+gdb_test "print *charap" "= 'abc'"
7d6eda
+gdb_test "print intp" "= \\(PTR TO -> \\( $int\\)\\) $hex\( <.*>\)?"
7d6eda
+gdb_test "print *intp" "= 10"
7d6eda
+set test_name "print intap, associated"
7d6eda
+gdb_test_multiple "print intap" $test_name {
7d6eda
+  -re "= \\(\\( 1, 1, 3(, 1){7}\\) \\( 1(, 1){9}\\) \\)\r\n$gdb_prompt $" {
7d6eda
+    pass $test_name
7d6eda
+  }
7d6eda
+  -re "= \\(PTR TO -> \\( $int \\(10,2\\)\\)\\) $hex\( <.*>\)?\r\n$gdb_prompt $" {
7d6eda
+    gdb_test "print *intap" "= \\(\\( 1, 1, 3(, 1){7}\\) \\( 1(, 1){9}\\) \\)"
7d6eda
+    pass $test_name
7d6eda
+  }
7d6eda
+}
7d6eda
+set test_name "print intvlap, associated"
7d6eda
+gdb_test_multiple "print intvlap" $test_name {
7d6eda
+  -re "= \\(2, 2, 2, 4(, 2){6}\\)\r\n$gdb_prompt $" {
7d6eda
+    pass $test_name
7d6eda
+  }
7d6eda
+  -re "= \\(PTR TO -> \\( $int \\(10\\)\\)\\) $hex\( <.*>\)?\r\n$gdb_prompt $" {
7d6eda
+    gdb_test "print *intvlap" "= \\(2, 2, 2, 4(, 2){6}\\)"
7d6eda
+    pass $test_name
7d6eda
+  }
7d6eda
+}
7d6eda
+gdb_test "print realp" "= \\(PTR TO -> \\( $real\\)\\) $hex\( <.*>\)?"
7d6eda
+gdb_test "print *realp" "= 3\\.14000\\d+"
7d6eda
+gdb_test "print arrayOfPtr(2)%p" "= \\(PTR TO -> \\( Type two\\)\\) $hex\( <.*>\)?"
7d6eda
+gdb_test "print *(arrayOfPtr(2)%p)" "= \\( ivla1 = \\(11, 12, 13\\), ivla2 = \\(\\( 211, 221\\) \\( 212, 222\\) \\) \\)"
7d6eda
+set test_name "print arrayOfPtr(3)%p"
7d6eda
+gdb_test_multiple $test_name $test_name {
7d6eda
+  -re "= \\(PTR TO -> \\( Type two\\)\\) <not associated>\r\n$gdb_prompt $" {
7d6eda
+    pass $test_name
7d6eda
+  }
7d6eda
+  -re "= \\(PTR TO -> \\( Type two\\)\\) 0x0\r\n$gdb_prompt $" {
7d6eda
+    pass $test_name
7d6eda
+  }
7d6eda
+}
7d6eda
+set test_name "print *(arrayOfPtr(3)%p), associated"
7d6eda
+gdb_test_multiple "print *(arrayOfPtr(3)%p)" $test_name {
7d6eda
+  -re "Cannot access memory at address 0x0\r\n$gdb_prompt $" {
7d6eda
+    pass $test_name
7d6eda
+  }
7d6eda
+  -re "Attempt to take contents of a not associated pointer.\r\n$gdb_prompt $" {
7d6eda
+    pass $test_name
7d6eda
+  }
7d6eda
+}
7d6eda
+gdb_test "print cyclicp1" "= \\( i = 1, p = $hex\( <.*>\)? \\)"
7d6eda
+gdb_test "print cyclicp1%p" "= \\(PTR TO -> \\( Type typewithpointer\\)\\) $hex\( <.*>\)?"
7d6eda
+gdb_test "print *((integer*) &inta + 2)" "= 3" "print temporary pointer, array"
7d6eda
+gdb_test "print *((integer*) &intvla + 3)" "= 4" "print temporary pointer, allocated vla"
7d6eda
+gdb_test "print \$pc" "= \\(PTR TO -> \\( void \\(\\) \\(\\)\\)\\) $hex <pointers\\+\\d+>" "Print program counter"
7d6eda
diff --git a/gdb/testsuite/gdb.fortran/pointers.f90 b/gdb/testsuite/gdb.fortran/pointers.f90
7d6eda
--- a/gdb/testsuite/gdb.fortran/pointers.f90
7d6eda
+++ b/gdb/testsuite/gdb.fortran/pointers.f90
7d6eda
@@ -20,21 +20,34 @@ program pointers
7d6eda
     integer, allocatable :: ivla2 (:, :)
7d6eda
   end type two
7d6eda
 
7d6eda
+  type :: typeWithPointer
7d6eda
+    integer i
7d6eda
+    type(typeWithPointer), pointer:: p
7d6eda
+  end type typeWithPointer
7d6eda
+
7d6eda
+  type :: twoPtr
7d6eda
+    type (two), pointer :: p
7d6eda
+  end type twoPtr
7d6eda
+
7d6eda
   logical, target :: logv
7d6eda
   complex, target :: comv
7d6eda
   character, target :: charv
7d6eda
   character (len=3), target :: chara
7d6eda
   integer, target :: intv
7d6eda
   integer, target, dimension (10,2) :: inta
7d6eda
-  real, target :: realv
7d6eda
-  type(two), target :: twov
7d6eda
+  integer, target, allocatable, dimension (:) :: intvla
7d6eda
+  real, target    :: realv
7d6eda
+  type(two), target  :: twov
7d6eda
+  type(twoPtr) :: arrayOfPtr (3)
7d6eda
+  type(typeWithPointer), target:: cyclicp1,cyclicp2
7d6eda
 
7d6eda
   logical, pointer :: logp
7d6eda
   complex, pointer :: comp
7d6eda
-  character, pointer :: charp
7d6eda
-  character (len=3), pointer :: charap
7d6eda
+  character, pointer:: charp
7d6eda
+  character (len=3), pointer:: charap
7d6eda
   integer, pointer :: intp
7d6eda
   integer, pointer, dimension (:,:) :: intap
7d6eda
+  integer, pointer, dimension (:) :: intvlap
7d6eda
   real, pointer :: realp
7d6eda
   type(two), pointer :: twop
7d6eda
 
7d6eda
@@ -44,8 +57,14 @@ program pointers
7d6eda
   nullify (charap)
7d6eda
   nullify (intp)
7d6eda
   nullify (intap)
7d6eda
+  nullify (intvlap)
7d6eda
   nullify (realp)
7d6eda
   nullify (twop)
7d6eda
+  nullify (arrayOfPtr(1)%p)
7d6eda
+  nullify (arrayOfPtr(2)%p)
7d6eda
+  nullify (arrayOfPtr(3)%p)
7d6eda
+  nullify (cyclicp1%p)
7d6eda
+  nullify (cyclicp2%p)
7d6eda
 
7d6eda
   logp => logv    ! Before pointer assignment
7d6eda
   comp => comv
7d6eda
@@ -53,8 +72,14 @@ program pointers
7d6eda
   charap => chara
7d6eda
   intp => intv
7d6eda
   intap => inta
7d6eda
+  intvlap => intvla
7d6eda
   realp => realv
7d6eda
   twop => twov
7d6eda
+  arrayOfPtr(2)%p => twov
7d6eda
+  cyclicp1%i = 1
7d6eda
+  cyclicp1%p => cyclicp2
7d6eda
+  cyclicp2%i = 2
7d6eda
+  cyclicp2%p => cyclicp1
7d6eda
 
7d6eda
   logv = associated(logp)     ! Before value assignment
7d6eda
   comv = cmplx(1,2)
7d6eda
@@ -63,6 +88,10 @@ program pointers
7d6eda
   intv = 10
7d6eda
   inta(:,:) = 1
7d6eda
   inta(3,1) = 3
7d6eda
+  allocate (intvla(10))
7d6eda
+  intvla(:) = 2
7d6eda
+  intvla(4) = 4
7d6eda
+  intvlap => intvla
7d6eda
   realv = 3.14
7d6eda
 
7d6eda
   allocate (twov%ivla1(3))
7d6eda
diff --git a/gdb/testsuite/gdb.fortran/print_type.exp b/gdb/testsuite/gdb.fortran/print_type.exp
7d6eda
--- a/gdb/testsuite/gdb.fortran/print_type.exp
7d6eda
+++ b/gdb/testsuite/gdb.fortran/print_type.exp
7d6eda
@@ -1,5 +1,6 @@
7d6eda
 # Copyright 2019-2020 Free Software Foundation, Inc.
7d6eda
 #
7d6eda
+
7d6eda
 # This program is free software; you can redistribute it and/or modify
7d6eda
 # it under the terms of the GNU General Public License as published by
7d6eda
 # the Free Software Foundation; either version 3 of the License, or
7d6eda
@@ -40,7 +41,7 @@ set complex [fortran_complex4]
7d6eda
 # matches the string TYPE.
7d6eda
 proc check_pointer_type { var_name type } {
7d6eda
     gdb_test "ptype ${var_name}" \
7d6eda
-	"type = PTR TO -> \\( ${type} \\)"
7d6eda
+	"type = PTR TO -> \\( ${type}\\)"
7d6eda
 }
7d6eda
 
7d6eda
 gdb_breakpoint [gdb_get_line_number "Before pointer assignment"]
7d6eda
@@ -85,7 +86,8 @@ gdb_test "ptype twop" \
7d6eda
     [multi_line "type = PTR TO -> \\( Type two" \
7d6eda
                 "    $int, allocatable :: ivla1\\(:\\)" \
7d6eda
                 "    $int, allocatable :: ivla2\\(:,:\\)" \
7d6eda
-                "End Type two \\)"]
7d6eda
+                "End Type two\\)"]
7d6eda
+
7d6eda
 
7d6eda
 gdb_breakpoint [gdb_get_line_number "After value assignment"]
7d6eda
 gdb_continue_to_breakpoint "After value assignment"
7d6eda
@@ -97,11 +99,11 @@ gdb_test "ptype intv" "type = $int"
7d6eda
 gdb_test "ptype inta" "type = $int \\(10,2\\)"
7d6eda
 gdb_test "ptype realv" "type = $real"
7d6eda
 
7d6eda
-gdb_test "ptype logp" "type = PTR TO -> \\( $logical \\)"
7d6eda
-gdb_test "ptype comp" "type = PTR TO -> \\( $complex \\)"
7d6eda
-gdb_test "ptype charp" "type = PTR TO -> \\( character\\*1 \\)"
7d6eda
-gdb_test "ptype charap" "type = PTR TO -> \\( character\\*3 \\)"
7d6eda
-gdb_test "ptype intp" "type = PTR TO -> \\( $int \\)"
7d6eda
+gdb_test "ptype logp" "type = PTR TO -> \\( $logical\\)"
7d6eda
+gdb_test "ptype comp" "type = PTR TO -> \\( $complex\\)"
7d6eda
+gdb_test "ptype charp" "type = PTR TO -> \\( character\\*1\\)"
7d6eda
+gdb_test "ptype charap" "type = PTR TO -> \\( character\\*3\\)"
7d6eda
+gdb_test "ptype intp" "type = PTR TO -> \\( $int\\)"
7d6eda
 set test "ptype intap"
7d6eda
 gdb_test_multiple $test $test {
7d6eda
     -re "type = $int \\(10,2\\)\r\n$gdb_prompt $" {
7d6eda
@@ -111,4 +113,4 @@ gdb_test_multiple $test $test {
7d6eda
         pass $test
7d6eda
     }
7d6eda
 }
7d6eda
-gdb_test "ptype realp" "type = PTR TO -> \\( $real \\)"
7d6eda
+gdb_test "ptype realp" "type = PTR TO -> \\( $real\\)"
7d6eda
diff --git a/gdb/testsuite/gdb.fortran/vla-strings.exp b/gdb/testsuite/gdb.fortran/vla-strings.exp
7d6eda
new file mode 100644
7d6eda
--- /dev/null
7d6eda
+++ b/gdb/testsuite/gdb.fortran/vla-strings.exp
7d6eda
@@ -0,0 +1,103 @@
7d6eda
+# Copyright 2016 Free Software Foundation, Inc.
7d6eda
+
7d6eda
+# This program is free software; you can redistribute it and/or modify
7d6eda
+# it under the terms of the GNU General Public License as published by
7d6eda
+# the Free Software Foundation; either version 3 of the License, or
7d6eda
+# (at your option) any later version.
7d6eda
+#
7d6eda
+# This program is distributed in the hope that it will be useful,
7d6eda
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
7d6eda
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
7d6eda
+# GNU General Public License for more details.
7d6eda
+#
7d6eda
+# You should have received a copy of the GNU General Public License
7d6eda
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
7d6eda
+
7d6eda
+standard_testfile ".f90"
7d6eda
+
7d6eda
+if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
7d6eda
+    {debug f90 quiet}] } {
7d6eda
+    return -1
7d6eda
+}
7d6eda
+
7d6eda
+# check that all fortran standard datatypes will be
7d6eda
+# handled correctly when using as VLA's
7d6eda
+
7d6eda
+if ![runto_main] {
7d6eda
+    untested "could not run to main"
7d6eda
+    return -1
7d6eda
+}
7d6eda
+
7d6eda
+gdb_breakpoint [gdb_get_line_number "var_char-allocated-1"]
7d6eda
+gdb_continue_to_breakpoint "var_char-allocated-1"
7d6eda
+set test "whatis var_char first time"
7d6eda
+gdb_test_multiple "whatis var_char" $test {
7d6eda
+    -re "type = PTR TO -> \\( character\\*10\\)\r\n$gdb_prompt $" {
7d6eda
+	    pass $test
7d6eda
+    }
7d6eda
+    -re "type = character\\*10\r\n$gdb_prompt $" {
7d6eda
+	    pass $test
7d6eda
+    }
7d6eda
+}
7d6eda
+set test "ptype var_char first time"
7d6eda
+gdb_test_multiple "ptype var_char" $test {
7d6eda
+    -re "type = PTR TO -> \\( character\\*10\\)\r\n$gdb_prompt $" {
7d6eda
+	    pass $test
7d6eda
+    }
7d6eda
+    -re "type = character\\*10\r\n$gdb_prompt $" {
7d6eda
+	    pass $test
7d6eda
+    }
7d6eda
+}
7d6eda
+
7d6eda
+
7d6eda
+gdb_test "next" "\\d+.*var_char = 'foo'.*" \
7d6eda
+  "next to allocation status of var_char"
7d6eda
+gdb_test "print l" " = \\.TRUE\\." "print allocation status first time"
7d6eda
+
7d6eda
+
7d6eda
+gdb_breakpoint [gdb_get_line_number "var_char-filled-1"]
7d6eda
+gdb_continue_to_breakpoint "var_char-filled-1"
7d6eda
+set test "print var_char, var_char-filled-1"
7d6eda
+gdb_test_multiple "print var_char" $test {
7d6eda
+    -re "= \\(PTR TO -> \\( character\\*3\\)\\) $hex\r\n$gdb_prompt $" {
7d6eda
+        gdb_test "print *var_char" "= 'foo'" "print *var_char, var_char-filled-1"
7d6eda
+	    pass $test
7d6eda
+    }
7d6eda
+    -re "= 'foo'\r\n$gdb_prompt $" {
7d6eda
+	    pass $test
7d6eda
+    }
7d6eda
+}
7d6eda
+set test "ptype var_char, var_char-filled-1"
7d6eda
+gdb_test_multiple "ptype var_char" $test {
7d6eda
+    -re "type = PTR TO -> \\( character\\*3\\)\r\n$gdb_prompt $" {
7d6eda
+	    pass $test
7d6eda
+    }
7d6eda
+    -re "type = character\\*3\r\n$gdb_prompt $" {
7d6eda
+	    pass $test
7d6eda
+    }
7d6eda
+}
7d6eda
+gdb_test "print var_char(1)" " = 102 'f'" "print var_char(1)"
7d6eda
+gdb_test "print var_char(3)" " = 111 'o'" "print var_char(3)"
7d6eda
+
7d6eda
+
7d6eda
+gdb_breakpoint [gdb_get_line_number "var_char-filled-2"]
7d6eda
+gdb_continue_to_breakpoint "var_char-filled-2"
7d6eda
+set test "print var_char, var_char-filled-2"
7d6eda
+gdb_test_multiple "print var_char" $test {
7d6eda
+    -re "= \\(PTR TO -> \\( character\\*6\\)\\) $hex\r\n$gdb_prompt $" {
7d6eda
+        gdb_test "print *var_char" "= 'foobar'" "print *var_char, var_char-filled-2"
7d6eda
+	    pass $test
7d6eda
+    }
7d6eda
+    -re "= 'foobar'\r\n$gdb_prompt $" {
7d6eda
+	    pass $test
7d6eda
+    }
7d6eda
+}
7d6eda
+set test "ptype var_char, var_char-filled-2"
7d6eda
+gdb_test_multiple "ptype var_char" $test {
7d6eda
+    -re "type = PTR TO -> \\( character\\*6\\)\r\n$gdb_prompt $" {
7d6eda
+	    pass $test
7d6eda
+    }
7d6eda
+    -re "type = character\\*6\r\n$gdb_prompt $" {
7d6eda
+	    pass $test
7d6eda
+    }
7d6eda
+}
7d6eda
diff --git a/gdb/testsuite/gdb.fortran/vla-strings.f90 b/gdb/testsuite/gdb.fortran/vla-strings.f90
7d6eda
new file mode 100644
7d6eda
--- /dev/null
7d6eda
+++ b/gdb/testsuite/gdb.fortran/vla-strings.f90
7d6eda
@@ -0,0 +1,39 @@
7d6eda
+! Copyright 2016 Free Software Foundation, Inc.
7d6eda
+!
7d6eda
+! This program is free software; you can redistribute it and/or modify
7d6eda
+! it under the terms of the GNU General Public License as published by
7d6eda
+! the Free Software Foundation; either version 3 of the License, or
7d6eda
+! (at your option) any later version.
7d6eda
+!
7d6eda
+! This program is distributed in the hope that it will be useful,
7d6eda
+! but WITHOUT ANY WARRANTY; without even the implied warranty of
7d6eda
+! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
7d6eda
+! GNU General Public License for more details.
7d6eda
+!
7d6eda
+! You should have received a copy of the GNU General Public License
7d6eda
+! along with this program.  If not, see <http://www.gnu.org/licenses/>.
7d6eda
+
7d6eda
+program vla_strings
7d6eda
+  character(len=:), target, allocatable   :: var_char
7d6eda
+  character(len=:), pointer               :: var_char_p
7d6eda
+  logical                                 :: l
7d6eda
+
7d6eda
+  allocate(character(len=10) :: var_char)
7d6eda
+  l = allocated(var_char)                 ! var_char-allocated-1
7d6eda
+  var_char = 'foo'
7d6eda
+  deallocate(var_char)                    ! var_char-filled-1
7d6eda
+  l = allocated(var_char)                 ! var_char-deallocated
7d6eda
+  allocate(character(len=42) :: var_char)
7d6eda
+  l = allocated(var_char)
7d6eda
+  var_char = 'foobar'
7d6eda
+  var_char = ''                           ! var_char-filled-2
7d6eda
+  var_char = 'bar'                        ! var_char-empty
7d6eda
+  deallocate(var_char)
7d6eda
+  allocate(character(len=21) :: var_char)
7d6eda
+  l = allocated(var_char)                 ! var_char-allocated-3
7d6eda
+  var_char = 'johndoe'
7d6eda
+  var_char_p => var_char
7d6eda
+  l = associated(var_char_p)              ! var_char_p-associated
7d6eda
+  var_char_p => null()
7d6eda
+  l = associated(var_char_p)              ! var_char_p-not-associated
7d6eda
+end program vla_strings
7d6eda
diff --git a/gdb/testsuite/gdb.fortran/vla-value.exp b/gdb/testsuite/gdb.fortran/vla-value.exp
7d6eda
--- a/gdb/testsuite/gdb.fortran/vla-value.exp
7d6eda
+++ b/gdb/testsuite/gdb.fortran/vla-value.exp
7d6eda
@@ -35,7 +35,7 @@ gdb_breakpoint [gdb_get_line_number "vla1-init"]
7d6eda
 gdb_continue_to_breakpoint "vla1-init"
7d6eda
 gdb_test "print vla1" " = <not allocated>" "print non-allocated vla1"
7d6eda
 gdb_test "print &vla1" \
7d6eda
-  " = \\\(PTR TO -> \\\( $real, allocatable \\\(:,:,:\\\) \\\)\\\) $hex" \
7d6eda
+  " = \\\(PTR TO -> \\\( $real, allocatable \\\(:,:,:\\\)\\\)\\\) $hex" \
7d6eda
   "print non-allocated &vla1"
7d6eda
 gdb_test "print vla1(1,1,1)" "no such vector element \\\(vector not allocated\\\)" \
7d6eda
   "print member in non-allocated vla1 (1)"
7d6eda
@@ -56,7 +56,7 @@ with_timeout_factor 15 {
7d6eda
 	"step over value assignment of vla1"
7d6eda
 }
7d6eda
 gdb_test "print &vla1" \
7d6eda
-  " = \\\(PTR TO -> \\\( $real, allocatable \\\(10,10,10\\\) \\\)\\\) $hex" \
7d6eda
+  " = \\\(PTR TO -> \\\( $real, allocatable \\\(10,10,10\\\)\\\)\\\) $hex" \
7d6eda
   "print allocated &vla1"
7d6eda
 gdb_test "print vla1(3, 6, 9)" " = 1311" "print allocated vla1(3,6,9)"
7d6eda
 gdb_test "print vla1(1, 3, 8)" " = 1311" "print allocated vla1(1,3,8)"
7d6eda
@@ -76,7 +76,7 @@ gdb_test "print vla1(9, 9, 9)" " = 999" \
7d6eda
 # Try to access values in undefined pointer to VLA (dangling)
7d6eda
 gdb_test "print pvla" " = <not associated>" "print undefined pvla"
7d6eda
 gdb_test "print &pvla" \
7d6eda
-  " = \\\(PTR TO -> \\\( $real \\\(:,:,:\\\) \\\)\\\) $hex" \
7d6eda
+  " = \\\(PTR TO -> \\\( $real \\\(:,:,:\\\)\\\)\\\) $hex" \
7d6eda
   "print non-associated &pvla"
7d6eda
 gdb_test "print pvla(1, 3, 8)" "no such vector element \\\(vector not associated\\\)" \
7d6eda
   "print undefined pvla(1,3,8)"
7d6eda
@@ -85,7 +85,7 @@ gdb_test "print pvla(1, 3, 8)" "no such vector element \\\(vector not associated
7d6eda
 gdb_breakpoint [gdb_get_line_number "pvla-associated"]
7d6eda
 gdb_continue_to_breakpoint "pvla-associated"
7d6eda
 gdb_test "print &pvla" \
7d6eda
-  " = \\\(PTR TO -> \\\( $real \\\(10,10,10\\\) \\\)\\\) $hex" \
7d6eda
+  " = \\\(PTR TO -> \\\( $real \\\(10,10,10\\\)\\\)\\\) $hex" \
7d6eda
   "print associated &pvla"
7d6eda
 gdb_test "print pvla(3, 6, 9)" " = 42" "print associated pvla(3,6,9)"
7d6eda
 gdb_test "print pvla(1, 3, 8)" " = 1001" "print associated pvla(1,3,8)"
7d6eda
diff --git a/gdb/typeprint.c b/gdb/typeprint.c
7d6eda
--- a/gdb/typeprint.c
7d6eda
+++ b/gdb/typeprint.c
7d6eda
@@ -574,6 +574,25 @@ whatis_exp (const char *exp, int show)
7d6eda
       printf_filtered (" */\n");    
7d6eda
     }
7d6eda
 
7d6eda
+  /* Resolve any dynamic target type, as we might print
7d6eda
+     additional information about the target.
7d6eda
+     For example, in Fortran and C we are printing the dimension of the
7d6eda
+     dynamic array the pointer is pointing to.  */
7d6eda
+  if (TYPE_CODE (type) == TYPE_CODE_PTR
7d6eda
+      && is_dynamic_type (type) == 1)
7d6eda
+    {
7d6eda
+      CORE_ADDR addr;
7d6eda
+      if (NULL != TYPE_DATA_LOCATION (TYPE_TARGET_TYPE(type)))
7d6eda
+	addr = value_address (val);
7d6eda
+      else
7d6eda
+	addr = value_as_address (val);
7d6eda
+
7d6eda
+      if (addr != 0
7d6eda
+	  && type_not_associated (type) == 0)
7d6eda
+	TYPE_TARGET_TYPE (type) = resolve_dynamic_type (TYPE_TARGET_TYPE (type),
7d6eda
+							NULL, addr);
7d6eda
+    }
7d6eda
+
7d6eda
   LA_PRINT_TYPE (type, "", gdb_stdout, show, 0, &flags);
7d6eda
   printf_filtered ("\n");
7d6eda
 }
7d6eda
diff --git a/gdb/valops.c b/gdb/valops.c
7d6eda
--- a/gdb/valops.c
7d6eda
+++ b/gdb/valops.c
7d6eda
@@ -1553,6 +1553,19 @@ value_ind (struct value *arg1)
7d6eda
   if (TYPE_CODE (base_type) == TYPE_CODE_PTR)
7d6eda
     {
7d6eda
       struct type *enc_type;
7d6eda
+      CORE_ADDR addr;
7d6eda
+
7d6eda
+      if (type_not_associated (base_type))
7d6eda
+        error (_("Attempt to take contents of a not associated pointer."));
7d6eda
+
7d6eda
+      if (NULL != TYPE_DATA_LOCATION (TYPE_TARGET_TYPE (base_type)))
7d6eda
+	addr = value_address (arg1);
7d6eda
+      else
7d6eda
+	addr = value_as_address (arg1);
7d6eda
+
7d6eda
+      if (addr != 0)
7d6eda
+	TYPE_TARGET_TYPE (base_type) =
7d6eda
+	    resolve_dynamic_type (TYPE_TARGET_TYPE (base_type), NULL, addr);
7d6eda
 
7d6eda
       /* We may be pointing to something embedded in a larger object.
7d6eda
          Get the real type of the enclosing object.  */
7d6eda
@@ -1568,8 +1581,7 @@ value_ind (struct value *arg1)
7d6eda
       else
7d6eda
 	/* Retrieve the enclosing object pointed to.  */
7d6eda
 	arg2 = value_at_lazy (enc_type, 
7d6eda
-			      (value_as_address (arg1)
7d6eda
-			       - value_pointed_to_offset (arg1)));
7d6eda
+			      (addr - value_pointed_to_offset (arg1)));
7d6eda
 
7d6eda
       enc_type = value_type (arg2);
7d6eda
       return readjust_indirect_value_type (arg2, enc_type, base_type, arg1);
7d6eda
diff --git a/gdb/valprint.c b/gdb/valprint.c
7d6eda
--- a/gdb/valprint.c
7d6eda
+++ b/gdb/valprint.c
7d6eda
@@ -1149,12 +1149,6 @@ value_check_printable (struct value *val, struct ui_file *stream,
7d6eda
       return 0;
7d6eda
     }
7d6eda
 
7d6eda
-  if (type_not_associated (value_type (val)))
7d6eda
-    {
7d6eda
-      val_print_not_associated (stream);
7d6eda
-      return 0;
7d6eda
-    }
7d6eda
-
7d6eda
   if (type_not_allocated (value_type (val)))
7d6eda
     {
7d6eda
       val_print_not_allocated (stream);