+2021-02-09  Tom de Vries  <tdevries@suse.de>
+
+       PR symtab/27341
+       * dwarf2/read.c (read_array_type): Return NULL when not being able to
+       construct an array type.  Add assert to ensure that element_type is
+       not being modified.
+
 2021-02-09  Andrew Burgess  <andrew.burgess@embecosm.com>
 
        * gcore.c (struct gcore_collect_regset_section_cb_data): Delete.
 
       child_die = child_die->sibling;
     }
 
+  if (range_types.empty ())
+    {
+      complaint (_("unable to find array range - DIE at %s [in module %s]"),
+                sect_offset_str (die->sect_off),
+                objfile_name (cu->per_objfile->objfile));
+      return NULL;
+    }
+
   /* Dwarf2 dimensions are output from left to right, create the
      necessary array types in backwards order.  */
 
        }
     }
 
+  gdb_assert (type != element_type);
+
   /* Understand Dwarf2 support for vector types (like they occur on
      the PowerPC w/ AltiVec).  Gcc just adds another attribute to the
      array type.  This is not part of the Dwarf2/3 standard yet, but a
 
+2021-02-09  Tom de Vries  <tdevries@suse.de>
+
+       PR symtab/27341
+       * lib/gdb.exp (with_complaints): New proc, factored out of ...
+       (gdb_load_no_complaints): ... here.
+       * gdb.fortran/function-calls.exp: Add test-case.
+
 2021-02-09  Abid Qadeer  <abidh@codesourcery.com>
 
        * gdb.threads/signal-command-handle-nopass.exp: Call
 
     return -1
 }
 
+with_complaints 5 {
+    set cmd "maint expand-symtabs $srcfile"
+    set cmd_regexp [string_to_regexp $cmd]
+    set re_kfail [concat "During symbol reading:" \
+                     " unable to find array range"]
+    gdb_test_multiple $cmd "no complaints in srcfile" {
+       -re -wrap "$re_kfail.*" {
+           kfail symtab/27388 $gdb_test_name
+       }
+        -re "^$cmd_regexp\r\n$gdb_prompt $" {
+           pass $gdb_test_name
+       }
+    }
+}
+
 if {![runto [gdb_get_line_number "post_init"]]} then {
     perror "couldn't run to breakpoint post_init"
     continue
 
 }
 
 #
-# gdb_load_no_complaints -- As gdb_load, but in addition verifies that
-# loading caused no symbol reading complaints.
+# with_complaints -- Execute BODY and set complaints temporary to N for the
+# duration.
 #
-proc gdb_load_no_complaints { arg } {
-    global gdb_prompt gdb_file_cmd_msg decimal
+proc with_complaints { n body } {
+    global decimal
 
     # Save current setting of complaints.
     set save ""
        }
     }
 
-    # Fall back to regular gdb_load if we couldn't get the current setting
-    # of complaints.
     if { $save == "" } {
-       return gdb_load $arg
+       perror "Did not manage to set complaints"
+    } else {
+       # Set complaints.
+       gdb_test_no_output "set complaints $n" ""
     }
 
-    # Temporarily set complaint to a small non-zero number.
-    gdb_test_no_output "set complaints 5" ""
+    set code [catch {uplevel 1 $body} result]
+
+    # Restore saved setting of complaints.
+    if { $save != "" } {
+       gdb_test_no_output "set complaints $save" ""
+    }
+
+    if {$code == 1} {
+       global errorInfo errorCode
+       return -code $code -errorinfo $errorInfo -errorcode $errorCode $result
+    } else {
+       return -code $code $result
+    }
+}
+
+#
+# gdb_load_no_complaints -- As gdb_load, but in addition verifies that
+# loading caused no symbol reading complaints.
+#
+proc gdb_load_no_complaints { arg } {
+    global gdb_prompt gdb_file_cmd_msg decimal
 
-    gdb_load $arg
+    # Temporarily set complaint to a small non-zero number.
+    with_complaints 5 {
+       gdb_load $arg
+    }
 
     # Verify that there were no complaints.
     set re "^Reading symbols from \[^\r\n\]*\r\n$gdb_prompt $"