Commit a2af967e by Nathan Sidwell Committed by Nathan Sidwell

[C++ PATCH] Kill IDENTIFIER_LABEL_VALUE

https://gcc.gnu.org/ml/gcc-patches/2017-10/msg01854.html
	Kill IDENTIFIER_LABEL_VALUE.
	* cp-tree.h (lang_identifier): Delete label_value slot.
	(IDENTIFIER_LABEL_VALUE, SET_IDENTIFIER_LABEL_VALUE): Delete.
	(struct named_label_hasher): Rename to ...
	(struct named_label_hash): ... here.  Reimplement.
	(struct language_function): Adjust x_named_labels.
	* name-lookup.h (struct cp_label_binding): Delete.
	(struct cp_binding_level): Delete shadowed_labels slot.
	* decl.c (struct named_label_entry): Add name and outer slots.
	(pop_label): Rename to ...
	(check_label_used): ... here.  Don't pop.
	(note_label, sort_labels): Delete.
	(pop_labels, pop_local_label): Reimplement.
	(poplevel): Pop local labels as any other decl. Remove
	shadowed_labels handling.
	(named_label_hash::hash, named_label_hash::equal): New.
	(make_label_decl): Absorb into ...
	(lookup_label_1): ... here.  Add making_local_p arg, reimplement.
	(lookup_label, declare_local_label): Adjust.
	(check_goto, define_label): Adjust.
	* lex.c (make_conv_op_name): Don't clear IDENTIFIER_LABEL_VALUE.
	* ptree.c (cxx_print_identifier): Don't print identifier binding.

