diff options
author | Daniel Jacobowitz <drow@false.org> | 2001-12-07 22:11:51 +0000 |
---|---|---|
committer | Daniel Jacobowitz <drow@false.org> | 2001-12-07 22:11:51 +0000 |
commit | a02fd225edb13af1ba10ec58d3795b7572b46e54 (patch) | |
tree | 4a915d746f05e37c30638ef7f03ef501b9a01860 /gdb/gdbtypes.c | |
parent | 5178b9d60203ce67999ecad2fc5ba8a2b7b363db (diff) | |
download | fsf-binutils-gdb-a02fd225edb13af1ba10ec58d3795b7572b46e54.zip fsf-binutils-gdb-a02fd225edb13af1ba10ec58d3795b7572b46e54.tar.gz fsf-binutils-gdb-a02fd225edb13af1ba10ec58d3795b7572b46e54.tar.bz2 |
* gdbtypes.c (finish_cv_type): New function.
(check_typedef): Remove ``register'' keyword from argument.
Preserve const and volatile attributes across filling in
opaque types.
* gdbtypes.h (finish_cv_type): Add prototype.
* hp-symtab-read.c (hpread_read_struct_type): Call finish_cv_type.
* stabsread.c (read_struct_type): Likewise.
* dwarf2read.c (read_structure_scope): Likewise. Remove redundant
assignment to die->type.
Diffstat (limited to 'gdb/gdbtypes.c')
-rw-r--r-- | gdb/gdbtypes.c | 59 |
1 files changed, 52 insertions, 7 deletions
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index 8a941de..6a8fe1f 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -36,6 +36,7 @@ #include "gdbcmd.h" #include "wrapper.h" #include "cp-abi.h" +#include "gdb_assert.h" /* These variables point to the objects representing the predefined C data types. */ @@ -469,8 +470,51 @@ make_cv_type (int cnst, int voltl, struct type *type, struct type **typeptr) return ntype; } +/* When reading in a class type, we may have created references to + cv-qualified versions of the type (in method arguments, for + instance). Update everything on the cv ring from the primary + type TYPE. + The only reason we do not need to do the same thing for address + spaces is that type readers do not create address space qualified + types. */ +void +finish_cv_type (struct type *type) +{ + struct type *ntype, *cv_type, *ptr_type, *ref_type; + int cv_flags; + + gdb_assert (!TYPE_CONST (type) && !TYPE_VOLATILE (type)); + + ntype = type; + while ((ntype = TYPE_CV_TYPE (ntype)) != type) + { + /* Save cv_flags. */ + cv_flags = TYPE_FLAGS (ntype) & (TYPE_FLAG_VOLATILE | TYPE_FLAG_CONST); + + /* If any reference or pointer types were created, save them too. */ + ptr_type = TYPE_POINTER_TYPE (ntype); + ref_type = TYPE_REFERENCE_TYPE (ntype); + + /* Don't disturb the CV chain. */ + cv_type = TYPE_CV_TYPE (ntype); + + /* Verify that we haven't added any address-space qualified types, + for the future. */ + gdb_assert (ntype == TYPE_AS_TYPE (ntype)); + + /* Copy original type */ + memcpy ((char *) ntype, (char *) type, sizeof (struct type)); + /* Restore everything. */ + TYPE_POINTER_TYPE (ntype) = ptr_type; + TYPE_REFERENCE_TYPE (ntype) = ref_type; + TYPE_CV_TYPE (ntype) = cv_type; + TYPE_FLAGS (ntype) = TYPE_FLAGS (ntype) | cv_flags; + + TYPE_AS_TYPE (ntype) = ntype; + } +} /* Implement direct support for MEMBER_TYPE in GNU C++. May need to construct such a type if this is the first use. @@ -1144,9 +1188,11 @@ struct complaint stub_noname_complaint = {"stub type has NULL name", 0, 0}; struct type * -check_typedef (register struct type *type) +check_typedef (struct type *type) { struct type *orig_type = type; + int is_const, is_volatile; + while (TYPE_CODE (type) == TYPE_CODE_TYPEDEF) { if (!TYPE_TARGET_TYPE (type)) @@ -1179,6 +1225,9 @@ check_typedef (register struct type *type) type = TYPE_TARGET_TYPE (type); } + is_const = TYPE_CONST (type); + is_volatile = TYPE_VOLATILE (type); + /* If this is a struct/class/union with no fields, then check whether a full definition exists somewhere else. This is for systems where a type definition with no fields is issued for such types, instead of @@ -1195,9 +1244,7 @@ check_typedef (register struct type *type) } newtype = lookup_transparent_type (name); if (newtype) - { - memcpy ((char *) type, (char *) newtype, sizeof (struct type)); - } + make_cv_type (is_const, is_volatile, newtype, &type); } /* Otherwise, rely on the stub flag being set for opaque/stubbed types */ else if ((TYPE_FLAGS (type) & TYPE_FLAG_STUB) && !currently_reading_symtab) @@ -1215,9 +1262,7 @@ check_typedef (register struct type *type) } sym = lookup_symbol (name, 0, STRUCT_NAMESPACE, 0, (struct symtab **) NULL); if (sym) - { - memcpy ((char *) type, (char *) SYMBOL_TYPE (sym), sizeof (struct type)); - } + make_cv_type (is_const, is_volatile, SYMBOL_TYPE (sym), &type); } if (TYPE_FLAGS (type) & TYPE_FLAG_TARGET_STUB) |