aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMark Mitchell <mark@codesourcery.com>2003-01-30 16:02:58 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>2003-01-30 16:02:58 +0000
commit5552b43ca5b26f94760cfb94f59cd6b5d60f1c7d (patch)
treed892f0dae664670d38fe018c10299cee82931af6 /gcc
parente43dd89d8061e68695c871f7f6b044012dfcd82b (diff)
downloadgcc-5552b43ca5b26f94760cfb94f59cd6b5d60f1c7d.zip
gcc-5552b43ca5b26f94760cfb94f59cd6b5d60f1c7d.tar.gz
gcc-5552b43ca5b26f94760cfb94f59cd6b5d60f1c7d.tar.bz2
class.c (check_field_decls): Only check C_TYPE_FIELDS_READONLY for class types.
* class.c (check_field_decls): Only check C_TYPE_FIELDS_READONLY for class types. * cp-tree.h (C_TYPE_FIELDS_READONLY): Use a lang-specific bit rather than TYPE_LANG_FLAG_0. (TYPE_BUILT_IN): Remove. (TYPE_DEPENDENT_P): New macro. (TYPE_DEPENDENT_P_VALID): Likewise. (lang_type_class): Add fields_readonly. * decl.c (record_builtin_type): Don't set TYPE_BUILT_IN. * pt.c (dependent_type_p_r): New function, split out from ... (dependent_type_p): ... here. Memoize results. * search.c (dependent_base_p): Use dependent_type_p, not uses_template_parms. * typeck.c (build_modify_expr): Only check C_TYPE_FIELDS_READONLY for class types. From-SVN: r62143
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog18
-rw-r--r--gcc/cp/class.c2
-rw-r--r--gcc/cp/cp-tree.h21
-rw-r--r--gcc/cp/decl.c2
-rw-r--r--gcc/cp/pt.c55
-rw-r--r--gcc/cp/search.c2
-rw-r--r--gcc/cp/typeck.c5
7 files changed, 72 insertions, 33 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 1b00808..5e6a99b 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,21 @@
+2003-01-30 Mark Mitchell <mark@codesourcery.com>
+
+ * class.c (check_field_decls): Only check C_TYPE_FIELDS_READONLY
+ for class types.
+ * cp-tree.h (C_TYPE_FIELDS_READONLY): Use a lang-specific bit
+ rather than TYPE_LANG_FLAG_0.
+ (TYPE_BUILT_IN): Remove.
+ (TYPE_DEPENDENT_P): New macro.
+ (TYPE_DEPENDENT_P_VALID): Likewise.
+ (lang_type_class): Add fields_readonly.
+ * decl.c (record_builtin_type): Don't set TYPE_BUILT_IN.
+ * pt.c (dependent_type_p_r): New function, split out from ...
+ (dependent_type_p): ... here. Memoize results.
+ * search.c (dependent_base_p): Use dependent_type_p, not
+ uses_template_parms.
+ * typeck.c (build_modify_expr): Only check C_TYPE_FIELDS_READONLY
+ for class types.
+
2003-01-29 Mark Mitchell <mark@codesourcery.com>
* call.c (build_field_call): Use build_new_op, not build_opfncall.
diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index 378c637..f1f831c 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -3413,7 +3413,7 @@ check_field_decls (tree t, tree *access_decls,
cp_warning_at ("non-static const member `%#D' in class without a constructor", x);
}
/* A field that is pseudo-const makes the structure likewise. */
- else if (IS_AGGR_TYPE (type))
+ else if (CLASS_TYPE_P (type))
{
C_TYPE_FIELDS_READONLY (t) |= C_TYPE_FIELDS_READONLY (type);
SET_CLASSTYPE_READONLY_FIELDS_NEED_INIT (t,
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index e8d8acf..087a1c0 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -82,13 +82,13 @@ struct diagnostic_context;
6: BINFO_ACCESS (in BINFO)
Usage of TYPE_LANG_FLAG_?:
- 0: C_TYPE_FIELDS_READONLY (in RECORD_TYPE or UNION_TYPE).
+ 0: TYPE_DEPENDENT_P
1: TYPE_HAS_CONSTRUCTOR.
2: TYPE_HAS_DESTRUCTOR.
3: TYPE_FOR_JAVA.
4: TYPE_HAS_NONTRIVIAL_DESTRUCTOR
5: IS_AGGR_TYPE.
- 6: TYPE_BUILT_IN.
+ 6: TYPE_DEPENDENT_P_VALID
Usage of DECL_LANG_FLAG_?:
0: DECL_ERROR_REPORTED (in VAR_DECL).
@@ -497,7 +497,8 @@ struct tree_srcloc GTY(())
TREE_LANG_FLAG_3 (NODE)
/* In a RECORD_TYPE or UNION_TYPE, nonzero if any component is read-only. */
-#define C_TYPE_FIELDS_READONLY(TYPE) TYPE_LANG_FLAG_0 (TYPE)
+#define C_TYPE_FIELDS_READONLY(TYPE) \
+ (LANG_TYPE_CLASS_CHECK (TYPE)->fields_readonly)
/* Store a value in that field. */
#define C_SET_EXP_ORIGINAL_CODE(EXP, CODE) \
@@ -1028,12 +1029,17 @@ enum languages { lang_c, lang_cplusplus, lang_java };
(CLASS_TYPE_P (T) || TREE_CODE (T) == ENUMERAL_TYPE)
#define IS_OVERLOAD_TYPE(T) TAGGED_TYPE_P (T)
-/* In a *_TYPE, nonzero means a built-in type. */
-#define TYPE_BUILT_IN(NODE) TYPE_LANG_FLAG_6 (NODE)
-
/* True if this a "Java" type, defined in 'extern "Java"'. */
#define TYPE_FOR_JAVA(NODE) TYPE_LANG_FLAG_3 (NODE)
+/* True if this type is dependent. This predicate is only valid if
+ TYPE_DEPENDENT_P_VALID is true. */
+#define TYPE_DEPENDENT_P(NODE) TYPE_LANG_FLAG_0 (NODE)
+
+/* True if dependent_type_p has been called for this type, with the
+ result that TYPE_DEPENDENT_P is valid. */
+#define TYPE_DEPENDENT_P_VALID(NODE) TYPE_LANG_FLAG_6(NODE)
+
/* Nonzero if this type is const-qualified. */
#define CP_TYPE_CONST_P(NODE) \
((cp_type_quals (NODE) & TYPE_QUAL_CONST) != 0)
@@ -1162,6 +1168,7 @@ struct lang_type_class GTY(())
unsigned non_zero_init : 1;
unsigned empty_p : 1;
+ unsigned fields_readonly : 1;
/* When adding a flag here, consider whether or not it ought to
apply to a template instance if it applies to the template. If
@@ -1170,7 +1177,7 @@ struct lang_type_class GTY(())
/* There are some bits left to fill out a 32-bit word. Keep track
of this by updating the size of this bitfield whenever you add or
remove a flag. */
- unsigned dummy : 6;
+ unsigned dummy : 5;
tree primary_base;
tree vfields;
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 9078da6..e02fdd2 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -6071,8 +6071,6 @@ record_builtin_type (enum rid rid_index,
if (name)
tname = get_identifier (name);
- TYPE_BUILT_IN (type) = 1;
-
if (tname)
{
tdecl = pushdecl (build_decl (TYPE_DECL, tname, type));
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 2429f7f..dc2a9e2 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -171,6 +171,7 @@ static void copy_default_args_to_explicit_spec PARAMS ((tree));
static int invalid_nontype_parm_type_p PARAMS ((tree, tsubst_flags_t));
static int eq_local_specializations (const void *, const void *);
static tree template_for_substitution (tree);
+static bool dependent_type_p_r (tree);
static bool dependent_template_id_p (tree, tree);
static tree tsubst (tree, tree, tsubst_flags_t, tree);
static tree tsubst_expr (tree, tree, tsubst_flags_t, tree);
@@ -11202,29 +11203,14 @@ invalid_nontype_parm_type_p (type, complain)
return 1;
}
-/* Returns TRUE if TYPE is dependent, in the sense of
- [temp.dep.type]. */
+/* Returns TRUE if TYPE is dependent, in the sense of [temp.dep.type].
+ Assumes that TYPE really is a type, and not the ERROR_MARK_NODE.*/
-bool
-dependent_type_p (type)
- tree type;
+static bool
+dependent_type_p_r (tree type)
{
tree scope;
- /* If there are no template parameters in scope, then there can't be
- any dependent types. */
- if (!processing_template_decl)
- return false;
-
- /* If the type is NULL, we have not computed a type for the entity
- in question; in that case, the type is dependent. */
- if (!type)
- return true;
-
- /* Erroneous types can be considered non-dependent. */
- if (type == error_mark_node)
- return false;
-
/* [temp.dep.type]
A type is dependent if it is:
@@ -11315,6 +11301,37 @@ dependent_type_p (type)
return false;
}
+/* Returns TRUE if TYPE is dependent, in the sense of
+ [temp.dep.type]. */
+
+bool
+dependent_type_p (tree type)
+{
+ /* If there are no template parameters in scope, then there can't be
+ any dependent types. */
+ if (!processing_template_decl)
+ return false;
+
+ /* If the type is NULL, we have not computed a type for the entity
+ in question; in that case, the type is dependent. */
+ if (!type)
+ return true;
+
+ /* Erroneous types can be considered non-dependent. */
+ if (type == error_mark_node)
+ return false;
+
+ /* If we have not already computed the appropriate value for TYPE,
+ do so now. */
+ if (!TYPE_DEPENDENT_P_VALID (type))
+ {
+ TYPE_DEPENDENT_P (type) = dependent_type_p_r (type);
+ TYPE_DEPENDENT_P_VALID (type) = 1;
+ }
+
+ return TYPE_DEPENDENT_P (type);
+}
+
/* Returns TRUE if the EXPRESSION is value-dependent. */
bool
diff --git a/gcc/cp/search.c b/gcc/cp/search.c
index cab3bbb..952c760 100644
--- a/gcc/cp/search.c
+++ b/gcc/cp/search.c
@@ -2417,7 +2417,7 @@ dependent_base_p (binfo)
{
if (currently_open_class (TREE_TYPE (binfo)))
break;
- if (uses_template_parms (TREE_TYPE (binfo)))
+ if (dependent_type_p (TREE_TYPE (binfo)))
return 1;
}
return 0;
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index 9d11262..37a07b6 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -5511,7 +5511,7 @@ build_modify_expr (lhs, modifycode, rhs)
|| TREE_CODE (TREE_TYPE (lhs)) == METHOD_TYPE
/* If it's an aggregate and any field is const, then it is
effectively const. */
- || (IS_AGGR_TYPE_CODE (TREE_CODE (lhstype))
+ || (CLASS_TYPE_P (lhstype)
&& C_TYPE_FIELDS_READONLY (lhstype))))
readonly_error (lhs, "assignment", 0);
@@ -6266,8 +6266,7 @@ c_expand_asm_operands (string, outputs, inputs, clobbers, vol, filename, line)
tree type = TREE_TYPE (o[i]);
if (type != error_mark_node
&& (CP_TYPE_CONST_P (type)
- || (IS_AGGR_TYPE_CODE (TREE_CODE (type))
- && C_TYPE_FIELDS_READONLY (type))))
+ || (CLASS_TYPE_P (type) && C_TYPE_FIELDS_READONLY (type))))
readonly_error (o[i], "modification by `asm'", 1);
}
}