aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMark Mitchell <mark@codesourcery.com>2002-06-26 17:03:44 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>2002-06-26 17:03:44 +0000
commit88e5899c42f407b4a004f07547b66faedb337e5d (patch)
tree6c2da327814262da8d36bf59a30e8df049d74c85 /gcc
parentdd6773cd70d74d69706f5ac96df5c76151789925 (diff)
downloadgcc-88e5899c42f407b4a004f07547b66faedb337e5d.zip
gcc-88e5899c42f407b4a004f07547b66faedb337e5d.tar.gz
gcc-88e5899c42f407b4a004f07547b66faedb337e5d.tar.bz2
cp-tree.h (xref_tag): Change prototype.
* cp-tree.h (xref_tag): Change prototype. (handle_class_head): Likewise. (build_x_component_ref): Likewise. * decl.c (cxx_init_decl_processing): Adjust call to xref_tag. (xref_tag): Take attributes as a separate parameter. (xref_tag_from_type): Adjust call to xref_tag. * decl2.c (build_expr_from_tree): Adjust call to build_x_component_ref. (handle_class_head): Take attributes as a separate parameter. * parse.y (parse_xref_tag): New function. (parse_handle_class_head): Likewise. (primary): Use parse_xref_tag. (class_head_decl): Use parse_handle_class_head. (class_head_defn): Likewise. * rtti.c (init_rtti_processing): Adjust call to xref_tag. (build_dynamic_cast_1): Likewise. (create_pseudo_type_info): Likewise. (emit_support_tinfos): Likewise. * typeck.c (build_object_ref): Adjust call to build_x_component_ref. (build_x_component_ref): Remove protect parameter. From-SVN: r55013
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog24
-rw-r--r--gcc/cp/cp-tree.h6
-rw-r--r--gcc/cp/decl.c33
-rw-r--r--gcc/cp/decl2.c12
-rw-r--r--gcc/cp/parse.y95
-rw-r--r--gcc/cp/rtti.c17
-rw-r--r--gcc/cp/typeck.c8
7 files changed, 130 insertions, 65 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 891f962..5f2a0b3 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,27 @@
+2002-06-26 Mark Mitchell <mark@codesourcery.com>
+
+ * cp-tree.h (xref_tag): Change prototype.
+ (handle_class_head): Likewise.
+ (build_x_component_ref): Likewise.
+ * decl.c (cxx_init_decl_processing): Adjust call to xref_tag.
+ (xref_tag): Take attributes as a separate parameter.
+ (xref_tag_from_type): Adjust call to xref_tag.
+ * decl2.c (build_expr_from_tree): Adjust call to
+ build_x_component_ref.
+ (handle_class_head): Take attributes as a separate parameter.
+ * parse.y (parse_xref_tag): New function.
+ (parse_handle_class_head): Likewise.
+ (primary): Use parse_xref_tag.
+ (class_head_decl): Use parse_handle_class_head.
+ (class_head_defn): Likewise.
+ * rtti.c (init_rtti_processing): Adjust call to xref_tag.
+ (build_dynamic_cast_1): Likewise.
+ (create_pseudo_type_info): Likewise.
+ (emit_support_tinfos): Likewise.
+ * typeck.c (build_object_ref): Adjust call to
+ build_x_component_ref.
+ (build_x_component_ref): Remove protect parameter.
+
2002-06-25 Mark Mitchell <mark@codesourcery.com>
* call.c (build_op_delete_call): Use BASELINK_FUNCTIONS.
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 7f21c9c..2c19c09 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -3856,7 +3856,7 @@ extern int copy_fn_p PARAMS ((tree));
extern void grok_special_member_properties PARAMS ((tree));
extern int grok_ctor_properties PARAMS ((tree, tree));
extern void grok_op_properties PARAMS ((tree, int));
-extern tree xref_tag PARAMS ((tree, tree, int));
+extern tree xref_tag (enum tag_types, tree, tree, bool);
extern tree xref_tag_from_type PARAMS ((tree, tree, int));
extern void xref_basetypes PARAMS ((tree, tree));
extern tree start_enum PARAMS ((tree));
@@ -3955,7 +3955,7 @@ extern tree do_class_using_decl PARAMS ((tree));
extern void do_using_directive PARAMS ((tree));
extern void check_default_args PARAMS ((tree));
extern void mark_used PARAMS ((tree));
-extern tree handle_class_head PARAMS ((tree, tree, tree, int, int *));
+extern tree handle_class_head (enum tag_types, tree, tree, tree, int, int *);
extern tree lookup_arg_dependent PARAMS ((tree, tree, tree));
extern void finish_static_data_member_decl PARAMS ((tree, tree, tree, int));
extern tree build_artificial_parm PARAMS ((tree, tree));
@@ -4437,7 +4437,7 @@ extern tree decay_conversion PARAMS ((tree));
extern tree build_object_ref PARAMS ((tree, tree, tree));
extern tree build_component_ref_1 PARAMS ((tree, tree, int));
extern tree build_component_ref PARAMS ((tree, tree, tree, int));
-extern tree build_x_component_ref PARAMS ((tree, tree, tree, int));
+extern tree build_x_component_ref PARAMS ((tree, tree, tree));
extern tree build_x_indirect_ref PARAMS ((tree, const char *));
extern tree build_indirect_ref PARAMS ((tree, const char *));
extern tree build_array_ref PARAMS ((tree, tree));
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 1b1975a..e2263fc 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -6587,8 +6587,9 @@ cxx_init_decl_processing ()
tree ptr_ftype_sizetype;
push_namespace (std_identifier);
- bad_alloc_type_node = xref_tag
- (class_type_node, get_identifier ("bad_alloc"), 1);
+ bad_alloc_type_node
+ = xref_tag (class_type, get_identifier ("bad_alloc"),
+ /*attributes=*/NULL_TREE, 1);
pop_namespace ();
ptr_ftype_sizetype
= build_function_type (ptr_type_node,
@@ -12729,29 +12730,14 @@ tag_name (code)
scope.) */
tree
-xref_tag (code_type_node, name, globalize)
- tree code_type_node;
- tree name;
- int globalize;
+xref_tag (enum tag_types tag_code, tree name, tree attributes,
+ bool globalize)
{
- enum tag_types tag_code;
enum tree_code code;
register tree ref, t;
struct cp_binding_level *b = current_binding_level;
- tree attributes = NULL_TREE;
tree context = NULL_TREE;
- /* If we are called from the parser, code_type_node will sometimes be a
- TREE_LIST. This indicates that the user wrote
- "class __attribute__ ((foo)) bar". Extract the attributes so we can
- use them later. */
- if (TREE_CODE (code_type_node) == TREE_LIST)
- {
- attributes = TREE_PURPOSE (code_type_node);
- code_type_node = TREE_VALUE (code_type_node);
- }
-
- tag_code = (enum tag_types) tree_low_cst (code_type_node, 1);
switch (tag_code)
{
case record_type:
@@ -12962,18 +12948,17 @@ xref_tag_from_type (old, id, globalize)
tree old, id;
int globalize;
{
- tree code_type_node;
+ enum tag_types tag_kind;
if (TREE_CODE (old) == RECORD_TYPE)
- code_type_node = (CLASSTYPE_DECLARED_CLASS (old)
- ? class_type_node : record_type_node);
+ tag_kind = (CLASSTYPE_DECLARED_CLASS (old) ? class_type : record_type);
else
- code_type_node = union_type_node;
+ tag_kind = union_type;
if (id == NULL_TREE)
id = TYPE_IDENTIFIER (old);
- return xref_tag (code_type_node, id, globalize);
+ return xref_tag (tag_kind, id, /*attributes=*/NULL_TREE, globalize);
}
/* REF is a type (named NAME), for which we have just seen some
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index 72930c2..eb1dd00 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -3919,8 +3919,7 @@ build_expr_from_tree (t)
TREE_OPERAND (field, 0),
TREE_OPERAND (field, 1));
else
- return build_x_component_ref (object, field,
- NULL_TREE, 1);
+ return build_x_component_ref (object, field, NULL_TREE);
}
case THROW_EXPR:
@@ -5194,8 +5193,9 @@ mark_used (decl)
Return a TYPE_DECL for the type declared by ID in SCOPE. */
tree
-handle_class_head (aggr, scope, id, defn_p, new_type_p)
- tree aggr, scope, id;
+handle_class_head (tag_kind, scope, id, attributes, defn_p, new_type_p)
+ enum tag_types tag_kind;
+ tree scope, id, attributes;
int defn_p;
int *new_type_p;
{
@@ -5244,7 +5244,7 @@ handle_class_head (aggr, scope, id, defn_p, new_type_p)
if (!decl)
{
- decl = TYPE_MAIN_DECL (xref_tag (aggr, id, !defn_p));
+ decl = TYPE_MAIN_DECL (xref_tag (tag_kind, id, attributes, !defn_p));
xrefd_p = true;
}
@@ -5271,7 +5271,7 @@ handle_class_head (aggr, scope, id, defn_p, new_type_p)
/* It is legal to define a class with a different class key,
and this changes the default member access. */
CLASSTYPE_DECLARED_CLASS (TREE_TYPE (decl))
- = aggr == class_type_node;
+ = (tag_kind == class_type);
if (!xrefd_p && PROCESSING_REAL_TEMPLATE_DECL_P ())
decl = push_template_decl (decl);
diff --git a/gcc/cp/parse.y b/gcc/cp/parse.y
index 14e5c5c..eb76810 100644
--- a/gcc/cp/parse.y
+++ b/gcc/cp/parse.y
@@ -90,7 +90,6 @@ do { \
malloced_yyss = newss; \
malloced_yyvs = (void *) newvs; \
} while (0)
-
#define OP0(NODE) (TREE_OPERAND (NODE, 0))
#define OP1(NODE) (TREE_OPERAND (NODE, 1))
@@ -131,6 +130,8 @@ static tree parse_method PARAMS ((tree, tree, tree));
static void frob_specs PARAMS ((tree, tree));
static void check_class_key PARAMS ((tree, tree));
static tree parse_scoped_id PARAMS ((tree));
+static tree parse_xref_tag (tree, tree, int);
+static tree parse_handle_class_head (tree, tree, tree, int, int *);
/* Cons up an empty parameter list. */
static inline tree
@@ -1718,14 +1719,14 @@ primary:
{ $$ = finish_qualified_call_expr ($1, NULL_TREE); }
| object object_template_id %prec UNARY
{
- $$ = build_x_component_ref ($$, $2, NULL_TREE, 1);
+ $$ = build_x_component_ref ($$, $2, NULL_TREE);
}
| object object_template_id '(' nonnull_exprlist ')'
{ $$ = finish_object_call_expr ($2, $1, $4); }
| object object_template_id LEFT_RIGHT
{ $$ = finish_object_call_expr ($2, $1, NULL_TREE); }
| object unqualified_id %prec UNARY
- { $$ = build_x_component_ref ($$, $2, NULL_TREE, 1); }
+ { $$ = build_x_component_ref ($$, $2, NULL_TREE); }
| object overqualified_id %prec UNARY
{ if (processing_template_decl)
$$ = build_min_nt (COMPONENT_REF, $1, $2);
@@ -2308,10 +2309,10 @@ structsp:
current_enum_type = $<ttype>3;
check_for_missing_semicolon ($$.t); }
| ENUM identifier
- { $$.t = xref_tag (enum_type_node, $2, 1);
+ { $$.t = parse_xref_tag (enum_type_node, $2, 1);
$$.new_type_flag = 0; }
| ENUM complex_type_name
- { $$.t = xref_tag (enum_type_node, $2, 1);
+ { $$.t = parse_xref_tag (enum_type_node, $2, 1);
$$.new_type_flag = 0; }
| TYPENAME_KEYWORD typename_sub
{ $$.t = $2;
@@ -2442,14 +2443,15 @@ class_head_apparent_template:
class_head_decl:
class_head %prec EMPTY
{
- $$.t = handle_class_head (current_aggr,
- TREE_PURPOSE ($1), TREE_VALUE ($1),
- 0, &$$.new_type_flag);
+ $$.t = parse_handle_class_head (current_aggr,
+ TREE_PURPOSE ($1),
+ TREE_VALUE ($1),
+ 0, &$$.new_type_flag);
}
| aggr identifier_defn %prec EMPTY
{
current_aggr = $1;
- $$.t = TYPE_MAIN_DECL (xref_tag (current_aggr, $2, 0));
+ $$.t = TYPE_MAIN_DECL (parse_xref_tag (current_aggr, $2, 0));
$$.new_type_flag = 1;
}
| class_head_apparent_template %prec EMPTY
@@ -2463,16 +2465,19 @@ class_head_defn:
class_head '{'
{
yyungetc ('{', 1);
- $$.t = handle_class_head (current_aggr,
- TREE_PURPOSE ($1), TREE_VALUE ($1),
- 1, &$$.new_type_flag);
+ $$.t = parse_handle_class_head (current_aggr,
+ TREE_PURPOSE ($1),
+ TREE_VALUE ($1),
+ 1,
+ &$$.new_type_flag);
}
| class_head ':'
{
yyungetc (':', 1);
- $$.t = handle_class_head (current_aggr,
- TREE_PURPOSE ($1), TREE_VALUE ($1),
- 1, &$$.new_type_flag);
+ $$.t = parse_handle_class_head (current_aggr,
+ TREE_PURPOSE ($1),
+ TREE_VALUE ($1),
+ 1, &$$.new_type_flag);
}
| class_head_apparent_template '{'
{
@@ -2500,22 +2505,24 @@ class_head_defn:
{
yyungetc ('{', 1);
current_aggr = $1;
- $$.t = handle_class_head (current_aggr,
- NULL_TREE, $2,
- 1, &$$.new_type_flag);
+ $$.t = parse_handle_class_head (current_aggr,
+ NULL_TREE, $2,
+ 1, &$$.new_type_flag);
}
| aggr identifier_defn ':'
{
yyungetc (':', 1);
current_aggr = $1;
- $$.t = handle_class_head (current_aggr,
- NULL_TREE, $2,
- 1, &$$.new_type_flag);
+ $$.t = parse_handle_class_head (current_aggr,
+ NULL_TREE, $2,
+ 1, &$$.new_type_flag);
}
| aggr '{'
{
current_aggr = $1;
- $$.t = TYPE_MAIN_DECL (xref_tag ($1, make_anon_name (), 0));
+ $$.t = TYPE_MAIN_DECL (parse_xref_tag ($1,
+ make_anon_name (),
+ 0));
$$.new_type_flag = 0;
yyungetc ('{', 1);
}
@@ -4034,4 +4041,48 @@ parse_scoped_id (token)
return do_scoped_id (token, id);
}
+/* AGGR may be either a type node (like class_type_node) or a
+ TREE_LIST whose TREE_PURPOSE is a list of attributes and whose
+ TREE_VALUE is a type node. Set *TAG_KIND and *ATTRIBUTES to
+ represent the information encoded. */
+
+static void
+parse_split_aggr (tree aggr, enum tag_types *tag_kind, tree *attributes)
+{
+ if (TREE_CODE (aggr) == TREE_LIST)
+ {
+ *attributes = TREE_PURPOSE (aggr);
+ aggr = TREE_VALUE (aggr);
+ }
+ else
+ *attributes = NULL_TREE;
+ *tag_kind = (enum tag_types) tree_low_cst (aggr, 1);
+}
+
+/* Like xref_tag, except that the AGGR may be either a type node (like
+ class_type_node) or a TREE_LIST whose TREE_PURPOSE is a list of
+ attributes and whose TREE_VALUE is a type node. */
+
+static tree
+parse_xref_tag (tree aggr, tree name, int globalize)
+{
+ tree attributes;
+ enum tag_types tag_kind;
+ parse_split_aggr (aggr, &tag_kind, &attributes);
+ return xref_tag (tag_kind, name, attributes, globalize);
+}
+
+/* Like handle_class_head, but AGGR may be as for parse_xref_tag. */
+
+static tree
+parse_handle_class_head (tree aggr, tree scope, tree id,
+ int defn_p, int *new_type_p)
+{
+ tree attributes;
+ enum tag_types tag_kind;
+ parse_split_aggr (aggr, &tag_kind, &attributes);
+ return handle_class_head (tag_kind, scope, id, attributes,
+ defn_p, new_type_p);
+}
+
#include "gt-cp-parse.h"
diff --git a/gcc/cp/rtti.c b/gcc/cp/rtti.c
index 7d3027a..317a44d 100644
--- a/gcc/cp/rtti.c
+++ b/gcc/cp/rtti.c
@@ -72,8 +72,9 @@ void
init_rtti_processing ()
{
push_namespace (std_identifier);
- type_info_type_node = xref_tag
- (class_type_node, get_identifier ("type_info"), 1);
+ type_info_type_node
+ = xref_tag (class_type, get_identifier ("type_info"),
+ /*attributes=*/NULL_TREE, 1);
pop_namespace ();
tinfo_decl_type =
build_qualified_type (type_info_type_node, TYPE_QUAL_CONST);
@@ -573,8 +574,9 @@ build_dynamic_cast_1 (type, expr)
const char *name;
push_nested_namespace (ns);
- tinfo_ptr = xref_tag (class_type_node,
+ tinfo_ptr = xref_tag (class_type,
get_identifier ("__class_type_info"),
+ /*attributes=*/NULL_TREE,
1);
tinfo_ptr = build_pointer_type
@@ -1166,7 +1168,8 @@ create_pseudo_type_info VPARAMS((const char *real_name, int ident, ...))
sprintf (pseudo_name + strlen (pseudo_name), "%d", ident);
/* Get the vtable decl. */
- real_type = xref_tag (class_type_node, get_identifier (real_name), 1);
+ real_type = xref_tag (class_type, get_identifier (real_name),
+ /*attributes=*/NULL_TREE, 1);
if (! TYPE_SIZE (real_type))
{
/* We never saw a definition of this type, so we need to tell the
@@ -1370,8 +1373,10 @@ emit_support_tinfos ()
tree bltn_type, dtor;
push_nested_namespace (abi_node);
- bltn_type = xref_tag (class_type_node,
- get_identifier ("__fundamental_type_info"), 1);
+ bltn_type = xref_tag (class_type,
+ get_identifier ("__fundamental_type_info"),
+ /*attributes=*/NULL_TREE,
+ 1);
pop_nested_namespace (abi_node);
if (!COMPLETE_TYPE_P (bltn_type))
return;
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index c1338d9..30d8cac 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -1844,7 +1844,7 @@ build_object_ref (datum, basetype, field)
{
tree binfo = NULL_TREE;
datum = build_scoped_ref (datum, basetype, &binfo);
- return build_x_component_ref (datum, field, binfo, 1);
+ return build_x_component_ref (datum, field, binfo);
}
return error_mark_node;
}
@@ -2256,11 +2256,11 @@ invalid offsetof from non-POD type `%#T'; use pointer to member instead",
never have REFERENCE_TYPE. */
tree
-build_x_component_ref (datum, component, basetype_path, protect)
+build_x_component_ref (datum, component, basetype_path)
tree datum, component, basetype_path;
- int protect;
{
- tree t = build_component_ref (datum, component, basetype_path, protect);
+ tree t = build_component_ref (datum, component, basetype_path,
+ /*protect=*/1);
if (! processing_template_decl)
t = convert_from_reference (t);