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

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