Commit 30bcc028 by Douglas Gregor Committed by Doug Gregor

ptree.c (cxx_print_type): Use formatting markup for integers when printing template parameter...

2007-03-15  Douglas Gregor  <doug.gregor@gmail.com>

	* ptree.c (cxx_print_type): Use formatting markup for integers
	when printing template parameter index/level/orig level.
	(cxx_print_xnode): Ditto.
	* cp-tree.h (TEMPLATE_PARM_PARAMETER_PACK): Use TREE_LANG_FLAG_0.
	(struct template_parm_index_s): Remove the PARAMETER_PACK member.
	Make INDEX, LEVEL, and ORIG_LEVEL integers instead of
	HOST_WIDE_INTs.
	(struct saved_scope): Make X_PROCESSING_TEMPLATE_DECL an int,
	rather than a HOST_WIDE_INT.
	Turn X_PROCESSING_EXPLICIT_INSTANTIATION, SKIP_EVALUATION, and
	NEED_POP_FUNCTION_CONTEXT into bool bitfields; reorder fields for
	better bit-packing.
	(struct language_function): Make RETURNS_VALUE, RETURNS_NULL,
	RETURNS_ABNORMALLY, IN_FUNCTION_TRY_HANDLER, and
	IN_BASE_INITIALIZER bool bitfields.
	(struct cp_declarator): Make KIND a 4-bit field. Make
	PARAMETER_PACK_P a bool bitfield just after KIND.
	* pt.c (uses_parameter_packs): Destroy the pointer set.
	(make_pack_expansion): Ditto.
	(check_for_bare_parameter_packs): Ditto.
	* name-lookup.c (push_to_top_level): Make need_pop a bool value.

