diff options
author | Nathan Sidwell <nathan@acm.org> | 1999-01-16 16:31:12 +0000 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 1999-01-16 11:31:12 -0500 |
commit | a7a7710d423cba8feb795c3e626df5ce4075cebb (patch) | |
tree | 8f9d4e6c38db1bc57ed11c767e476cf0f914efb7 /gcc | |
parent | 854b494a9ef17692e2daabf8fa0c478161becd41 (diff) | |
download | gcc-a7a7710d423cba8feb795c3e626df5ce4075cebb.zip gcc-a7a7710d423cba8feb795c3e626df5ce4075cebb.tar.gz gcc-a7a7710d423cba8feb795c3e626df5ce4075cebb.tar.bz2 |
cp-tree.h (struct lang_type): Added has_mutable flag.
* cp-tree.h (struct lang_type): Added has_mutable flag.
(CLASSTYPE_HAS_MUTABLE): New macro to access it.
(TYPE_HAS_MUTABLE_P): New macro to read it.
(cp_has_mutable_p): Prototype for new function.
* class.c (finish_struct_1): Set has_mutable from members.
* decl.c (cp_finish_decl): Clear decl's TREE_READONLY flag, if
it contains a mutable.
* typeck.c (cp_has_mutable_p): New function.
Fixes g++.other/mutable1.C
From-SVN: r24701
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 11 | ||||
-rw-r--r-- | gcc/cp/class.c | 5 | ||||
-rw-r--r-- | gcc/cp/cp-tree.h | 8 | ||||
-rw-r--r-- | gcc/cp/decl.c | 3 | ||||
-rw-r--r-- | gcc/cp/typeck.c | 12 |
5 files changed, 38 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index c0daba4..32f5df1 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,14 @@ +1999-01-16 Nathan Sidwell <nathan@acm.org> + + * cp-tree.h (struct lang_type): Added has_mutable flag. + (CLASSTYPE_HAS_MUTABLE): New macro to access it. + (TYPE_HAS_MUTABLE_P): New macro to read it. + (cp_has_mutable_p): Prototype for new function. + * class.c (finish_struct_1): Set has_mutable from members. + * decl.c (cp_finish_decl): Clear decl's TREE_READONLY flag, if + it contains a mutable. + * typeck.c (cp_has_mutable_p): New function. + 1999-01-15 Mark Mitchell <mark@markmitchell.com> * pt.c (process_template_parm): Ignore top-level qualifiers on diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 694ac0b..1688e02 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -3316,6 +3316,7 @@ finish_struct_1 (t, warn_anon) int cant_have_default_ctor; int cant_have_const_ctor; int no_const_asn_ref; + int has_mutable = 0; /* The index of the first base class which has virtual functions. Only applied to non-virtual baseclasses. */ @@ -3578,6 +3579,9 @@ finish_struct_1 (t, warn_anon) if (TREE_CODE (TREE_TYPE (x)) == POINTER_TYPE) has_pointers = 1; + if (DECL_MUTABLE_P (x) || TYPE_HAS_MUTABLE_P (TREE_TYPE (x))) + has_mutable = 1; + /* If any field is const, the structure type is pseudo-const. */ if (TREE_READONLY (x)) { @@ -3794,6 +3798,7 @@ finish_struct_1 (t, warn_anon) CLASSTYPE_READONLY_FIELDS_NEED_INIT (t) = const_sans_init; CLASSTYPE_REF_FIELDS_NEED_INIT (t) = ref_sans_init; CLASSTYPE_ABSTRACT_VIRTUALS (t) = abstract_virtuals; + CLASSTYPE_HAS_MUTABLE (t) = has_mutable; /* Effective C++ rule 11. */ if (has_pointers && warn_ecpp && TYPE_HAS_CONSTRUCTOR (t) diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index fccfba5..fb80e38 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -726,11 +726,12 @@ struct lang_type unsigned has_abstract_assign_ref : 1; unsigned non_aggregate : 1; unsigned is_partial_instantiation : 1; + unsigned has_mutable : 1; /* The MIPS compiler gets it wrong if this struct also does not fill out to a multiple of 4 bytes. Add a member `dummy' with new bits if you go over the edge. */ - unsigned dummy : 11; + unsigned dummy : 10; } type_flags; int n_ancestors; @@ -1037,6 +1038,10 @@ struct lang_type /* Ditto, for operator=. */ #define TYPE_HAS_NONPUBLIC_ASSIGN_REF(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.has_nonpublic_assign_ref) +/* Nonzero means that this type contains a mutable member */ +#define CLASSTYPE_HAS_MUTABLE(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.has_mutable) +#define TYPE_HAS_MUTABLE_P(NODE) (cp_has_mutable_p (NODE)) + /* Many routines need to cons up a list of basetypes for access checking. This field contains a TREE_LIST node whose TREE_VALUE is the main variant of the type, and whose TREE_VIA_PUBLIC @@ -3372,6 +3377,7 @@ extern int comp_ptr_ttypes PROTO((tree, tree)); extern int ptr_reasonably_similar PROTO((tree, tree)); extern tree build_ptrmemfunc PROTO((tree, tree, int)); extern int cp_type_quals PROTO((tree)); +extern int cp_has_mutable_p PROTO((tree)); extern int at_least_as_qualified_p PROTO((tree, tree)); extern int more_qualified_p PROTO((tree, tree)); diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 5e603b6..b15cec5 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -7369,6 +7369,9 @@ cp_finish_decl (decl, init, asmspec_tree, need_pop, flags) return; } + if (TYPE_HAS_MUTABLE_P (type)) + TREE_READONLY (decl) = 0; + if (processing_template_decl) { if (init && DECL_INITIAL (decl)) diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 6034ce3..4fb4f59 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -7471,3 +7471,15 @@ cp_type_quals (type) return TYPE_QUALS (type); } + +/* Returns non-zero if the TYPE contains a mutable member */ + +int +cp_has_mutable_p (type) + tree type; +{ + while (TREE_CODE (type) == ARRAY_TYPE) + type = TREE_TYPE (type); + + return CLASS_TYPE_P (type) && CLASSTYPE_HAS_MUTABLE (type); +} |