From-SVN: r254087
parent 733ba9b9
2017-10-25 Nathan Sidwell <nathan@acm.org> 2017-10-25 Nathan Sidwell <nathan@acm.org>
Kill IDENTIFIER_LABEL_VALUE.
* cp-tree.h (lang_identifier): Delete label_value slot.
(IDENTIFIER_LABEL_VALUE, SET_IDENTIFIER_LABEL_VALUE): Delete.
(struct named_label_hasher): Rename to ...
(struct named_label_hash): ... here. Reimplement.
(struct language_function): Adjust x_named_labels.
* name-lookup.h (struct cp_label_binding): Delete.
(struct cp_binding_level): Delete shadowed_labels slot.
* decl.c (struct named_label_entry): Add name and outer slots.
(pop_label): Rename to ...
(check_label_used): ... here. Don't pop.
(note_label, sort_labels): Delete.
(pop_labels, pop_local_label): Reimplement.
(poplevel): Pop local labels as any other decl. Remove
shadowed_labels handling.
(named_label_hash::hash, named_label_hash::equal): New.
(make_label_decl): Absorb into ...
(lookup_label_1): ... here. Add making_local_p arg, reimplement.
(lookup_label, declare_local_label): Adjust.
(check_goto, define_label): Adjust.
* lex.c (make_conv_op_name): Don't clear IDENTIFIER_LABEL_VALUE.
* ptree.c (cxx_print_identifier): Don't print identifier binding.
* decl.c (identifier_goto): Reduce duplication. * decl.c (identifier_goto): Reduce duplication.
(check_previous_goto_1): Likewise. (check_previous_goto_1): Likewise.
(check_goto): Move var decls to initialization. (check_goto): Move var decls to initialization.
......
...@@ -561,7 +561,6 @@ extern GTY(()) tree cp_global_trees[CPTI_MAX]; ...@@ -561,7 +561,6 @@ extern GTY(()) tree cp_global_trees[CPTI_MAX];
struct GTY(()) lang_identifier { struct GTY(()) lang_identifier {
struct c_common_identifier c_common; struct c_common_identifier c_common;
cxx_binding *bindings; cxx_binding *bindings;
tree label_value;
}; };
/* Return a typed pointer version of T if it designates a /* Return a typed pointer version of T if it designates a
...@@ -996,11 +995,6 @@ enum GTY(()) abstract_class_use { ...@@ -996,11 +995,6 @@ enum GTY(()) abstract_class_use {
#define SET_IDENTIFIER_TYPE_VALUE(NODE,TYPE) (TREE_TYPE (NODE) = (TYPE)) #define SET_IDENTIFIER_TYPE_VALUE(NODE,TYPE) (TREE_TYPE (NODE) = (TYPE))
#define IDENTIFIER_HAS_TYPE_VALUE(NODE) (IDENTIFIER_TYPE_VALUE (NODE) ? 1 : 0) #define IDENTIFIER_HAS_TYPE_VALUE(NODE) (IDENTIFIER_TYPE_VALUE (NODE) ? 1 : 0)
#define IDENTIFIER_LABEL_VALUE(NODE) \
(LANG_IDENTIFIER_CAST (NODE)->label_value)
#define SET_IDENTIFIER_LABEL_VALUE(NODE, VALUE) \
IDENTIFIER_LABEL_VALUE (NODE) = (VALUE)
/* Kinds of identifiers. Values are carefully chosen. */ /* Kinds of identifiers. Values are carefully chosen. */
enum cp_identifier_kind { enum cp_identifier_kind {
cik_normal = 0, /* Not a special identifier. */ cik_normal = 0, /* Not a special identifier. */
...@@ -1662,12 +1656,22 @@ struct cxx_int_tree_map_hasher : ggc_ptr_hash<cxx_int_tree_map> ...@@ -1662,12 +1656,22 @@ struct cxx_int_tree_map_hasher : ggc_ptr_hash<cxx_int_tree_map>
static bool equal (cxx_int_tree_map *, cxx_int_tree_map *); static bool equal (cxx_int_tree_map *, cxx_int_tree_map *);
}; };
struct named_label_entry; struct named_label_entry; /* Defined in decl.c. */
struct named_label_hasher : ggc_ptr_hash<named_label_entry> struct named_label_hash : ggc_remove <named_label_entry *>
{ {
static hashval_t hash (named_label_entry *); typedef named_label_entry *value_type;
static bool equal (named_label_entry *, named_label_entry *); typedef tree compare_type; /* An identifier. */
inline static hashval_t hash (value_type);
inline static bool equal (const value_type, compare_type);
inline static void mark_empty (value_type &p) {p = NULL;}
inline static bool is_empty (value_type p) {return !p;}
/* Nothing is deletable. Everything is insertable. */
inline static bool is_deleted (value_type) { return false; }
inline static void mark_deleted (value_type) { gcc_unreachable (); }
}; };
/* Global state pertinent to the current function. */ /* Global state pertinent to the current function. */
...@@ -1696,7 +1700,8 @@ struct GTY(()) language_function { ...@@ -1696,7 +1700,8 @@ struct GTY(()) language_function {
BOOL_BITFIELD invalid_constexpr : 1; BOOL_BITFIELD invalid_constexpr : 1;
hash_table<named_label_hasher> *x_named_labels; hash_table<named_label_hash> *x_named_labels;
cp_binding_level *bindings; cp_binding_level *bindings;
vec<tree, va_gc> *x_local_names; vec<tree, va_gc> *x_local_names;
/* Tracking possibly infinite loops. This is a vec<tree> only because /* Tracking possibly infinite loops. This is a vec<tree> only because
......
...@@ -585,7 +585,6 @@ make_conv_op_name (tree type) ...@@ -585,7 +585,6 @@ make_conv_op_name (tree type)
/* Just in case something managed to bind. */ /* Just in case something managed to bind. */
IDENTIFIER_BINDING (identifier) = NULL; IDENTIFIER_BINDING (identifier) = NULL;
IDENTIFIER_LABEL_VALUE (identifier) = NULL_TREE;
/* Hang TYPE off the identifier so it can be found easily later /* Hang TYPE off the identifier so it can be found easily later
when performing conversions. */ when performing conversions. */
......
...@@ -148,15 +148,6 @@ struct GTY(()) cp_class_binding { ...@@ -148,15 +148,6 @@ struct GTY(()) cp_class_binding {
tree identifier; tree identifier;
}; };
struct GTY(()) cp_label_binding {
/* The bound LABEL_DECL. */
tree label;
/* The previous IDENTIFIER_LABEL_VALUE. */
tree prev_value;
};
/* For each binding contour we allocate a binding_level structure /* For each binding contour we allocate a binding_level structure
which records the names defined in that contour. which records the names defined in that contour.
Contours include: Contours include:
...@@ -202,10 +193,6 @@ struct GTY(()) cp_binding_level { ...@@ -202,10 +193,6 @@ struct GTY(()) cp_binding_level {
the class. */ the class. */
tree type_shadowed; tree type_shadowed;
/* Similar to class_shadowed, but for IDENTIFIER_LABEL_VALUE, and
used for all binding levels. */
vec<cp_label_binding, va_gc> *shadowed_labels;
/* For each level (except not the global one), /* For each level (except not the global one),
a chain of BLOCK nodes for all the levels a chain of BLOCK nodes for all the levels
that were entered and exited one level down. */ that were entered and exited one level down. */
......
...@@ -177,7 +177,6 @@ cxx_print_identifier (FILE *file, tree node, int indent) ...@@ -177,7 +177,6 @@ cxx_print_identifier (FILE *file, tree node, int indent)
indent_to (file, indent + 4); indent_to (file, indent + 4);
fprintf (file, "%s local bindings <%p>", get_identifier_kind_name (node), fprintf (file, "%s local bindings <%p>", get_identifier_kind_name (node),
(void *) IDENTIFIER_BINDING (node)); (void *) IDENTIFIER_BINDING (node));
print_node (file, "label", IDENTIFIER_LABEL_VALUE (node), indent + 4);
} }
void void
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment