static struct type *
read_subrange_type (struct die_info *die, struct dwarf2_cu *cu)
{
- struct type *base_type;
+ struct type *base_type, *orig_base_type;
struct type *range_type;
struct attribute *attr;
LONGEST low, high;
const char *name;
LONGEST negative_mask;
- base_type = die_type (die, cu);
- /* Preserve BASE_TYPE's original type, just set its LENGTH. */
- check_typedef (base_type);
+ orig_base_type = die_type (die, cu);
+ /* If ORIG_BASE_TYPE is a typedef, it will not be TYPE_UNSIGNED,
+ whereas the real type might be. So, we use ORIG_BASE_TYPE when
+ creating the range type, but we use the result of check_typedef
+ when examining properties of the type. */
+ base_type = check_typedef (orig_base_type);
/* The die_type call above may have already set the type for this DIE. */
range_type = get_die_type (die, cu);
if (!TYPE_UNSIGNED (base_type) && (high & negative_mask))
high |= negative_mask;
- range_type = create_range_type (NULL, base_type, low, high);
+ range_type = create_range_type (NULL, orig_base_type, low, high);
/* Mark arrays with dynamic length at least as an array of unspecified
length. GDB could check the boundary but before it gets implemented at
\f
/* Macro support. */
-/* Return the full name of file number I in *LH's file name table.
- Use COMP_DIR as the name of the current directory of the
- compilation. The result is allocated using xmalloc; the caller is
+/* Return file name relative to the compilation directory of file number I in
+ *LH's file name table. The result is allocated using xmalloc; the caller is
responsible for freeing it. */
+
static char *
-file_full_name (int file, struct line_header *lh, const char *comp_dir)
+file_file_name (int file, struct line_header *lh)
{
/* Is the file number a valid index into the line header's file name
table? Remember that file numbers start with one, not zero. */
{
struct file_entry *fe = &lh->file_names[file - 1];
- if (IS_ABSOLUTE_PATH (fe->name))
+ if (IS_ABSOLUTE_PATH (fe->name) || fe->dir_index == 0)
return xstrdup (fe->name);
- else
- {
- const char *dir;
-
- if (fe->dir_index == 0)
- dir = comp_dir;
- else
- {
- dir = lh->include_dirs[fe->dir_index - 1];
- if (!IS_ABSOLUTE_PATH (dir))
- return concat (comp_dir, SLASH_STRING, dir, SLASH_STRING,
- fe->name, NULL);
- }
-
- if (dir)
- return concat (dir, SLASH_STRING, fe->name, NULL);
- else
- return xstrdup (fe->name);
- }
+ return concat (lh->include_dirs[fe->dir_index - 1], SLASH_STRING,
+ fe->name, NULL);
}
else
{
}
}
+/* Return the full name of file number I in *LH's file name table.
+ Use COMP_DIR as the name of the current directory of the
+ compilation. The result is allocated using xmalloc; the caller is
+ responsible for freeing it. */
+static char *
+file_full_name (int file, struct line_header *lh, const char *comp_dir)
+{
+ /* Is the file number a valid index into the line header's file name
+ table? Remember that file numbers start with one, not zero. */
+ if (1 <= file && file <= lh->num_file_names)
+ {
+ char *relative = file_file_name (file, lh);
+
+ if (IS_ABSOLUTE_PATH (relative) || comp_dir == NULL)
+ return relative;
+ return reconcat (relative, comp_dir, SLASH_STRING, relative, NULL);
+ }
+ else
+ return file_file_name (file, lh);
+}
+
static struct macro_source_file *
macro_start_file (int file, int line,
const char *comp_dir,
struct line_header *lh, struct objfile *objfile)
{
- /* The full name of this source file. */
- char *full_name = file_full_name (file, lh, comp_dir);
+ /* File name relative to the compilation directory of this source file. */
+ char *file_name = file_file_name (file, lh);
/* We don't create a macro table for this compilation unit
at all until we actually get a filename. */
if (! pending_macros)
pending_macros = new_macro_table (&objfile->per_bfd->storage_obstack,
- objfile->per_bfd->macro_cache);
+ objfile->per_bfd->macro_cache,
+ comp_dir);
if (! current_file)
{
/* If we have no current file, then this must be the start_file
directive for the compilation unit's main source file. */
- current_file = macro_set_main (pending_macros, full_name);
+ current_file = macro_set_main (pending_macros, file_name);
macro_define_special (pending_macros);
}
else
- current_file = macro_include (current_file, line, full_name);
+ current_file = macro_include (current_file, line, file_name);
- xfree (full_name);
+ xfree (file_name);
return current_file;
}