aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Macleod <amacleod@redhat.com>2015-12-17 21:34:58 +0000
committerAndrew Macleod <amacleod@redhat.com>2015-12-17 21:34:58 +0000
commitb1fdbd6c68ebdbbbbd4261753b710334332a68ec (patch)
tree6dc606e405379b9d532117d7dbbf679409426b69
parent3699df9669b9b0bfb68ba402fa3623ad2db9eb49 (diff)
The rest. ttype-2015
Allow ttype to be printed via %T in diagnostics Changes a typevec into C/C++ front end to ttype*. removes some TTYPE_PTRs type_promotes_to langhook conversion. ttype_p and Adjust TTYPE macros in tree.h.. locations and such. basic cleanup git-svn-id: https://gcc.gnu.org/svn/gcc/branches/ttype-2015@231789 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/c-family/c-common.c42
-rw-r--r--gcc/c-family/c-common.h7
-rw-r--r--gcc/c-family/c-format.c57
-rw-r--r--gcc/c/c-tree.h2
-rw-r--r--gcc/c/c-typeck.c20
-rw-r--r--gcc/cp/call.c48
-rw-r--r--gcc/cp/cp-tree.h27
-rw-r--r--gcc/cp/cvt.c21
-rw-r--r--gcc/cp/decl.c2
-rw-r--r--gcc/cp/decl2.c12
-rw-r--r--gcc/cp/parser.c6
-rw-r--r--gcc/cp/tree.c34
-rw-r--r--gcc/cp/typeck.c29
-rw-r--r--gcc/java/expr.c4
-rw-r--r--gcc/java/java-tree.h4
-rw-r--r--gcc/java/typeck.c4
-rw-r--r--gcc/langhooks-def.h2
-rw-r--r--gcc/langhooks.c4
-rw-r--r--gcc/langhooks.h4
-rw-r--r--gcc/tree-inline.c8
-rw-r--r--gcc/tree-inline.h2
-rw-r--r--gcc/tree.c53
-rw-r--r--gcc/tree.h103
23 files changed, 291 insertions, 204 deletions
diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c
index c305ab5908b..49a7ef77ad3 100644
--- a/gcc/c-family/c-common.c
+++ b/gcc/c-family/c-common.c
@@ -4141,7 +4141,7 @@ c_common_signed_type (tree type)
signed according to UNSIGNEDP. */
ttype *
-c_common_signed_or_unsigned_type (int unsignedp, tree type)
+c_common_signed_or_unsigned_type (int unsignedp, ttype_p type)
{
ttype *type1;
int i;
@@ -4269,7 +4269,7 @@ c_common_signed_or_unsigned_type (int unsignedp, tree type)
if (!INTEGRAL_TYPE_P (type)
|| TYPE_UNSIGNED (type) == unsignedp)
- return TTYPE (type);
+ return type;
#define TYPE_OK(node) \
(TYPE_MODE (type) == TYPE_MODE (node) \
@@ -8715,7 +8715,7 @@ handle_visibility_type_attribute (ttype **node, tree name, tree args,
else if (TYPE_FIELDS (*node))
{
error ("%qE attribute ignored because %qT is already defined",
- name, TREE_CAST (*node));
+ name, *node);
return NULL_TREE;
}
@@ -12753,6 +12753,42 @@ make_tree_vector_copy (const vec<tree, va_gc> *orig)
return ret;
}
+/* Same thing for a type vector. */
+typedef vec<ttype *, va_gc> *ttype_gc_vec;
+static GTY((deletable)) vec<ttype_gc_vec, va_gc> *ttype_vector_cache;
+
+/* Return a new vector from the cache. If the cache is empty,
+ allocate a new vector. These vectors are GC'ed, so it is OK if the
+ pointer is not released.. */
+
+vec<ttype *, va_gc> *
+make_ttype_vector (void)
+{
+ if (ttype_vector_cache && !ttype_vector_cache->is_empty ())
+ return ttype_vector_cache->pop ();
+ else
+ {
+ /* Passing 0 to vec::alloc returns NULL, and our callers require
+ that we always return a non-NULL value. The vector code uses
+ 4 when growing a NULL vector, so we do too. */
+ vec<ttype *, va_gc> *v;
+ vec_alloc (v, 4);
+ return v;
+ }
+}
+
+/* Release a vector of trees back to the cache. */
+
+void
+release_ttype_vector (vec<ttype *, va_gc> *vec)
+{
+ if (vec != NULL)
+ {
+ vec->truncate (0);
+ vec_safe_push (ttype_vector_cache, vec);
+ }
+}
+
/* Return true if KEYWORD starts a type specifier. */
bool
diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h
index 919e3b8ce4f..139215c729d 100644
--- a/gcc/c-family/c-common.h
+++ b/gcc/c-family/c-common.h
@@ -811,7 +811,7 @@ extern tree c_common_fixed_point_type_for_size (unsigned int, unsigned int,
int, int);
extern ttype *c_common_unsigned_type (tree);
extern ttype *c_common_signed_type (tree);
-extern ttype *c_common_signed_or_unsigned_type (int, tree);
+extern ttype *c_common_signed_or_unsigned_type (int, ttype_p);
extern void c_common_init_ts (void);
extern tree c_build_bitfield_integer_type (unsigned HOST_WIDE_INT, int);
extern enum conversion_safety unsafe_conversion_p (location_t, tree, tree,
@@ -875,7 +875,7 @@ extern tree pointer_int_sum (location_t, enum tree_code, tree, tree,
bool = true);
/* Add qualifiers to a type, in the fashion for C. */
-extern tree c_build_qualified_type (tree, int);
+extern ttype *c_build_qualified_type (tree, int);
/* Build tree nodes and builtin functions common to both C and C++ language
frontends. */
@@ -1090,6 +1090,9 @@ extern vec<tree, va_gc> *make_tree_vector_single (tree);
extern vec<tree, va_gc> *make_tree_vector_from_list (tree);
extern vec<tree, va_gc> *make_tree_vector_copy (const vec<tree, va_gc> *);
+extern vec<ttype *, va_gc> *make_ttype_vector (void);
+extern void release_ttype_vector (vec<ttype *, va_gc> *);
+
/* Used for communication between c_common_type_for_mode and
c_register_builtin_type. */
extern GTY(()) tree registered_builtin_types;
diff --git a/gcc/c-family/c-format.c b/gcc/c-family/c-format.c
index 92bb7edfa3d..c64d50f449b 100644
--- a/gcc/c-family/c-format.c
+++ b/gcc/c-family/c-format.c
@@ -142,6 +142,11 @@ location_from_offset (location_t loc, int offset)
return linemap_position_for_loc_and_offset (line_table, loc, column);
}
+/* Mark the tree and ttype nodes so we can compare for equality when checking
+ for type compatibility. the langhooks type_compatible_p() routine will
+ not consider a derived class to be the same. */
+static ttype *tree_ptr_node = NULL;
+static ttype *ttype_ptr_node = NULL;
/* Check that we have a pointer to a string suitable for use as a format.
The default is to check for a char type.
For objective-c dialects, this is extended to include references to string
@@ -2568,6 +2573,11 @@ check_format_types (location_t loc, format_wanted_type *types)
/* Check the type of the "real" argument, if there's a type we want. */
if (lang_hooks.types_compatible_p (wanted_type, cur_type))
continue;
+ /* ttype is derived from tree, but types_compatible_p wont match derived
+ types... so manually check for ttype passed to a tree. */
+ if (cur_type == ttype_ptr_node && wanted_type == tree_ptr_node
+ && tree_ptr_node && ttype_ptr_node)
+ continue;
/* If we want 'void *', allow any pointer type.
(Anything else would already have got a warning.)
With -Wpedantic, only allow pointers to void and to character
@@ -2859,17 +2869,20 @@ init_dynamic_gfc_info (void)
static void
init_dynamic_diag_info (void)
{
- static ttype *t, *loc, *hwi;
+ static ttype *loc, *hwi;
tree x;
- if (!loc || !t || !hwi)
+ if (!loc || !hwi || !tree_ptr_node || !ttype_ptr_node)
{
static format_char_info *diag_fci, *tdiag_fci, *cdiag_fci, *cxxdiag_fci;
static format_length_info *diag_ls;
unsigned int i;
- loc = t = hwi = 0;
+ loc = hwi = NULL;
+ tree_ptr_node = NULL;
+ ttype_ptr_node = NULL;
+
/* For the GCC-diagnostics custom format specifiers to work, one
must have declared 'tree' and/or 'location_t' prior to using
those attributes. If we haven't seen these declarations then
@@ -2900,10 +2913,24 @@ init_dynamic_diag_info (void)
else if (TREE_CODE (TREE_TYPE (x)) != POINTER_TYPE)
error ("%<tree%> is not defined as a pointer type");
else
- t = TREE_TTYPE (TREE_TYPE (x));
+ tree_ptr_node = TREE_TTYPE (TREE_TYPE (x));
}
}
+ /* Set the ttype pointer node. */
+ if ((x = maybe_get_identifier ("ttype")))
+ {
+ x = identifier_global_value (x);
+ if (x)
+ {
+ if (TREE_CODE (x) != TYPE_DECL)
+ error ("%<ttype%> is not defined as a type");
+ else
+ ttype_ptr_node = TREE_TTYPE (x);
+ }
+ }
+
+
/* Find the underlying type for HOST_WIDE_INT. For the %w
length modifier to work, one must have issued: "typedef
HOST_WIDE_INT __gcc_host_wide_int__;" in one's source code
@@ -2961,10 +2988,10 @@ init_dynamic_diag_info (void)
xmemdup (gcc_diag_char_table,
sizeof (gcc_diag_char_table),
sizeof (gcc_diag_char_table));
- if (t)
+ if (tree_ptr_node)
{
i = find_char_info_specifier_index (diag_fci, 'K');
- diag_fci[i].types[0].type = &t;
+ diag_fci[i].types[0].type = &tree_ptr_node;
diag_fci[i].pointer_count = 1;
}
@@ -2975,14 +3002,14 @@ init_dynamic_diag_info (void)
xmemdup (gcc_tdiag_char_table,
sizeof (gcc_tdiag_char_table),
sizeof (gcc_tdiag_char_table));
- if (t)
+ if (tree_ptr_node)
{
/* All specifiers taking a tree share the same struct. */
i = find_char_info_specifier_index (tdiag_fci, 'D');
- tdiag_fci[i].types[0].type = &t;
+ tdiag_fci[i].types[0].type = &tree_ptr_node;
tdiag_fci[i].pointer_count = 1;
i = find_char_info_specifier_index (tdiag_fci, 'K');
- tdiag_fci[i].types[0].type = &t;
+ tdiag_fci[i].types[0].type = &tree_ptr_node;
tdiag_fci[i].pointer_count = 1;
}
@@ -2993,14 +3020,14 @@ init_dynamic_diag_info (void)
xmemdup (gcc_cdiag_char_table,
sizeof (gcc_cdiag_char_table),
sizeof (gcc_cdiag_char_table));
- if (t)
+ if (tree_ptr_node)
{
/* All specifiers taking a tree share the same struct. */
i = find_char_info_specifier_index (cdiag_fci, 'D');
- cdiag_fci[i].types[0].type = &t;
+ cdiag_fci[i].types[0].type = &tree_ptr_node;
cdiag_fci[i].pointer_count = 1;
i = find_char_info_specifier_index (cdiag_fci, 'K');
- cdiag_fci[i].types[0].type = &t;
+ cdiag_fci[i].types[0].type = &tree_ptr_node;
cdiag_fci[i].pointer_count = 1;
}
@@ -3011,14 +3038,14 @@ init_dynamic_diag_info (void)
xmemdup (gcc_cxxdiag_char_table,
sizeof (gcc_cxxdiag_char_table),
sizeof (gcc_cxxdiag_char_table));
- if (t)
+ if (tree_ptr_node)
{
/* All specifiers taking a tree share the same struct. */
i = find_char_info_specifier_index (cxxdiag_fci, 'D');
- cxxdiag_fci[i].types[0].type = &t;
+ cxxdiag_fci[i].types[0].type = &tree_ptr_node;
cxxdiag_fci[i].pointer_count = 1;
i = find_char_info_specifier_index (cxxdiag_fci, 'K');
- cxxdiag_fci[i].types[0].type = &t;
+ cxxdiag_fci[i].types[0].type = &tree_ptr_node;
cxxdiag_fci[i].pointer_count = 1;
}
}
diff --git a/gcc/c/c-tree.h b/gcc/c/c-tree.h
index 04991f7261c..5e3a44a41c7 100644
--- a/gcc/c/c-tree.h
+++ b/gcc/c/c-tree.h
@@ -584,7 +584,7 @@ extern int comptypes_check_different_types (tree, tree, bool *);
extern bool c_vla_type_p (const_tree);
extern bool c_mark_addressable (tree);
extern void c_incomplete_type_error (const_tree, const_tree);
-extern tree c_type_promotes_to (tree);
+extern ttype *c_type_promotes_to (ttype_p);
extern struct c_expr default_function_array_conversion (location_t,
struct c_expr);
extern struct c_expr default_function_array_read_conversion (location_t,
diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c
index 47df986a148..d22d71793db 100644
--- a/gcc/c/c-typeck.c
+++ b/gcc/c/c-typeck.c
@@ -261,10 +261,10 @@ c_incomplete_type_error (const_tree value, const_tree type)
/* Given a type, apply default promotions wrt unnamed function
arguments and return the new type. */
-tree
-c_type_promotes_to (tree type)
+ttype *
+c_type_promotes_to (ttype_p type)
{
- tree ret = NULL_TREE;
+ ttype *ret = NULL;
if (TYPE_MAIN_VARIANT (type) == float_type_node)
ret = double_type_node;
@@ -3321,7 +3321,7 @@ convert_arguments (location_t loc, vec<location_t> arg_loc, tree typelist,
warning_at (ploc, OPT_Wdouble_promotion,
"implicit conversion from %qT to %qT when passing "
"argument to function",
- valtype, TREE_CAST(double_type_node));
+ valtype, double_type_node);
parmval = convert (double_type_node, val);
}
}
@@ -13063,20 +13063,20 @@ c_finish_transaction (location_t loc, tree block, int flags)
/* Make a variant type in the proper way for C/C++, propagating qualifiers
down to the element type of an array. */
-tree
+ttype *
c_build_qualified_type (tree type, int type_quals)
{
if (type == error_mark_node)
- return type;
+ return error_type_node;
if (TREE_CODE (type) == ARRAY_TYPE)
{
- tree t;
- tree element_type = c_build_qualified_type (TREE_TYPE (type),
+ ttype *t;
+ ttype *element_type = c_build_qualified_type (TREE_TYPE (type),
type_quals);
/* See if we already have an identically qualified type. */
- for (t = TYPE_MAIN_VARIANT (type); t; t = TYPE_NEXT_VARIANT (t))
+ for (t = TTYPE_MAIN_VARIANT (type); t; t = TTYPE_NEXT_VARIANT (t))
{
if (TYPE_QUALS (strip_array_types (t)) == type_quals
&& TYPE_NAME (t) == TYPE_NAME (type)
@@ -13122,7 +13122,7 @@ c_build_qualified_type (tree type, int type_quals)
type_quals &= ~TYPE_QUAL_RESTRICT;
}
- tree var_type = build_qualified_type (type, type_quals);
+ ttype *var_type = build_qualified_type (type, type_quals);
/* A variant type does not inherit the list of incomplete vars from the
type main variant. */
if (TREE_CODE (var_type) == RECORD_TYPE
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index b87d3939103..acac613ae79 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -179,10 +179,10 @@ static void add_builtin_candidates
tree, tree *, int, tsubst_flags_t);
static void add_builtin_candidate
(struct z_candidate **, enum tree_code, enum tree_code,
- tree, tree, tree, tree *, tree *, int, tsubst_flags_t);
+ tree, tree, tree, tree *, type_array, int, tsubst_flags_t);
static bool is_complete (tree);
static void build_builtin_candidate
- (struct z_candidate **, tree, tree, tree, tree *, tree *,
+ (struct z_candidate **, tree, tree, tree, tree *, type_array,
int, tsubst_flags_t);
static struct z_candidate *add_conv_candidate
(struct z_candidate **, tree, tree, const vec<tree, va_gc> *, tree,
@@ -2253,7 +2253,7 @@ add_conv_candidate (struct z_candidate **candidates, tree fn, tree obj,
static void
build_builtin_candidate (struct z_candidate **candidates, tree fnname,
- tree type1, tree type2, tree *args, tree *argtypes,
+ tree type1, tree type2, tree *args, type_array argtypes,
int flags, tsubst_flags_t complain)
{
conversion *t;
@@ -2362,7 +2362,7 @@ promoted_arithmetic_type_p (tree type)
static void
add_builtin_candidate (struct z_candidate **candidates, enum tree_code code,
enum tree_code code2, tree fnname, tree type1,
- tree type2, tree *args, tree *argtypes, int flags,
+ tree type2, tree *args, type_array argtypes, int flags,
tsubst_flags_t complain)
{
switch (code)
@@ -2791,8 +2791,8 @@ add_builtin_candidate (struct z_candidate **candidates, enum tree_code code,
(candidates, fnname, type1, type2, args, argtypes, flags, complain);
}
-tree
-type_decays_to (tree type)
+ttype *
+type_decays_to (ttype_p type)
{
if (TREE_CODE (type) == ARRAY_TYPE)
return build_pointer_type (TREE_TYPE (type));
@@ -2821,10 +2821,10 @@ add_builtin_candidates (struct z_candidate **candidates, enum tree_code code,
{
int ref1, i;
int enum_p = 0;
- tree type, argtypes[3], t;
+ ttype *type, *argtypes[3], *t;
/* TYPES[i] is the set of possible builtin-operator parameter types
we will consider for the Ith argument. */
- vec<tree, va_gc> *types[2];
+ vec<ttype *, va_gc> *types[2];
unsigned ix;
for (i = 0; i < 3; ++i)
@@ -2832,7 +2832,7 @@ add_builtin_candidates (struct z_candidate **candidates, enum tree_code code,
if (args[i])
argtypes[i] = unlowered_expr_type (args[i]);
else
- argtypes[i] = NULL_TREE;
+ argtypes[i] = NULL;
}
switch (code)
@@ -2887,8 +2887,8 @@ add_builtin_candidates (struct z_candidate **candidates, enum tree_code code,
ref1 = 0;
}
- types[0] = make_tree_vector ();
- types[1] = make_tree_vector ();
+ types[0] = make_ttype_vector ();
+ types[1] = make_ttype_vector ();
for (i = 0; i < 2; ++i)
{
@@ -2906,9 +2906,9 @@ add_builtin_candidates (struct z_candidate **candidates, enum tree_code code,
if (code == COND_EXPR)
{
if (real_lvalue_p (args[i]))
- vec_safe_push (types[i], TREE_CAST (build_reference_type (argtypes[i])));
+ vec_safe_push (types[i], build_reference_type (argtypes[i]));
- vec_safe_push (types[i], TYPE_MAIN_VARIANT (argtypes[i]));
+ vec_safe_push (types[i], TTYPE_MAIN_VARIANT (argtypes[i]));
}
else if (! convs)
@@ -2916,7 +2916,7 @@ add_builtin_candidates (struct z_candidate **candidates, enum tree_code code,
for (; convs; convs = TREE_CHAIN (convs))
{
- type = TREE_TYPE (convs);
+ type = TREE_TTYPE (convs);
if (i == 0 && ref1
&& (TREE_CODE (type) != REFERENCE_TYPE
@@ -2943,7 +2943,7 @@ add_builtin_candidates (struct z_candidate **candidates, enum tree_code code,
else
{
if (code == COND_EXPR && real_lvalue_p (args[i]))
- vec_safe_push (types[i], TREE_CAST (build_reference_type (argtypes[i])));
+ vec_safe_push (types[i], build_reference_type (argtypes[i]));
type = non_reference (argtypes[i]);
if (i != 0 || ! ref1)
{
@@ -2962,7 +2962,7 @@ add_builtin_candidates (struct z_candidate **candidates, enum tree_code code,
FOR_EACH_VEC_ELT_REVERSE (*(types[0]), ix, t)
{
unsigned jx;
- tree u;
+ ttype *u;
if (!types[1]->is_empty ())
FOR_EACH_VEC_ELT_REVERSE (*(types[1]), jx, u)
@@ -2975,8 +2975,8 @@ add_builtin_candidates (struct z_candidate **candidates, enum tree_code code,
NULL_TREE, args, argtypes, flags, complain);
}
- release_tree_vector (types[0]);
- release_tree_vector (types[1]);
+ release_ttype_vector (types[0]);
+ release_ttype_vector (types[1]);
}
@@ -6735,7 +6735,7 @@ convert_arg_to_ellipsis (tree arg, tsubst_flags_t complain)
warning_at (loc, OPT_Wdouble_promotion,
"implicit conversion from %qT to %qT when passing "
"argument to function",
- arg_type, TREE_CAST(double_type_node));
+ arg_type, double_type_node);
arg = convert_to_real (double_type_node, arg);
}
else if (NULLPTR_TYPE_P (arg_type))
@@ -6847,16 +6847,16 @@ build_x_va_arg (source_location loc, tree expr, tree type)
would have happened when passed via ellipsis. Return the promoted
type, or the passed type if there is no change. */
-tree
-cxx_type_promotes_to (tree type)
+ttype *
+cxx_type_promotes_to (ttype_p type)
{
- tree promote;
+ ttype *promote;
/* Perform the array-to-pointer and function-to-pointer
conversions. */
- type = type_decays_to (type);
+ promote = type_decays_to (type);
- promote = type_promotes_to (type);
+ promote = type_promotes_to (promote);
if (same_type_p (type, promote))
promote = type;
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 3979317965b..57887ef9e8d 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -5471,7 +5471,7 @@ extern tree build_call_n (tree, int, ...);
extern bool null_ptr_cst_p (tree);
extern bool null_member_pointer_value_p (tree);
extern bool sufficient_parms_p (const_tree);
-extern tree type_decays_to (tree);
+extern ttype *type_decays_to (ttype_p);
extern tree build_user_type_conversion (tree, tree, int,
tsubst_flags_t);
extern tree build_new_function_call (tree, vec<tree, va_gc> **, bool,
@@ -5507,7 +5507,7 @@ extern tree convert_default_arg (tree, tree, tree, int,
tsubst_flags_t);
extern tree convert_arg_to_ellipsis (tree, tsubst_flags_t);
extern tree build_x_va_arg (source_location, tree, tree);
-extern tree cxx_type_promotes_to (tree);
+extern ttype *cxx_type_promotes_to (ttype_p);
extern tree type_passed_as (tree);
extern tree convert_for_arg_passing (tree, tree, tsubst_flags_t);
extern bool is_properly_derived_from (tree, tree);
@@ -5627,7 +5627,7 @@ extern tree convert_to_void (tree, impl_conv_void,
extern tree convert_force (tree, tree, int,
tsubst_flags_t);
extern tree build_expr_type_conversion (int, tree, bool);
-extern tree type_promotes_to (tree);
+extern ttype *type_promotes_to (ttype_p);
extern tree perform_qualification_conversions (tree, tree);
extern bool tx_safe_fn_type_p (tree);
extern tree tx_unsafe_fn_variant (tree);
@@ -5764,7 +5764,7 @@ extern tree grokfield (const cp_declarator *, cp_decl_specifier_seq *,
tree, bool, tree, tree);
extern tree grokbitfield (const cp_declarator *, cp_decl_specifier_seq *,
tree, tree);
-extern ttype *cp_reconstruct_complex_type (tree, tree);
+extern ttype *cp_reconstruct_complex_type (ttype_p, ttype_p);
extern bool attributes_naming_typedef_ok (tree);
extern void cplus_decl_attributes (tree *, tree, int);
extern void finish_anon_union (tree);
@@ -6423,7 +6423,7 @@ extern tree build_cplus_new (tree, tree, tsubst_flags_t);
extern tree build_aggr_init_expr (tree, tree);
extern tree get_target_expr (tree);
extern tree get_target_expr_sfinae (tree, tsubst_flags_t);
-extern ttype *build_cplus_array_type (tree, tree);
+extern ttype *build_cplus_array_type (ttype_p, tree);
extern tree build_array_of_n_type (tree, int);
extern bool array_of_runtime_bound_p (tree);
extern tree build_array_copy (tree);
@@ -6432,7 +6432,7 @@ extern void diagnose_non_constexpr_vec_init (tree);
extern tree hash_tree_cons (tree, tree, tree);
extern tree hash_tree_chain (tree, tree);
extern tree build_qualified_name (tree, tree, tree, bool);
-extern ttype *build_ref_qualified_type (tree, cp_ref_qualifier);
+extern ttype *build_ref_qualified_type (ttype_p, cp_ref_qualifier);
extern int is_overloaded_fn (tree);
extern tree dependent_name (tree);
extern tree get_fns (tree);
@@ -6443,7 +6443,7 @@ extern tree ovl_scope (tree);
extern bool non_static_member_function_p (tree);
extern const char *cxx_printable_name (tree, int);
extern const char *cxx_printable_name_translate (tree, int);
-extern ttype *build_exception_variant (tree, tree);
+extern ttype *build_exception_variant (ttype_p, tree);
extern tree bind_template_template_parm (tree, tree);
extern tree array_type_nelts_total (tree);
extern tree array_type_nelts_top (tree);
@@ -6468,11 +6468,11 @@ extern tree make_ptrmem_cst (tree, tree);
extern ttype *cp_build_type_attribute_variant (tree, tree);
extern tree cp_build_reference_type (tree, bool);
extern tree move (tree);
-extern ttype *cp_build_qualified_type_real (tree, int, tsubst_flags_t);
+extern ttype *cp_build_qualified_type_real (ttype_p, int, tsubst_flags_t);
#define cp_build_qualified_type(TYPE, QUALS) \
cp_build_qualified_type_real ((TYPE), (QUALS), tf_warning_or_error)
extern bool cv_qualified_p (const_tree);
-extern tree cv_unqualified (tree);
+extern ttype *cv_unqualified (tree);
extern special_function_kind special_function_p (const_tree);
extern int count_trees (tree);
extern int char_type_p (tree);
@@ -6527,8 +6527,8 @@ extern tree cxx_sizeof_or_alignof_expr (tree, enum tree_code, bool);
extern tree cxx_sizeof_or_alignof_type (tree, enum tree_code, bool);
extern tree cxx_alignas_expr (tree);
extern tree cxx_sizeof_nowarn (tree);
-extern tree is_bitfield_expr_with_lowered_type (const_tree);
-extern tree unlowered_expr_type (const_tree);
+extern ttype *is_bitfield_expr_with_lowered_type (const_tree);
+extern ttype *unlowered_expr_type (const_tree);
extern tree decay_conversion (tree,
tsubst_flags_t,
bool = true);
@@ -6594,7 +6594,8 @@ extern tree build_ptrmemfunc (tree, tree, int, bool,
extern int cp_type_quals (const_tree);
extern int type_memfn_quals (const_tree);
extern cp_ref_qualifier type_memfn_rqual (const_tree);
-extern ttype *apply_memfn_quals (tree, cp_cv_quals, cp_ref_qualifier);
+extern ttype *apply_memfn_quals (ttype_p, cp_cv_quals,
+ cp_ref_qualifier);
extern bool cp_has_mutable_p (const_tree);
extern bool at_least_as_qualified_p (const_tree, const_tree);
extern void cp_apply_type_quals_to_decl (int, tree);
@@ -6619,7 +6620,7 @@ extern tree build_simple_component_ref (tree, tree);
extern tree build_ptrmemfunc_access_expr (tree, tree);
extern tree build_address (tree);
extern tree build_nop (tree, tree);
-extern tree non_reference (tree);
+extern ttype *non_reference (ttype_p);
extern tree lookup_anon_field (tree, tree);
extern bool invalid_nonstatic_memfn_p (location_t, tree,
tsubst_flags_t);
diff --git a/gcc/cp/cvt.c b/gcc/cp/cvt.c
index e764ee15243..baecf985494 100644
--- a/gcc/cp/cvt.c
+++ b/gcc/cp/cvt.c
@@ -1692,18 +1692,19 @@ build_expr_type_conversion (int desires, tree expr, bool complain)
/* Implements integral promotion (4.1) and float->double promotion. */
-tree
-type_promotes_to (tree type)
+ttype *
+type_promotes_to (ttype_p orig_type)
{
- tree promoted_type;
+ ttype *promoted_type;
+ ttype *type;
- if (type == error_mark_node)
- return error_mark_node;
+ if (orig_type == error_mark_node)
+ return error_type_node;
- type = TYPE_MAIN_VARIANT (type);
+ type = TTYPE_MAIN_VARIANT (orig_type);
/* Check for promotions of target-defined types first. */
- promoted_type = targetm.promoted_type (type);
+ promoted_type = TTYPE (targetm.promoted_type (type));
if (promoted_type)
return promoted_type;
@@ -1722,10 +1723,10 @@ type_promotes_to (tree type)
{
int precision = MAX (TYPE_PRECISION (type),
TYPE_PRECISION (integer_type_node));
- tree totype = c_common_type_for_size (precision, 0);
- tree prom = type;
+ ttype *totype = c_common_type_for_size (precision, 0);
+ ttype *prom = type;
if (TREE_CODE (prom) == ENUMERAL_TYPE)
- prom = ENUM_UNDERLYING_TYPE (prom);
+ prom = TTYPE (ENUM_UNDERLYING_TYPE (prom));
if (TYPE_UNSIGNED (prom)
&& ! int_fits_type_p (TYPE_MAX_VALUE (prom), totype))
prom = c_common_type_for_size (precision, 1);
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index a8d590cdb57..1e313e36d93 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -12280,7 +12280,7 @@ grok_op_properties (tree decl, bool complain)
|| !same_type_p (TYPE_MAIN_VARIANT (TREE_TYPE (ret)),
arg))
warning (OPT_Weffc__, "prefix %qD should return %qT", decl,
- TREE_CAST (build_reference_type (arg)));
+ build_reference_type (arg));
}
else
{
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index 2a913edc41f..6e56d2a2419 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -1314,7 +1314,7 @@ attributes_naming_typedef_ok (tree attrs)
/* Like reconstruct_complex_type, but handle also template trees. */
ttype *
-cp_reconstruct_complex_type (tree type, tree bottom)
+cp_reconstruct_complex_type (ttype_p type, ttype_p bottom)
{
ttype *inner, *outer;
bool late_return_type_p = false;
@@ -1367,7 +1367,7 @@ cp_reconstruct_complex_type (tree type, tree bottom)
outer = build_offset_type (TYPE_OFFSET_BASETYPE (type), inner);
}
else
- return TTYPE (bottom);
+ return bottom;
if (TYPE_ATTRIBUTES (type))
outer = cp_build_type_attribute_variant (outer, TYPE_ATTRIBUTES (type));
@@ -1655,7 +1655,7 @@ coerce_new_type (tree type)
if (!same_type_p (TREE_TYPE (type), ptr_type_node))
{
e = 1;
- error ("%<operator new%> must return type %qT", TREE_CAST (ptr_type_node));
+ error ("%<operator new%> must return type %qT", ptr_type_node);
}
if (args && args != void_list_node)
@@ -1683,7 +1683,7 @@ coerce_new_type (tree type)
if (e == 2)
permerror (input_location, "%<operator new%> takes type %<size_t%> (%qT) "
- "as first parameter", TREE_CAST (size_type_node));
+ "as first parameter", size_type_node);
switch (e)
{
@@ -1711,7 +1711,7 @@ coerce_delete_type (tree type)
if (!same_type_p (TREE_TYPE (type), void_type_node))
{
e = 1;
- error ("%<operator delete%> must return type %qT", TREE_CAST (void_type_node));
+ error ("%<operator delete%> must return type %qT", void_type_node);
}
if (!args || args == void_list_node
@@ -1721,7 +1721,7 @@ coerce_delete_type (tree type)
if (args && args != void_list_node)
args = TREE_CHAIN (args);
error ("%<operator delete%> takes type %qT as first parameter",
- TREE_CAST (ptr_type_node));
+ ptr_type_node);
}
switch (e)
{
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index de9e084dd5f..12452e689ff 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -4025,14 +4025,14 @@ cp_parser_userdef_numeric_literal (cp_parser *parser)
{
warning_at (token->location, OPT_Woverflow,
"integer literal exceeds range of %qT type",
- TREE_CAST (long_long_unsigned_type_node));
+ long_long_unsigned_type_node);
}
else
{
if (overflow > 0)
warning_at (token->location, OPT_Woverflow,
"floating literal exceeds range of %qT type",
- TREE_CAST (long_double_type_node));
+ long_double_type_node);
else if (overflow < 0)
warning_at (token->location, OPT_Woverflow,
"floating literal truncated to zero");
@@ -4130,7 +4130,7 @@ cp_parser_userdef_string_literal (tree literal)
release_tree_vector (args);
error ("unable to find string literal operator %qD with %qT, %qT arguments",
- name, TREE_TYPE (value), TREE_CAST (size_type_node));
+ name, TREE_TYPE (value), size_type_node);
return error_mark_node;
}
diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
index 57d671b4d8e..f6890464d37 100644
--- a/gcc/cp/tree.c
+++ b/gcc/cp/tree.c
@@ -805,7 +805,7 @@ set_array_type_canon (tree t, tree elt_type, tree index_type)
the element type. */
ttype *
-build_cplus_array_type (tree elt_type, tree index_type)
+build_cplus_array_type (ttype_p elt_type, tree index_type)
{
ttype *t;
@@ -833,7 +833,7 @@ build_cplus_array_type (tree elt_type, tree index_type)
hash = TYPE_UID (elt_type);
if (index_type)
hash ^= TYPE_UID (index_type);
- cai.type = TTYPE (elt_type);
+ cai.type = elt_type;
cai.domain = index_type;
ttype **e = cplus_array_htab->find_slot_with_hash (&cai, hash, INSERT);
@@ -996,7 +996,7 @@ move (tree expr)
/* Used by the C++ front end to build qualified array types. However,
the C version of this function does not properly maintain canonical
types (which are not used in C). */
-tree
+ttype *
c_build_qualified_type (tree type, int type_quals)
{
return cp_build_qualified_type (type, type_quals);
@@ -1024,7 +1024,7 @@ c_build_qualified_type (tree type, int type_quals)
in a similar manner for restricting non-pointer types. */
ttype *
-cp_build_qualified_type_real (tree type,
+cp_build_qualified_type_real (ttype_p type,
int type_quals,
tsubst_flags_t complain)
{
@@ -1035,7 +1035,7 @@ cp_build_qualified_type_real (tree type,
return error_type_node;
if (type_quals == cp_type_quals (type))
- return TTYPE (type);
+ return type;
if (TREE_CODE (type) == ARRAY_TYPE)
{
@@ -1130,9 +1130,9 @@ cp_build_qualified_type_real (tree type,
return error_type_node;
else
{
- tree bad_type = build_qualified_type (ptr_type_node, bad_quals);
+ ttype *bad_type = build_qualified_type (ptr_type_node, bad_quals);
error ("%qV qualifiers cannot be applied to %qT",
- bad_type, type);
+ bad_type, type.as_a_ttype ());
}
/* Retrieve (or create) the appropriately qualified variant. */
@@ -1152,13 +1152,13 @@ cp_build_qualified_type_real (tree type,
/* Return TYPE with const and volatile removed. */
-tree
+ttype *
cv_unqualified (tree type)
{
int quals;
if (type == error_mark_node)
- return type;
+ return error_type_node;
quals = cp_type_quals (type);
quals &= ~(TYPE_QUAL_CONST|TYPE_QUAL_VOLATILE);
@@ -1878,12 +1878,12 @@ cp_check_qualified_type (const_tree cand, const_tree base, int type_quals,
/* Build the FUNCTION_TYPE or METHOD_TYPE with the ref-qualifier RQUAL. */
ttype *
-build_ref_qualified_type (tree type, cp_ref_qualifier rqual)
+build_ref_qualified_type (ttype_p type, cp_ref_qualifier rqual)
{
ttype *t;
if (rqual == type_memfn_rqual (type))
- return TTYPE (type);
+ return type;
int type_quals = TYPE_QUALS (type);
tree raises = TYPE_RAISES_EXCEPTIONS (type);
@@ -2118,13 +2118,13 @@ cxx_printable_name_translate (tree decl, int v)
listed in RAISES. */
ttype *
-build_exception_variant (tree type, tree raises)
+build_exception_variant (ttype_p type, tree raises)
{
ttype *v;
int type_quals;
if (comp_except_specs (raises, TYPE_RAISES_EXCEPTIONS (type), ce_exact))
- return TTYPE (type);
+ return type;
type_quals = TYPE_QUALS (type);
cp_ref_qualifier rqual = type_memfn_rqual (type);
@@ -3701,27 +3701,27 @@ handle_abi_tag_type_attribute (ttype ** node, tree name, tree args,
if (!OVERLOAD_TYPE_P (*node))
{
error ("%qE attribute applied to non-class, non-enum type %qT",
- name, TREE_CAST (*node));
+ name, *node);
goto fail;
}
else if (!(flags & (int)ATTR_FLAG_TYPE_IN_PLACE))
{
error ("%qE attribute applied to %qT after its definition",
- name, TREE_CAST (*node));
+ name, *node);
goto fail;
}
else if (CLASS_TYPE_P (*node)
&& CLASSTYPE_TEMPLATE_INSTANTIATION (*node))
{
warning (OPT_Wattributes, "ignoring %qE attribute applied to "
- "template instantiation %qT", name, TREE_CAST (*node));
+ "template instantiation %qT", name, *node);
goto fail;
}
else if (CLASS_TYPE_P (*node)
&& CLASSTYPE_TEMPLATE_SPECIALIZATION (*node))
{
warning (OPT_Wattributes, "ignoring %qE attribute applied to "
- "template specialization %qT", name, TREE_CAST (*node));
+ "template specialization %qT", name, *node);
goto fail;
}
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index 48552d26de1..5a49db7fbdb 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -1848,7 +1848,7 @@ invalid_nonstatic_memfn_p (location_t loc, tree expr, tsubst_flags_t complain)
match the declared type of the bitfield, return the declared type
of the bitfield. Otherwise, return NULL_TREE. */
-tree
+ttype *
is_bitfield_expr_with_lowered_type (const_tree exp)
{
switch (TREE_CODE (exp))
@@ -1857,7 +1857,7 @@ is_bitfield_expr_with_lowered_type (const_tree exp)
if (!is_bitfield_expr_with_lowered_type (TREE_OPERAND (exp, 1)
? TREE_OPERAND (exp, 1)
: TREE_OPERAND (exp, 0)))
- return NULL_TREE;
+ return NULL;
return is_bitfield_expr_with_lowered_type (TREE_OPERAND (exp, 2));
case COMPOUND_EXPR:
@@ -1873,11 +1873,11 @@ is_bitfield_expr_with_lowered_type (const_tree exp)
field = TREE_OPERAND (exp, 1);
if (TREE_CODE (field) != FIELD_DECL || !DECL_BIT_FIELD_TYPE (field))
- return NULL_TREE;
+ return NULL;
if (same_type_ignoring_top_level_qualifiers_p
(TREE_TYPE (exp), DECL_BIT_FIELD_TYPE (field)))
- return NULL_TREE;
- return DECL_BIT_FIELD_TYPE (field);
+ return NULL;
+ return TTYPE (DECL_BIT_FIELD_TYPE (field));
}
CASE_CONVERT:
@@ -1887,7 +1887,7 @@ is_bitfield_expr_with_lowered_type (const_tree exp)
/* Fallthrough. */
default:
- return NULL_TREE;
+ return NULL;
}
}
@@ -1895,11 +1895,11 @@ is_bitfield_expr_with_lowered_type (const_tree exp)
bitfield with a lowered type, the type of EXP is returned, rather
than NULL_TREE. */
-tree
+ttype *
unlowered_expr_type (const_tree exp)
{
- tree type;
- tree etype = TREE_TYPE (exp);
+ ttype *type;
+ ttype *etype = TREE_TTYPE (exp);
type = is_bitfield_expr_with_lowered_type (exp);
if (type)
@@ -9086,13 +9086,14 @@ type_memfn_quals (const_tree type)
MEMFN_QUALS and its ref-qualifier to RQUAL. */
ttype *
-apply_memfn_quals (tree type, cp_cv_quals memfn_quals, cp_ref_qualifier rqual)
+apply_memfn_quals (ttype_p type, cp_cv_quals memfn_quals,
+ cp_ref_qualifier rqual)
{
/* Could handle METHOD_TYPE here if necessary. */
gcc_assert (TREE_CODE (type) == FUNCTION_TYPE);
if (TYPE_QUALS (type) == memfn_quals
&& type_memfn_rqual (type) == rqual)
- return (TTYPE (type));
+ return type;
/* This should really have a different TYPE_MAIN_VARIANT, but that gets
complex. */
@@ -9285,11 +9286,11 @@ casts_away_constness (tree t1, tree t2, tsubst_flags_t complain)
/* If T is a REFERENCE_TYPE return the type to which T refers.
Otherwise, return T itself. */
-tree
-non_reference (tree t)
+ttype *
+non_reference (ttype_p t)
{
if (t && TREE_CODE (t) == REFERENCE_TYPE)
- t = TREE_TYPE (t);
+ return TREE_TTYPE (t);
return t;
}
diff --git a/gcc/java/expr.c b/gcc/java/expr.c
index 57e8e68b3c9..c4c0f99a425 100644
--- a/gcc/java/expr.c
+++ b/gcc/java/expr.c
@@ -1673,9 +1673,9 @@ lookup_field (ttype **typep, tree name)
SELF_VALUE is NULL_TREE if looking for a static field. */
tree
-build_field_ref (tree self_value, tree self_class, tree name)
+build_field_ref (tree self_value, ttype_p self_class, tree name)
{
- ttype *base_class = TTYPE (self_class);
+ ttype *base_class = self_class;
tree field_decl = lookup_field (&base_class, name);
if (field_decl == NULL_TREE)
{
diff --git a/gcc/java/java-tree.h b/gcc/java/java-tree.h
index f54e02ed525..b55ce2514e1 100644
--- a/gcc/java/java-tree.h
+++ b/gcc/java/java-tree.h
@@ -975,7 +975,7 @@ extern tree lookup_java_method (tree, tree, tree);
extern tree lookup_argument_method (tree, tree, tree);
extern tree lookup_argument_method_generic (tree, tree, tree, int);
extern int has_method (tree, tree);
-extern ttype *promote_type (tree);
+extern ttype *promote_type (ttype_p);
extern tree get_constant (struct JCF*, int);
extern tree get_name_constant (struct JCF*, int);
extern tree get_class_constant (struct JCF*, int);
@@ -1049,7 +1049,7 @@ extern tree build_invokevirtual (tree, tree, tree);
extern tree build_invokeinterface (tree, tree);
extern tree build_jni_stub (tree);
extern tree invoke_build_dtable (int, vec<tree, va_gc> *);
-extern tree build_field_ref (tree, tree, tree);
+extern tree build_field_ref (tree, ttype_p, tree);
extern tree java_modify_addr_for_volatile (tree);
extern void pushdecl_force_head (tree);
extern tree build_java_binop (enum tree_code, tree, tree, tree);
diff --git a/gcc/java/typeck.c b/gcc/java/typeck.c
index 80b2e0b4110..e789d0fd490 100644
--- a/gcc/java/typeck.c
+++ b/gcc/java/typeck.c
@@ -324,7 +324,7 @@ build_java_array_type (tree element_type, HOST_WIDE_INT length)
/* Promote TYPE to the type actually used for fields and parameters. */
ttype *
-promote_type (tree type)
+promote_type (ttype_p type)
{
switch (TREE_CODE (type))
{
@@ -348,7 +348,7 @@ promote_type (tree type)
}
/* ... else fall through ... */
default:
- return TTYPE (type);
+ return type;
}
}
diff --git a/gcc/langhooks-def.h b/gcc/langhooks-def.h
index 0c81f787fcb..c26a9bb9e59 100644
--- a/gcc/langhooks-def.h
+++ b/gcc/langhooks-def.h
@@ -53,7 +53,7 @@ extern void lhd_print_error_function (diagnostic_context *,
extern void lhd_set_decl_assembler_name (tree);
extern bool lhd_warn_unused_global_decl (const_tree);
extern void lhd_incomplete_type_error (const_tree, const_tree);
-extern tree lhd_type_promotes_to (tree);
+extern ttype *lhd_type_promotes_to (ttype_p);
extern void lhd_register_builtin_type (tree, const char *);
extern bool lhd_decl_ok_for_sibcall (const_tree);
extern size_t lhd_tree_size (enum tree_code);
diff --git a/gcc/langhooks.c b/gcc/langhooks.c
index 64ff68bdc72..5d13110422c 100644
--- a/gcc/langhooks.c
+++ b/gcc/langhooks.c
@@ -183,8 +183,8 @@ lhd_set_decl_assembler_name (tree decl)
}
/* Type promotion for variable arguments. */
-tree
-lhd_type_promotes_to (tree ARG_UNUSED (type))
+ttype *
+lhd_type_promotes_to (ttype_p ARG_UNUSED (type))
{
gcc_unreachable ();
}
diff --git a/gcc/langhooks.h b/gcc/langhooks.h
index 912efc25410..dd7ba21ac17 100644
--- a/gcc/langhooks.h
+++ b/gcc/langhooks.h
@@ -86,7 +86,7 @@ struct lang_hooks_for_types
arguments and return the new type. Return the same type if no
change. Required by any language that supports variadic
arguments. The default hook dies. */
- tree (*type_promotes_to) (tree);
+ ttype *(*type_promotes_to) (ttype_p);
/* Register TYPE as a builtin type with the indicated NAME. The
TYPE is placed in the outermost lexical scope. The semantics
@@ -136,7 +136,7 @@ struct lang_hooks_for_types
we stripped off while looking for the inner type. Similarly for
return values from functions. The argument TYPE is the top of the
chain, and BOTTOM is the new type which we will point to. */
- ttype *(*reconstruct_complex_type) (tree, tree);
+ ttype *(*reconstruct_complex_type) (ttype_p, ttype_p);
/* Returns the tree that represents the underlying data type used to
implement the enumeration. The default implementation will just use
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index 2600fba43a2..44c0ebe13a0 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -382,7 +382,7 @@ remap_decl (tree decl, copy_body_data *id)
}
static ttype *
-remap_type_1 (tree type, copy_body_data *id)
+remap_type_1 (ttype_p type, copy_body_data *id)
{
ttype *new_tree, *t;
@@ -414,7 +414,7 @@ remap_type_1 (tree type, copy_body_data *id)
return new_tree;
}
else
- new_tree = copy_node (TTYPE (type));
+ new_tree = copy_node (type);
insert_decl_map (id, type, new_tree);
@@ -545,7 +545,7 @@ remap_type_1 (tree type, copy_body_data *id)
}
ttype *
-remap_type (tree type, copy_body_data *id)
+remap_type (ttype_p type, copy_body_data *id)
{
tree *node;
ttype *tmp;
@@ -562,7 +562,7 @@ remap_type (tree type, copy_body_data *id)
if (! variably_modified_type_p (type, id->src_fn))
{
insert_decl_map (id, type, type);
- return TTYPE (type);
+ return type;
}
id->remapping_type_depth++;
diff --git a/gcc/tree-inline.h b/gcc/tree-inline.h
index c1f6bb0b211..a3db1ec6a56 100644
--- a/gcc/tree-inline.h
+++ b/gcc/tree-inline.h
@@ -210,7 +210,7 @@ int estimate_num_insns_fn (tree, eni_weights *);
int estimate_num_insns_seq (gimple_seq, eni_weights *);
bool tree_versionable_function_p (tree);
extern tree remap_decl (tree decl, copy_body_data *id);
-extern ttype *remap_type (tree type, copy_body_data *id);
+extern ttype *remap_type (ttype_p type, copy_body_data *id);
extern gimple_seq copy_gimple_seq_and_replace_locals (gimple_seq seq);
extern bool debug_find_tree (tree, tree);
extern tree copy_fn (tree, tree&, tree&);
diff --git a/gcc/tree.c b/gcc/tree.c
index 39a80c800a3..fe1f74a7328 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -2738,6 +2738,19 @@ vec_member (const_tree elem, vec<tree, va_gc> *v)
return false;
}
+/* Return true if ELEM is in V. */
+
+bool
+vec_member (const ttype *elem, vec<ttype *, va_gc> *v)
+{
+ unsigned ix;
+ ttype *t;
+ FOR_EACH_VEC_SAFE_ELT (v, ix, t)
+ if (elem == t)
+ return true;
+ return false;
+}
+
/* Returns element number IDX (zero-origin) of chain CHAIN, or
NULL_TREE. */
@@ -4807,7 +4820,7 @@ build_decl_attribute_variant (tree ddecl, tree attribute)
Record such modified types already made so we don't make duplicates. */
ttype *
-build_type_attribute_qual_variant (tree type, tree attribute, int quals)
+build_type_attribute_qual_variant (ttype_p type, tree attribute, int quals)
{
if (! attribute_list_equal (TYPE_ATTRIBUTES (type), attribute))
{
@@ -4885,7 +4898,7 @@ build_type_attribute_qual_variant (tree type, tree attribute, int quals)
else if (TYPE_QUALS (type) != quals)
type = build_qualified_type (type, quals);
- return TTYPE (type);
+ return type;
}
/* Check if "omp declare simd" attribute arguments, CLAUSES1 and CLAUSES2, are
@@ -6591,12 +6604,12 @@ find_atomic_core_type (tree type)
return NULL_TREE. */
ttype *
-get_qualified_type (tree type, int type_quals)
+get_qualified_type (ttype_p type, int type_quals)
{
ttype *t;
if (TYPE_QUALS (type) == type_quals)
- return TTYPE (type);
+ return type;
/* Search the chain of variants to see if there is already one there just
like the one we need to have. If so, use that existing one. We must
@@ -6612,9 +6625,9 @@ get_qualified_type (tree type, int type_quals)
exist. This function never returns NULL_TREE. */
ttype *
-build_qualified_type (tree type, int type_quals)
+build_qualified_type (ttype_p type, int type_quals)
{
- tree t;
+ ttype *t;
/* See if we already have the appropriate qualified variant. */
t = get_qualified_type (type, type_quals);
@@ -6654,7 +6667,7 @@ build_qualified_type (tree type, int type_quals)
}
- return TTYPE (t);
+ return t;
}
/* Create a variant of type T with alignment ALIGN. */
@@ -6684,9 +6697,9 @@ build_aligned_type (tree type, unsigned int align)
TYPE_CANONICAL points to itself. */
ttype *
-build_distinct_type_copy (tree type)
+build_distinct_type_copy (ttype_p type)
{
- ttype *t = copy_node (TTYPE (type));
+ ttype *t = copy_node (type);
TYPE_POINTER_TO (t) = 0;
TYPE_REFERENCE_TO (t) = 0;
@@ -10276,7 +10289,7 @@ build_common_tree_nodes (bool signed_char, bool short_double)
MAKE_FIXED_MODE_NODE (accum, ta, TA)
{
- tree t = targetm.build_builtin_va_list ();
+ ttype *t = TTYPE (targetm.build_builtin_va_list ());
/* Many back-ends define record types without setting TYPE_NAME.
If we copied the record type here, we'd keep the original
@@ -10286,7 +10299,7 @@ build_common_tree_nodes (bool signed_char, bool short_double)
if (TREE_CODE (t) != RECORD_TYPE)
t = build_variant_type_copy (t);
- va_list_type_node = TTYPE (t);
+ va_list_type_node = t;
}
}
@@ -10592,7 +10605,7 @@ build_common_builtin_nodes (void)
new type which we will point to. */
ttype *
-reconstruct_complex_type (tree type, tree bottom)
+reconstruct_complex_type (ttype_p type, ttype_p bottom)
{
ttype *inner, *outer;
@@ -10635,7 +10648,7 @@ reconstruct_complex_type (tree type, tree bottom)
outer = build_offset_type (TYPE_OFFSET_BASETYPE (type), inner);
}
else
- return TTYPE (bottom);
+ return bottom;
return build_type_attribute_qual_variant (outer, TYPE_ATTRIBUTES (type),
TYPE_QUALS (type));
@@ -13833,19 +13846,5 @@ nonnull_arg_p (const_tree arg)
}
-void gt_ggc_mx (class ttype *& x)
-{
-// extern void gt_ggc_mx_lang_tree_node (void *);
- if (x)
- gt_ggc_mx_lang_tree_node ((void *) x);
-}
-
-void gt_pch_nx (class ttype *& x)
-{
-// extern void gt_pch_nx_lang_tree_node (void *);
- if (x)
- gt_pch_nx_lang_tree_node ((void *) x);
-}
-
#include "gt-tree.h"
diff --git a/gcc/tree.h b/gcc/tree.h
index 4aa3ea57e03..b402fa53c63 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -1719,12 +1719,6 @@ extern void protected_set_expr_location (tree, location_t);
#define TYPE_MAIN_VARIANT(NODE) (TYPE_CHECK (NODE)->u.type_common.main_variant)
#define TYPE_CONTEXT(NODE) (TYPE_CHECK (NODE)->u.type_common.context)
-
-#define TTYPE_POINTER_TO(NODE) TTYPE ((TYPE_CHECK (NODE)->u.type_common.pointer_to))
-#define TTYPE_REFERENCE_TO(NODE) TTYPE ((TYPE_CHECK (NODE)->u.type_common.reference_to))
-#define TTYPE_MAIN_VARIANT(NODE) (TTYPE (TYPE_MAIN_VARIANT (NODE)))
-#define TTYPE_NEXT_VARIANT(NODE) (TTYPE (TYPE_NEXT_VARIANT(NODE)))
-
#define TYPE_MODE(NODE) \
(VECTOR_TYPE_P (TYPE_CHECK (NODE)) \
? vector_type_mode (NODE) : (NODE)->u.type_common.mode)
@@ -1984,11 +1978,6 @@ extern machine_mode element_mode (const_tree t);
#define TYPE_MAX_VALUE(NODE) \
(NUMERICAL_TYPE_CHECK (NODE)->u.type_non_common.maxval)
-#define TTYPE_NEXT_PTR_TO(NODE) \
- TTYPE ((POINTER_TYPE_CHECK (NODE)->u.type_non_common.minval))
-#define TTYPE_NEXT_REF_TO(NODE) \
- TTYPE ((REFERENCE_TYPE_CHECK (NODE)->u.type_non_common.minval))
-
/* If non-NULL, this is an upper bound of the size (in bytes) of an
object of the given ARRAY_TYPE_NON_COMMON. This allows temporaries to be
allocated. */
@@ -2034,7 +2023,6 @@ extern machine_mode element_mode (const_tree t);
/* The actual data type node being inherited in this basetype. */
#define BINFO_TYPE(NODE) TREE_TYPE (TREE_BINFO_CHECK (NODE))
-#define BINFO_TTYPE(NODE) TREE_TTYPE (TREE_BINFO_CHECK (NODE))
/* The offset where this basetype appears in its containing type.
BINFO_OFFSET slot holds the offset (in bytes)
@@ -3682,6 +3670,61 @@ tree_operand_check_code (const_tree __t, enum tree_code __code, int __i,
((NODE) == error_mark_node \
|| ((NODE) && TREE_TYPE ((NODE)) == error_mark_node))
+template <>
+template <>
+inline bool
+is_a_helper <ttype *>::test (tree t)
+{
+ return TYPE_P (t);
+}
+
+static inline ttype *TTYPE (tree t)
+{
+ if (t == NULL_TREE)
+ return NULL;
+ if (t == error_mark_node)
+ return error_type_node;
+ return as_a <ttype *>(t);
+}
+
+ttype *TTYPE (ttype *t) __attribute__((error(" Fix use of TTYPE(ttype *)"))) ;
+
+
+class ttype_p {
+ ttype *type;
+public:
+ inline ttype_p (tree t) { type = TTYPE (t); }
+ inline ttype_p (ttype *t) { type = t; }
+ inline ttype_p& operator= (ttype *t) { type = t; return *this; }
+ inline operator ttype *() const { return type; }
+ inline ttype * operator->() { return type; }
+ // Used to mark locations which will simply be ttype when we can remove the
+ // ttype_p type at this location. Mostly when used in varargs..
+ inline ttype *as_a_ttype () { return type; }
+};
+
+#define TREE_CAST(NODE) ((tree)(NODE))
+#define TREE_PTR_CAST(NODE) ((tree *)(NODE))
+#define TTYPE_PTR(NODE) ((ttype **)(NODE))
+
+// This macros simply becomes TREE_TYPE when typed.type becomess a ttype *
+#define TREE_TTYPE(NODE) TTYPE (TREE_TYPE (NODE))
+// This macros simply becomes &TREE_TYPE when typed.type becomess a ttype *
+#define TREE_TTYPE_PTR(NODE) TTYPE_PTR (&TREE_TYPE (NODE))
+
+// These macros become the normal TYPE_ when their underlying type is converted.
+#define TTYPE_POINTER_TO(NODE) TTYPE (TYPE_POINTER_TO (NODE))
+#define TTYPE_REFERENCE_TO(NODE) TTYPE (TYPE_REFERENCE_TO (NODE))
+#define TTYPE_MAIN_VARIANT(NODE) (TTYPE (TYPE_MAIN_VARIANT (NODE)))
+#define TTYPE_NEXT_VARIANT(NODE) (TTYPE (TYPE_NEXT_VARIANT (NODE)))
+
+#define TTYPE_NEXT_PTR_TO(NODE) TTYPE (TYPE_NEXT_PTR_TO (NODE))
+#define TTYPE_NEXT_REF_TO(NODE) TTYPE (TYPE_NEXT_REF_TO(NODE))
+
+#define BINFO_TTYPE(NODE) TREE_TTYPE (TREE_BINFO_CHECK (NODE))
+
+
+
extern tree decl_assembler_name (tree);
extern tree decl_comdat_group (const_tree);
extern tree decl_comdat_group_id (const_tree);
@@ -3937,6 +3980,7 @@ extern tree array_type_nelts (const_tree);
extern tree value_member (tree, tree);
extern tree purpose_member (const_tree, tree);
extern bool vec_member (const_tree, vec<tree, va_gc> *);
+extern bool vec_member (const ttype *, vec<ttype *, va_gc> *);
extern tree chain_index (int, tree);
extern int attribute_list_equal (const_tree, const_tree);
@@ -3992,7 +4036,7 @@ extern tree make_tree (tree, rtx);
extern ttype *build_type_attribute_variant (tree, tree);
extern tree build_decl_attribute_variant (tree, tree);
-extern ttype *build_type_attribute_qual_variant (tree, tree, int);
+extern ttype *build_type_attribute_qual_variant (ttype_p, tree, int);
extern bool attribute_value_equal (const_tree, const_tree);
@@ -4103,12 +4147,12 @@ extern bool check_qualified_type (const_tree, const_tree, int);
TYPE_QUALS, if one exists. If no qualified version exists yet,
return NULL_TREE. */
-extern ttype *get_qualified_type (tree, int);
+extern ttype *get_qualified_type (ttype_p, int);
/* Like get_qualified_type, but creates the type if it does not
exist. This function never returns NULL_TREE. */
-extern ttype *build_qualified_type (tree, int);
+extern ttype *build_qualified_type (ttype_p, int);
/* Create a variant of type T with alignment ALIGN. */
@@ -4126,7 +4170,7 @@ extern tree build_aligned_type (tree, unsigned int);
/* Make a copy of a type node. */
-extern ttype *build_distinct_type_copy (tree);
+extern ttype *build_distinct_type_copy (ttype_p);
extern ttype *build_variant_type_copy (tree);
/* Given a hashcode and a ..._TYPE node (for which the hashcode was made),
@@ -4627,7 +4671,7 @@ extern int chain_member (const_tree, const_tree);
extern void dump_tree_statistics (void);
extern void recompute_tree_invariant_for_addr_expr (tree);
extern bool needs_to_live_in_memory (const_tree);
-extern ttype *reconstruct_complex_type (tree, tree);
+extern ttype *reconstruct_complex_type (ttype_p , ttype_p);
extern int real_onep (const_tree);
extern int real_minus_onep (const_tree);
extern void init_ttree (void);
@@ -5235,29 +5279,4 @@ extern void gt_pch_nx (tree &, gt_pointer_operator, void *);
extern bool nonnull_arg_p (const_tree);
-template <>
-template <>
-inline bool
-is_a_helper <ttype *>::test (tree t)
-{
- return TYPE_P (t);
-}
-
-static inline ttype *TTYPE (tree t)
-{
- if (t == NULL_TREE)
- return NULL;
- if (t == error_mark_node)
- return error_type_node;
- return as_a <ttype *>(t);
-}
-
-ttype *TTYPE (ttype *t) __attribute__((error(" Fix use of TTYPE(ttype *)"))) ;
-
-#define TREE_TTYPE(NODE) (as_a <ttype *>(TREE_TYPE (NODE)))
-#define TREE_CAST(NODE) ((tree)(NODE))
-#define TREE_PTR_CAST(NODE) ((tree *)(NODE))
-#define TTYPE_PTR(NODE) ((ttype **)(NODE))
-#define TREE_TTYPE_PTR(NODE) TTYPE_PTR (&TREE_TYPE (NODE))
-
#endif /* GCC_TREE_H */