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

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