From-SVN: r122955
parent 868d75db
2007-03-15 Douglas Gregor <doug.gregor@gmail.com>
* ptree.c (cxx_print_type): Use formatting markup for integers
when printing template parameter index/level/orig level.
(cxx_print_xnode): Ditto.
* cp-tree.h (TEMPLATE_PARM_PARAMETER_PACK): Use TREE_LANG_FLAG_0.
(struct template_parm_index_s): Remove the PARAMETER_PACK member.
Make INDEX, LEVEL, and ORIG_LEVEL integers instead of
HOST_WIDE_INTs.
(struct saved_scope): Make X_PROCESSING_TEMPLATE_DECL an int,
rather than a HOST_WIDE_INT.
Turn X_PROCESSING_EXPLICIT_INSTANTIATION, SKIP_EVALUATION, and
NEED_POP_FUNCTION_CONTEXT into bool bitfields; reorder fields for
better bit-packing.
(struct language_function): Make RETURNS_VALUE, RETURNS_NULL,
RETURNS_ABNORMALLY, IN_FUNCTION_TRY_HANDLER, and
IN_BASE_INITIALIZER bool bitfields.
(struct cp_declarator): Make KIND a 4-bit field. Make
PARAMETER_PACK_P a bool bitfield just after KIND.
* pt.c (uses_parameter_packs): Destroy the pointer set.
(make_pack_expansion): Ditto.
(check_for_bare_parameter_packs): Ditto.
* name-lookup.c (push_to_top_level): Make need_pop a bool value.
2007-03-14 Andrew Pinski <andrew_pinski@playstation.sony.com> 2007-03-14 Andrew Pinski <andrew_pinski@playstation.sony.com>
PR c++/31165 PR c++/31165
......
...@@ -56,6 +56,7 @@ struct diagnostic_context; ...@@ -56,6 +56,7 @@ struct diagnostic_context;
OMP_FOR_GIMPLIFYING_P (in OMP_FOR) OMP_FOR_GIMPLIFYING_P (in OMP_FOR)
BASELINK_QUALIFIED_P (in BASELINK) BASELINK_QUALIFIED_P (in BASELINK)
TARGET_EXPR_IMPLICIT_P (in TARGET_EXPR) TARGET_EXPR_IMPLICIT_P (in TARGET_EXPR)
TEMPLATE_PARM_PARAMETER_PACK (in TEMPLATE_PARM_INDEX)
1: IDENTIFIER_VIRTUAL_P (in IDENTIFIER_NODE) 1: IDENTIFIER_VIRTUAL_P (in IDENTIFIER_NODE)
TI_PENDING_TEMPLATE_FLAG. TI_PENDING_TEMPLATE_FLAG.
TEMPLATE_PARMS_FOR_INLINE. TEMPLATE_PARMS_FOR_INLINE.
...@@ -219,14 +220,10 @@ struct lang_identifier GTY(()) ...@@ -219,14 +220,10 @@ struct lang_identifier GTY(())
struct template_parm_index_s GTY(()) struct template_parm_index_s GTY(())
{ {
struct tree_common common; struct tree_common common;
HOST_WIDE_INT index; int index;
HOST_WIDE_INT level; int level;
HOST_WIDE_INT orig_level; int orig_level;
tree decl; tree decl;
/* When true, indicates that this parameter is actually a parameter
pack, for variadic templates. */
BOOL_BITFIELD parameter_pack;
}; };
typedef struct template_parm_index_s template_parm_index; typedef struct template_parm_index_s template_parm_index;
...@@ -703,11 +700,11 @@ struct saved_scope GTY(()) ...@@ -703,11 +700,11 @@ struct saved_scope GTY(())
struct cp_binding_level *x_previous_class_level; struct cp_binding_level *x_previous_class_level;
tree x_saved_tree; tree x_saved_tree;
HOST_WIDE_INT x_processing_template_decl; int x_processing_template_decl;
int x_processing_specialization; int x_processing_specialization;
bool x_processing_explicit_instantiation; BOOL_BITFIELD x_processing_explicit_instantiation : 1;
int need_pop_function_context; BOOL_BITFIELD need_pop_function_context : 1;
bool skip_evaluation; BOOL_BITFIELD skip_evaluation : 1;
struct stmt_tree_s x_stmt_tree; struct stmt_tree_s x_stmt_tree;
...@@ -786,11 +783,11 @@ struct language_function GTY(()) ...@@ -786,11 +783,11 @@ struct language_function GTY(())
tree x_vtt_parm; tree x_vtt_parm;
tree x_return_value; tree x_return_value;
int returns_value; BOOL_BITFIELD returns_value : 1;
int returns_null; BOOL_BITFIELD returns_null : 1;
int returns_abnormally; BOOL_BITFIELD returns_abnormally : 1;
int in_function_try_handler; BOOL_BITFIELD in_function_try_handler : 1;
int in_base_initializer; BOOL_BITFIELD in_base_initializer : 1;
/* True if this function can throw an exception. */ /* True if this function can throw an exception. */
BOOL_BITFIELD can_throw : 1; BOOL_BITFIELD can_throw : 1;
...@@ -3705,7 +3702,8 @@ enum overload_flags { NO_SPECIAL = 0, DTOR_FLAG, OP_FLAG, TYPENAME_FLAG }; ...@@ -3705,7 +3702,8 @@ enum overload_flags { NO_SPECIAL = 0, DTOR_FLAG, OP_FLAG, TYPENAME_FLAG };
#define TEMPLATE_PARM_DESCENDANTS(NODE) (TREE_CHAIN (NODE)) #define TEMPLATE_PARM_DESCENDANTS(NODE) (TREE_CHAIN (NODE))
#define TEMPLATE_PARM_ORIG_LEVEL(NODE) (TEMPLATE_PARM_INDEX_CAST (NODE)->orig_level) #define TEMPLATE_PARM_ORIG_LEVEL(NODE) (TEMPLATE_PARM_INDEX_CAST (NODE)->orig_level)
#define TEMPLATE_PARM_DECL(NODE) (TEMPLATE_PARM_INDEX_CAST (NODE)->decl) #define TEMPLATE_PARM_DECL(NODE) (TEMPLATE_PARM_INDEX_CAST (NODE)->decl)
#define TEMPLATE_PARM_PARAMETER_PACK(NODE) (TEMPLATE_PARM_INDEX_CAST (NODE)->parameter_pack) #define TEMPLATE_PARM_PARAMETER_PACK(NODE) \
(TREE_LANG_FLAG_0 (TEMPLATE_PARM_INDEX_CHECK (NODE)))
/* These macros are for accessing the fields of TEMPLATE_TYPE_PARM, /* These macros are for accessing the fields of TEMPLATE_TYPE_PARM,
TEMPLATE_TEMPLATE_PARM and BOUND_TEMPLATE_TEMPLATE_PARM nodes. */ TEMPLATE_TEMPLATE_PARM and BOUND_TEMPLATE_TEMPLATE_PARM nodes. */
...@@ -3901,16 +3899,16 @@ struct cp_parameter_declarator { ...@@ -3901,16 +3899,16 @@ struct cp_parameter_declarator {
/* A declarator. */ /* A declarator. */
struct cp_declarator { struct cp_declarator {
/* The kind of declarator. */ /* The kind of declarator. */
cp_declarator_kind kind; ENUM_BITFIELD (cp_declarator_kind) kind : 4;
/* Whether we parsed an ellipsis (`...') just before the declarator,
to indicate this is a parameter pack. */
BOOL_BITFIELD parameter_pack_p : 1;
/* Attributes that apply to this declarator. */ /* Attributes that apply to this declarator. */
tree attributes; tree attributes;
/* For all but cdk_id and cdk_error, the contained declarator. For /* For all but cdk_id and cdk_error, the contained declarator. For
cdk_id and cdk_error, guaranteed to be NULL. */ cdk_id and cdk_error, guaranteed to be NULL. */
cp_declarator *declarator; cp_declarator *declarator;
location_t id_loc; /* Currently only set for cdk_id. */ location_t id_loc; /* Currently only set for cdk_id. */
/* Whether we parsed an ellipsis (`...') just before the declarator,
to indicate this is a parameter pack. */
bool parameter_pack_p;
union { union {
/* For identifiers. */ /* For identifiers. */
struct { struct {
......
...@@ -5030,7 +5030,7 @@ push_to_top_level (void) ...@@ -5030,7 +5030,7 @@ push_to_top_level (void)
struct cp_binding_level *b; struct cp_binding_level *b;
cxx_saved_binding *sb; cxx_saved_binding *sb;
size_t i; size_t i;
int need_pop; bool need_pop;
timevar_push (TV_NAME_LOOKUP); timevar_push (TV_NAME_LOOKUP);
s = GGC_CNEW (struct saved_scope); s = GGC_CNEW (struct saved_scope);
...@@ -5040,11 +5040,11 @@ push_to_top_level (void) ...@@ -5040,11 +5040,11 @@ push_to_top_level (void)
/* If we're in the middle of some function, save our state. */ /* If we're in the middle of some function, save our state. */
if (cfun) if (cfun)
{ {
need_pop = 1; need_pop = true;
push_function_context_to (NULL_TREE); push_function_context_to (NULL_TREE);
} }
else else
need_pop = 0; need_pop = false;
if (scope_chain && previous_class_level) if (scope_chain && previous_class_level)
store_class_bindings (previous_class_level->class_shadowed, store_class_bindings (previous_class_level->class_shadowed,
......
...@@ -2461,6 +2461,7 @@ uses_parameter_packs (tree t) ...@@ -2461,6 +2461,7 @@ uses_parameter_packs (tree t)
ppd.parameter_packs = &parameter_packs; ppd.parameter_packs = &parameter_packs;
ppd.visited = pointer_set_create (); ppd.visited = pointer_set_create ();
walk_tree (&t, &find_parameter_packs_r, &ppd, ppd.visited); walk_tree (&t, &find_parameter_packs_r, &ppd, ppd.visited);
pointer_set_destroy (ppd.visited);
return parameter_packs != NULL_TREE; return parameter_packs != NULL_TREE;
} }
...@@ -2515,6 +2516,7 @@ make_pack_expansion (tree arg) ...@@ -2515,6 +2516,7 @@ make_pack_expansion (tree arg)
if (parameter_packs == NULL_TREE) if (parameter_packs == NULL_TREE)
{ {
error ("base initializer expansion %<%T%> contains no parameter packs", arg); error ("base initializer expansion %<%T%> contains no parameter packs", arg);
pointer_set_destroy (ppd.visited);
return error_mark_node; return error_mark_node;
} }
...@@ -2531,6 +2533,8 @@ make_pack_expansion (tree arg) ...@@ -2531,6 +2533,8 @@ make_pack_expansion (tree arg)
} }
} }
pointer_set_destroy (ppd.visited);
/* Create the pack expansion type for the base type. */ /* Create the pack expansion type for the base type. */
purpose = make_node (TYPE_PACK_EXPANSION); purpose = make_node (TYPE_PACK_EXPANSION);
SET_PACK_EXPANSION_PATTERN (purpose, TREE_PURPOSE (arg)); SET_PACK_EXPANSION_PATTERN (purpose, TREE_PURPOSE (arg));
...@@ -2564,6 +2568,7 @@ make_pack_expansion (tree arg) ...@@ -2564,6 +2568,7 @@ make_pack_expansion (tree arg)
ppd.parameter_packs = &parameter_packs; ppd.parameter_packs = &parameter_packs;
ppd.visited = pointer_set_create (); ppd.visited = pointer_set_create ();
walk_tree (&arg, &find_parameter_packs_r, &ppd, ppd.visited); walk_tree (&arg, &find_parameter_packs_r, &ppd, ppd.visited);
pointer_set_destroy (ppd.visited);
/* Make sure we found some parameter packs. */ /* Make sure we found some parameter packs. */
if (parameter_packs == NULL_TREE) if (parameter_packs == NULL_TREE)
...@@ -2605,6 +2610,7 @@ check_for_bare_parameter_packs (tree t) ...@@ -2605,6 +2610,7 @@ check_for_bare_parameter_packs (tree t)
ppd.parameter_packs = &parameter_packs; ppd.parameter_packs = &parameter_packs;
ppd.visited = pointer_set_create (); ppd.visited = pointer_set_create ();
walk_tree (&t, &find_parameter_packs_r, &ppd, ppd.visited); walk_tree (&t, &find_parameter_packs_r, &ppd, ppd.visited);
pointer_set_destroy (ppd.visited);
if (parameter_packs) { if (parameter_packs) {
error ("parameter packs not expanded with `...':"); error ("parameter packs not expanded with `...':");
......
...@@ -68,8 +68,7 @@ cxx_print_type (FILE *file, tree node, int indent) ...@@ -68,8 +68,7 @@ cxx_print_type (FILE *file, tree node, int indent)
case TEMPLATE_TEMPLATE_PARM: case TEMPLATE_TEMPLATE_PARM:
case BOUND_TEMPLATE_TEMPLATE_PARM: case BOUND_TEMPLATE_TEMPLATE_PARM:
indent_to (file, indent + 3); indent_to (file, indent + 3);
fprintf (file, "index " HOST_WIDE_INT_PRINT_DEC " level " fprintf (file, "index %d level %d orig_level %d",
HOST_WIDE_INT_PRINT_DEC " orig_level " HOST_WIDE_INT_PRINT_DEC,
TEMPLATE_TYPE_IDX (node), TEMPLATE_TYPE_LEVEL (node), TEMPLATE_TYPE_IDX (node), TEMPLATE_TYPE_LEVEL (node),
TEMPLATE_TYPE_ORIG_LEVEL (node)); TEMPLATE_TYPE_ORIG_LEVEL (node));
return; return;
...@@ -181,8 +180,7 @@ cxx_print_xnode (FILE *file, tree node, int indent) ...@@ -181,8 +180,7 @@ cxx_print_xnode (FILE *file, tree node, int indent)
break; break;
case TEMPLATE_PARM_INDEX: case TEMPLATE_PARM_INDEX:
indent_to (file, indent + 3); indent_to (file, indent + 3);
fprintf (file, "index " HOST_WIDE_INT_PRINT_DEC " level " fprintf (file, "index %d level %d orig_level %d",
HOST_WIDE_INT_PRINT_DEC " orig_level " HOST_WIDE_INT_PRINT_DEC,
TEMPLATE_PARM_IDX (node), TEMPLATE_PARM_LEVEL (node), TEMPLATE_PARM_IDX (node), TEMPLATE_PARM_LEVEL (node),
TEMPLATE_PARM_ORIG_LEVEL (node)); TEMPLATE_PARM_ORIG_LEVEL (node));
break; break;
......
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