diff options
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 35 | ||||
-rw-r--r-- | gcc/cp/call.c | 6 | ||||
-rw-r--r-- | gcc/cp/class.c | 10 | ||||
-rw-r--r-- | gcc/cp/cvt.c | 6 | ||||
-rw-r--r-- | gcc/cp/decl.c | 48 | ||||
-rw-r--r-- | gcc/cp/decl2.c | 6 | ||||
-rw-r--r-- | gcc/cp/friend.c | 2 | ||||
-rw-r--r-- | gcc/cp/init.c | 2 | ||||
-rw-r--r-- | gcc/cp/parse.c | 13 | ||||
-rw-r--r-- | gcc/cp/parse.y | 2 | ||||
-rw-r--r-- | gcc/cp/pt.c | 18 | ||||
-rw-r--r-- | gcc/cp/repo.c | 2 | ||||
-rw-r--r-- | gcc/cp/rtti.c | 14 | ||||
-rw-r--r-- | gcc/cp/search.c | 4 | ||||
-rw-r--r-- | gcc/cp/semantics.c | 2 | ||||
-rw-r--r-- | gcc/cp/tree.c | 2 | ||||
-rw-r--r-- | gcc/cp/typeck.c | 32 | ||||
-rw-r--r-- | gcc/cp/typeck2.c | 11 |
18 files changed, 124 insertions, 91 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 64a2b8a..79297e3 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,40 @@ 2000-03-21 Nathan Sidwell <nathan@codesourcery.com> + * typeck.c (require_complete_type, complete_type, + complete_type_or_else, c_sizeof, c_sizeof_nowarn, + build_array_ref, convert_arguments, pointer_diff, + build_x_unary_op, build_unary_op, build_c_cast, + build_modify_expr): Use COMPLETE_TYPE_P etc. + * call.c (is_complete, convert_like_real, + build_new_method_call): Likewise. + * class.c (build_vbase_pointer_fields, check_bases, + build_base_field, finish_struct_1, pushclass): Likewise. + * cvt.c (cp_convert_to_pointer, convert_to_void): Likewise. + * decl.c (maybe_process_template_type_declaration, pushtag, + pushdecl, redeclaration_error_message, start_decl, start_decl_1, + layout_var_decl, check_initializer, cp_finish_decl, + grokdeclarator, require_complete_types_for_parms, + grok_op_properties, xref_tag, xref_basetypes, + check_function_type): Likewise. + * decl2.c (check_classfn, reparse_absdcl_as_casts): Likewise. + * friend.c (do_friend): Likewise. + * init.c (build_offset_ref): Likewise. + * parse.y (structsp): Likewise. + * pt.c (maybe_process_partial_specialization, + tsubst_friend_function, instantiate_class_template, tsubst, + do_type_instantiation, instantiate_pending_templates): Likewise. + * repo.c (repo_get_id): Likewise. + * rtti.c (build_typeid, get_typeid, build_dynamic_cast_1, + synthesize_tinfo_var, emit_support_tinfos): Likewise. + * search.c (lookup_fnfields_1, lookup_conversions): Likewise. + * semantics.c (begin_class_definition): Likewise. + * tree.c (build_cplus_method_type): Likewise. + * typeck2.c (digest_init, build_functional_cast, + add_exception_specifier): Likewise. + * parse.h, parse.c: Regenerated. + +2000-03-21 Nathan Sidwell <nathan@codesourcery.com> + * inc/cxxabi.h: New header file. Define new-abi entry points. (__pointer_type_info::target): Rename member to ... (__pointer_type_info::type): ... here. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 40cd43d..b505b74 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -1514,7 +1514,7 @@ static int is_complete (t) tree t; { - return TYPE_SIZE (complete_type (t)) != NULL_TREE; + return COMPLETE_TYPE_P (complete_type (t)); } /* Returns non-zero if TYPE is a promoted arithmetic type. */ @@ -3736,7 +3736,7 @@ convert_like_real (convs, expr, fn, argnum, inner) conversion because the type might be an incomplete array type, which is OK if some constructor for the destination type takes a pointer argument. */ - if (TYPE_SIZE (TREE_TYPE (expr)) == 0) + if (!COMPLETE_TYPE_P (TREE_TYPE (expr))) { if (same_type_p (TREE_TYPE (expr), TREE_TYPE (convs))) incomplete_type_error (expr, TREE_TYPE (expr)); @@ -4313,7 +4313,7 @@ build_new_method_call (instance, name, args, basetype_path, flags) /* XXX will LOOKUP_SPECULATIVELY be needed when this is done? */ if (flags & LOOKUP_SPECULATIVELY) return NULL_TREE; - if (TYPE_SIZE (basetype) == 0) + if (!COMPLETE_TYPE_P (basetype)) incomplete_type_error (instance_ptr, basetype); else cp_error ("no matching function for call to `%T::%D (%A)%V'", diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 0242492..4be6f3e 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -200,7 +200,7 @@ build_vbase_pointer_fields (rli, empty_p) register tree base_binfo = TREE_VEC_ELT (binfos, i); register tree basetype = BINFO_TYPE (base_binfo); - if (TYPE_SIZE (basetype) == 0) + if (!COMPLETE_TYPE_P (basetype)) /* This error is now reported in xref_tag, thus giving better location information. */ continue; @@ -1876,7 +1876,7 @@ check_bases (t, cant_have_default_ctor_p, cant_have_const_ctor_p, /* If the type of basetype is incomplete, then we already complained about that fact (and we should have fixed it up as well). */ - if (TYPE_SIZE (basetype) == 0) + if (!COMPLETE_TYPE_P (basetype)) { int j; /* The base type is of incomplete type. It is @@ -4246,7 +4246,7 @@ build_base_field (rli, binfo, empty_p, base_align, v) tree basetype = BINFO_TYPE (binfo); tree decl; - if (TYPE_SIZE (basetype) == 0) + if (!COMPLETE_TYPE_P (basetype)) /* This error is now reported in xref_tag, thus giving better location information. */ return; @@ -5133,7 +5133,7 @@ finish_struct_1 (t) tree vfield; int empty = 1; - if (TYPE_SIZE (t)) + if (COMPLETE_TYPE_P (t)) { if (IS_AGGR_TYPE (t)) cp_error ("redefinition of `%#T'", t); @@ -5642,7 +5642,7 @@ pushclass (type, modify) if (previous_class_type != NULL_TREE && (type != previous_class_type - || TYPE_SIZE (previous_class_type) == NULL_TREE) + || !COMPLETE_TYPE_P (previous_class_type)) && current_class_depth == 1) { /* Forcibly remove any old class remnants. */ diff --git a/gcc/cp/cvt.c b/gcc/cp/cvt.c index d3c2409..ad114d6 100644 --- a/gcc/cp/cvt.c +++ b/gcc/cp/cvt.c @@ -79,7 +79,7 @@ cp_convert_to_pointer (type, expr) if (IS_AGGR_TYPE (intype)) { intype = complete_type (intype); - if (TYPE_SIZE (intype) == NULL_TREE) + if (!COMPLETE_TYPE_P (intype)) { cp_error ("can't convert from incomplete type `%T' to `%T'", intype, type); @@ -901,7 +901,7 @@ convert_to_void (expr, implicit) int is_reference = TREE_CODE (TREE_TYPE (TREE_OPERAND (expr, 0))) == REFERENCE_TYPE; int is_volatile = TYPE_VOLATILE (type); - int is_complete = TYPE_SIZE (complete_type (type)) != NULL_TREE; + int is_complete = COMPLETE_TYPE_P (complete_type (type)); if (is_volatile && !is_complete) cp_warning ("object of incomplete type `%T' will not be accessed in %s", @@ -920,7 +920,7 @@ convert_to_void (expr, implicit) { /* External variables might be incomplete. */ tree type = TREE_TYPE (expr); - int is_complete = TYPE_SIZE (complete_type (type)) != NULL_TREE; + int is_complete = COMPLETE_TYPE_P (complete_type (type)); if (TYPE_VOLATILE (type) && !is_complete) cp_warning ("object `%E' of incomplete type `%T' will not be accessed in %s", diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index e1d3178..813ef6f 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -2722,7 +2722,7 @@ maybe_process_template_type_declaration (type, globalize, b) binding level, but is instead the pseudo-global level. */ b->level_chain->tags = tree_cons (name, type, b->level_chain->tags); - if (TYPE_SIZE (current_class_type) == NULL_TREE) + if (!COMPLETE_TYPE_P (current_class_type)) CLASSTYPE_TAGS (current_class_type) = b->level_chain->tags; } } @@ -2838,7 +2838,7 @@ pushtag (name, type, globalize) } if (b->parm_flag == 2) { - if (TYPE_SIZE (current_class_type) == NULL_TREE) + if (!COMPLETE_TYPE_P (current_class_type)) CLASSTYPE_TAGS (current_class_type) = b->tags; } } @@ -4144,7 +4144,7 @@ pushdecl (x) /* Keep count of variables in this level with incomplete type. */ if (TREE_CODE (x) == VAR_DECL && TREE_TYPE (x) != error_mark_node - && ((TYPE_SIZE (TREE_TYPE (x)) == NULL_TREE + && ((!COMPLETE_TYPE_P (TREE_TYPE (x)) && PROMOTES_TO_AGGR_TYPE (TREE_TYPE (x), ARRAY_TYPE)) /* RTTI TD entries are created while defining the type_info. */ || (TYPE_LANG_SPECIFIC (TREE_TYPE (x)) @@ -4668,8 +4668,8 @@ redeclaration_error_message (newdecl, olddecl) && DECL_INITIAL (DECL_TEMPLATE_RESULT (newdecl)) && DECL_INITIAL (DECL_TEMPLATE_RESULT (olddecl))) || (TREE_CODE (DECL_TEMPLATE_RESULT (newdecl)) == TYPE_DECL - && TYPE_SIZE (TREE_TYPE (newdecl)) - && TYPE_SIZE (TREE_TYPE (olddecl)))) + && COMPLETE_TYPE_P (TREE_TYPE (newdecl)) + && COMPLETE_TYPE_P (TREE_TYPE (olddecl)))) return "redefinition of `%#D'"; return 0; } @@ -7003,7 +7003,7 @@ start_decl (declarator, declspecs, initialized, attributes, prefix_attributes) /* Set attributes here so if duplicate decl, will have proper attributes. */ cplus_decl_attributes (decl, attributes, prefix_attributes); - if (context && TYPE_SIZE (complete_type (context)) != NULL_TREE) + if (context && COMPLETE_TYPE_P (complete_type (context))) { push_nested_class (context, 2); @@ -7110,7 +7110,7 @@ start_decl_1 (decl) { /* Don't allow initializations for incomplete types except for arrays which might be completed by the initialization. */ - if (TYPE_SIZE (complete_type (type)) != NULL_TREE) + if (COMPLETE_TYPE_P (complete_type (type))) ; /* A complete type is ok. */ else if (TREE_CODE (type) != ARRAY_TYPE) { @@ -7119,7 +7119,7 @@ start_decl_1 (decl) initialized = 0; type = TREE_TYPE (decl) = error_mark_node; } - else if (TYPE_SIZE (complete_type (TREE_TYPE (type))) == NULL_TREE) + else if (!COMPLETE_TYPE_P (complete_type (TREE_TYPE (type)))) { if (DECL_LANG_SPECIFIC (decl) && DECL_TEMPLATE_INFO (decl)) cp_error ("elements of array `%#D' have incomplete type", decl); @@ -7136,7 +7136,7 @@ start_decl_1 (decl) && ! DECL_EXTERNAL (decl)) { if ((! processing_template_decl || ! uses_template_parms (type)) - && TYPE_SIZE (complete_type (type)) == NULL_TREE) + && !COMPLETE_TYPE_P (complete_type (type))) { cp_error ("aggregate `%#D' has incomplete type and cannot be initialized", decl); @@ -7337,7 +7337,7 @@ layout_var_decl (decl) `extern X x' for some incomplete type `X'.) */ if (!DECL_EXTERNAL (decl)) complete_type (type); - if (!DECL_SIZE (decl) && TYPE_SIZE (type)) + if (!DECL_SIZE (decl) && COMPLETE_TYPE_P (type)) layout_decl (decl, 0); if (!DECL_EXTERNAL (decl) && DECL_SIZE (decl) == NULL_TREE) @@ -7480,18 +7480,18 @@ check_initializer (decl, init) if (type == error_mark_node) /* We will have already complained. */ init = NULL_TREE; - else if (TYPE_SIZE (type) && !TREE_CONSTANT (TYPE_SIZE (type))) + else if (COMPLETE_TYPE_P (type) && !TREE_CONSTANT (TYPE_SIZE (type))) { cp_error ("variable-sized object `%D' may not be initialized", decl); init = NULL_TREE; } else if (TREE_CODE (type) == ARRAY_TYPE - && !TYPE_SIZE (TREE_TYPE (type))) + && !COMPLETE_TYPE_P (TREE_TYPE (type))) { cp_error ("elements of array `%#D' have incomplete type", decl); init = NULL_TREE; } - else if (!TYPE_SIZE (type)) + else if (!COMPLETE_TYPE_P (type)) { cp_error ("`%D' has incomplete type", decl); TREE_TYPE (decl) = error_mark_node; @@ -7565,8 +7565,7 @@ check_initializer (decl, init) check_for_uninitialized_const_var (decl); - if (TYPE_SIZE (type) != NULL_TREE - && TYPE_NEEDS_CONSTRUCTING (type)) + if (COMPLETE_TYPE_P (type) && TYPE_NEEDS_CONSTRUCTING (type)) init = obscure_complex_init (decl, NULL_TREE); } @@ -7944,7 +7943,7 @@ cp_finish_decl (decl, init, asmspec_tree, flags) type, and that type has not been defined yet, delay emitting the debug information for it, as we will emit it later. */ if (TYPE_MAIN_DECL (TREE_TYPE (decl)) == decl - && TYPE_SIZE (TREE_TYPE (decl)) == NULL_TREE) + && !COMPLETE_TYPE_P (TREE_TYPE (decl))) TYPE_DECL_SUPPRESS_DEBUG (decl) = 1; rest_of_decl_compilation (decl, NULL_PTR, @@ -8059,7 +8058,7 @@ cp_finish_decl (decl, init, asmspec_tree, flags) /* If size hasn't been set, we're still defining it, and therefore inside the class body; don't pop the binding level.. */ - && TYPE_SIZE (context) != NULL_TREE + && COMPLETE_TYPE_P (context) && context == current_class_type) pop_nested_class (); } @@ -10695,7 +10694,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist) } } else if (RIDBIT_SETP (RID_TYPEDEF, specbits) - || TYPE_SIZE (complete_type (ctype)) != NULL_TREE) + || COMPLETE_TYPE_P (complete_type (ctype))) { /* Have to move this code elsewhere in this function. this code is used for i.e., typedef int A::M; M *pm; @@ -11212,7 +11211,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist) return NULL_TREE; } else if (!staticp && ! processing_template_decl - && TYPE_SIZE (complete_type (type)) == NULL_TREE + && !COMPLETE_TYPE_P (complete_type (type)) && (TREE_CODE (type) != ARRAY_TYPE || initialized == 0)) { if (declarator) @@ -11532,7 +11531,7 @@ require_complete_types_for_parms (parms) if (type == error_mark_node) continue; - if (TYPE_SIZE (type) == NULL_TREE) + if (!COMPLETE_TYPE_P (type)) { if (DECL_NAME (parms)) error ("parameter `%s' has incomplete type", @@ -12160,7 +12159,7 @@ grok_op_properties (decl, virtualp, friendp) what = "the same type"; /* Don't force t to be complete here. */ else if (IS_AGGR_TYPE (t) - && TYPE_SIZE (t) + && COMPLETE_TYPE_P (t) && DERIVED_FROM_P (t, current_class_type)) what = "a base class"; @@ -12533,7 +12532,7 @@ xref_tag (code_type_node, name, globalize) /* Until the type is defined, tentatively accept whatever structure tag the user hands us. */ - if (TYPE_SIZE (ref) == NULL_TREE + if (!COMPLETE_TYPE_P (ref) && ref != current_class_type /* Have to check this, in case we have contradictory tag info. */ && IS_AGGR_TYPE_CODE (TREE_CODE (ref))) @@ -12643,7 +12642,7 @@ xref_basetypes (code_type_node, name, ref, binfo) /* This code replaces similar code in layout_basetypes. We put the complete_type first for implicit `typename'. */ - if (TYPE_SIZE (basetype) == NULL_TREE + if (!COMPLETE_TYPE_P (basetype) && ! (current_template_parms && uses_template_parms (basetype))) { cp_error ("base class `%T' has incomplete type", basetype); @@ -13058,11 +13057,12 @@ check_function_type (decl) tree decl; { tree fntype = TREE_TYPE (decl); + tree return_type = complete_type (TREE_TYPE (fntype)); /* In a function definition, arg types must be complete. */ require_complete_types_for_parms (current_function_parms); - if (TYPE_SIZE (complete_type (TREE_TYPE (fntype))) == NULL_TREE) + if (!COMPLETE_OR_VOID_TYPE_P (return_type)) { cp_error ("return type `%#T' is incomplete", TREE_TYPE (fntype)); diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 266e660..3d51808 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -1457,7 +1457,7 @@ check_classfn (ctype, function) else { methods = 0; - if (TYPE_SIZE (ctype) == 0) + if (!COMPLETE_TYPE_P (ctype)) incomplete_type_error (function, ctype); else cp_error ("no `%#D' member function declared in class `%T'", @@ -1468,7 +1468,7 @@ check_classfn (ctype, function) spurious errors (unless the CTYPE is not yet defined, in which case we'll only confuse ourselves when the function is declared properly within the class. */ - if (TYPE_SIZE (ctype)) + if (COMPLETE_TYPE_P (ctype)) add_method (ctype, methods, function); return NULL_TREE; } @@ -3734,7 +3734,7 @@ reparse_absdcl_as_casts (decl, expr) decl = TREE_OPERAND (decl, 0); expr = digest_init (type, expr, (tree *) 0); - if (TREE_CODE (type) == ARRAY_TYPE && TYPE_SIZE (type) == 0) + if (TREE_CODE (type) == ARRAY_TYPE && !COMPLETE_TYPE_P (type)) { int failure = complete_array_type (type, expr, 1); if (failure) diff --git a/gcc/cp/friend.c b/gcc/cp/friend.c index 01c5d94..20bb5d8 100644 --- a/gcc/cp/friend.c +++ b/gcc/cp/friend.c @@ -362,7 +362,7 @@ do_friend (ctype, declarator, decl, parmdecls, attrlist, /* A nested class may declare a member of an enclosing class to be a friend, so we do lookup here even if CTYPE is in the process of being defined. */ - else if (TYPE_SIZE (ctype) != 0 || TYPE_BEING_DEFINED (ctype)) + else if (COMPLETE_TYPE_P (ctype) || TYPE_BEING_DEFINED (ctype)) { decl = check_classfn (ctype, decl); diff --git a/gcc/cp/init.c b/gcc/cp/init.c index f2aba2c..ff8e058 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -1610,7 +1610,7 @@ build_offset_ref (type, name) name = ctor_identifier; #endif - if (TYPE_SIZE (complete_type (type)) == 0 + if (!COMPLETE_TYPE_P (complete_type (type)) && !TYPE_BEING_DEFINED (type)) { cp_error ("incomplete type `%T' does not have member `%D'", type, diff --git a/gcc/cp/parse.c b/gcc/cp/parse.c index 44f7ff2..306bd16 100644 --- a/gcc/cp/parse.c +++ b/gcc/cp/parse.c @@ -1,7 +1,6 @@ /* A Bison parser, made from parse.y - by GNU Bison version 1.27 - */ + by GNU Bison version 1.28 */ #define YYBISON 1 /* Identify Bison output. */ @@ -4031,8 +4030,8 @@ static const short yycheck[] = { 4, 78, 79, 80, 81, 82, 83, 84, 85 }; /* -*-C-*- Note some compilers choke on comments on `#line' lines. */ -#line 3 "/usr/share/bison.simple" -/* This file comes from bison-1.27. */ +#line 3 "/usr/lib/bison.simple" +/* This file comes from bison-1.28. */ /* Skeleton output parser for bison, Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc. @@ -4245,7 +4244,7 @@ __yy_memcpy (char *to, char *from, unsigned int count) #endif #endif -#line 216 "/usr/share/bison.simple" +#line 217 "/usr/lib/bison.simple" /* The user can define YYPARSE_PARAM as the name of an argument to be passed into yyparse. The argument should have type void *. @@ -6543,7 +6542,7 @@ case 480: /* struct B: public A; is not accepted by the standard grammar. */ if (CLASS_TYPE_P (yyval.ftype.t) && TYPE_BINFO_BASETYPES (yyval.ftype.t) - && !TYPE_SIZE (yyval.ftype.t) + && !COMPLETE_TYPE_P (yyval.ftype.t) && ! TYPE_BEING_DEFINED (yyval.ftype.t)) cp_error ("base clause without member specification for `%#T'", yyval.ftype.t); @@ -8230,7 +8229,7 @@ case 878: break;} } /* the action file gets copied in in place of this dollarsign */ -#line 542 "/usr/share/bison.simple" +#line 543 "/usr/lib/bison.simple" yyvsp -= yylen; yyssp -= yylen; diff --git a/gcc/cp/parse.y b/gcc/cp/parse.y index ab6012f..b593c1d 100644 --- a/gcc/cp/parse.y +++ b/gcc/cp/parse.y @@ -2206,7 +2206,7 @@ structsp: /* struct B: public A; is not accepted by the standard grammar. */ if (CLASS_TYPE_P ($$.t) && TYPE_BINFO_BASETYPES ($$.t) - && !TYPE_SIZE ($$.t) + && !COMPLETE_TYPE_P ($$.t) && ! TYPE_BEING_DEFINED ($$.t)) cp_error ("base clause without member specification for `%#T'", $$.t); diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index a5da8d2a..abb9539 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -657,7 +657,7 @@ maybe_process_partial_specialization (type) if (IS_AGGR_TYPE (type) && CLASSTYPE_USE_TEMPLATE (type)) { if (CLASSTYPE_IMPLICIT_INSTANTIATION (type) - && TYPE_SIZE (type) == NULL_TREE) + && !COMPLETE_TYPE_P (type)) { if (current_namespace != decl_namespace_context (CLASSTYPE_TI_TEMPLATE (type))) @@ -4577,7 +4577,7 @@ tsubst_friend_function (decl, args) new_friend = old_decl; } } - else if (TYPE_SIZE (DECL_CONTEXT (new_friend))) + else if (COMPLETE_TYPE_P (DECL_CONTEXT (new_friend))) { /* Check to see that the declaration is really present, and, possibly obtain an improved declaration. */ @@ -4673,7 +4673,7 @@ instantiate_class_template (type) if (type == error_mark_node) return error_mark_node; - if (TYPE_BEING_DEFINED (type) || TYPE_SIZE (type)) + if (TYPE_BEING_DEFINED (type) || COMPLETE_TYPE_P (type)) return type; /* Figure out which template is being instantiated. */ @@ -4749,7 +4749,7 @@ instantiate_class_template (type) /* If the template we're instantiating is incomplete, then clearly there's nothing we can do. */ - if (TYPE_SIZE (pattern) == NULL_TREE) + if (!COMPLETE_TYPE_P (pattern)) return type; /* If this is a partial instantiation, don't tsubst anything. We will @@ -6623,7 +6623,7 @@ tsubst (t, args, complain, in_decl) point, so here CTX really should have complete type, unless it's a partial instantiation. */ ctx = complete_type (ctx); - if (!TYPE_SIZE (ctx)) + if (!COMPLETE_TYPE_P (ctx)) { if (complain) incomplete_type_error (NULL_TREE, ctx); @@ -9177,7 +9177,7 @@ do_type_instantiation (t, storage) if (flag_external_templates) return; - if (TYPE_SIZE (t) == NULL_TREE) + if (!COMPLETE_TYPE_P (t)) { cp_error ("explicit instantiation of `%#T' before definition of template", t); @@ -9653,7 +9653,7 @@ instantiate_pending_templates () { tree fn; - if (!TYPE_SIZE (instantiation)) + if (!COMPLETE_TYPE_P (instantiation)) { instantiate_class_template (instantiation); if (CLASSTYPE_TEMPLATE_INSTANTIATION (instantiation)) @@ -9662,14 +9662,14 @@ instantiate_pending_templates () fn = TREE_CHAIN (fn)) if (! DECL_ARTIFICIAL (fn)) instantiate_decl (fn); - if (TYPE_SIZE (instantiation)) + if (COMPLETE_TYPE_P (instantiation)) { instantiated_something = 1; reconsider = 1; } } - if (TYPE_SIZE (instantiation)) + if (COMPLETE_TYPE_P (instantiation)) /* If INSTANTIATION has been instantiated, then we don't need to consider it again in the future. */ *t = TREE_CHAIN (*t); diff --git a/gcc/cp/repo.c b/gcc/cp/repo.c index bc8e919..0724a45 100644 --- a/gcc/cp/repo.c +++ b/gcc/cp/repo.c @@ -100,7 +100,7 @@ repo_get_id (t) /* If we're not done setting up the class, we may not have set up the vtable, so going ahead would give the wrong answer. See g++.pt/instantiate4.C. */ - if (TYPE_SIZE (t) == NULL_TREE || TYPE_BEING_DEFINED (t)) + if (!COMPLETE_TYPE_P (t) || TYPE_BEING_DEFINED (t)) my_friendly_abort (981113); t = TYPE_BINFO_VTABLE (t); diff --git a/gcc/cp/rtti.c b/gcc/cp/rtti.c index bc9746c..7a8baac 100644 --- a/gcc/cp/rtti.c +++ b/gcc/cp/rtti.c @@ -273,7 +273,7 @@ build_typeid (exp) return error_mark_node; } - if (TYPE_SIZE (type_info_type_node) == NULL_TREE) + if (!COMPLETE_TYPE_P (type_info_type_node)) { error ("must #include <typeinfo> before using typeid"); return error_mark_node; @@ -462,7 +462,7 @@ get_typeid (type) if (type == error_mark_node) return error_mark_node; - if (TYPE_SIZE (type_info_type_node) == NULL_TREE) + if (!COMPLETE_TYPE_P (type_info_type_node)) { error ("must #include <typeinfo> before using typeid"); return error_mark_node; @@ -564,7 +564,7 @@ build_dynamic_cast_1 (type, expr) errstr = "target is not pointer or reference to class"; goto fail; } - if (TYPE_SIZE (complete_type (TREE_TYPE (type))) == NULL_TREE) + if (!COMPLETE_TYPE_P (complete_type (TREE_TYPE (type)))) { errstr = "target is not pointer or reference to complete type"; goto fail; @@ -609,7 +609,7 @@ build_dynamic_cast_1 (type, expr) errstr = "source is not a pointer to class"; goto fail; } - if (TYPE_SIZE (complete_type (TREE_TYPE (exprtype))) == NULL_TREE) + if (!COMPLETE_TYPE_P (complete_type (TREE_TYPE (exprtype)))) { errstr = "source is a pointer to incomplete type"; goto fail; @@ -625,7 +625,7 @@ build_dynamic_cast_1 (type, expr) errstr = "source is not of class type"; goto fail; } - if (TYPE_SIZE (complete_type (TREE_TYPE (exprtype))) == NULL_TREE) + if (!COMPLETE_TYPE_P (complete_type (TREE_TYPE (exprtype)))) { errstr = "source is of incomplete class type"; goto fail; @@ -1466,7 +1466,7 @@ synthesize_tinfo_var (target_type, real_name) break; case UNION_TYPE: case RECORD_TYPE: - if (!TYPE_SIZE (target_type)) + if (!COMPLETE_TYPE_P (target_type)) { /* FIXME: incomplete type. Awaiting specification. */ return NULL_TREE; @@ -1820,7 +1820,7 @@ emit_support_tinfos () bltn_type = xref_tag (class_type_node, get_identifier ("__fundamental_type_info"), 1); pop_nested_namespace (abi_node); - if (!TYPE_SIZE (bltn_type)) + if (!COMPLETE_TYPE_P (bltn_type)) return; dtor = TREE_VEC_ELT (CLASSTYPE_METHOD_VEC (bltn_type), 1); if (DECL_EXTERNAL (dtor)) diff --git a/gcc/cp/search.c b/gcc/cp/search.c index dfded73..0667357 100644 --- a/gcc/cp/search.c +++ b/gcc/cp/search.c @@ -1692,7 +1692,7 @@ lookup_fnfields_1 (type, name) /* If the type is complete and we're past the conversion ops, switch to binary search. */ if (! DECL_CONV_FN_P (tmp) - && TYPE_SIZE (type)) + && COMPLETE_TYPE_P (type)) { int lo = i + 1, hi = len; @@ -3560,7 +3560,7 @@ lookup_conversions (type) tree t; tree conversions = NULL_TREE; - if (TYPE_SIZE (type)) + if (COMPLETE_TYPE_P (type)) bfs_walk (TYPE_BINFO (type), add_conversions, 0, &conversions); for (t = conversions; t; t = TREE_CHAIN (t)) diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 3071f1f0..9b2fa87 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -1919,7 +1919,7 @@ begin_class_definition (t) } /* If this type was already complete, and we see another definition, that's an error. */ - else if (TYPE_SIZE (t)) + else if (COMPLETE_TYPE_P (t)) duplicate_tag_error (t); /* Update the location of the decl. */ diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 57adf99..84c7f3f 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -474,7 +474,7 @@ build_cplus_method_type (basetype, rettype, argtypes) t = type_hash_canon (hashcode, t); - if (TYPE_SIZE (t) == 0) + if (!COMPLETE_TYPE_P (t)) layout_type (t); return t; diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 43bd1bc..0c45c9b 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -106,7 +106,7 @@ require_complete_type (value) type = TREE_TYPE (value); /* First, detect a valid value with a complete type. */ - if (TYPE_SIZE (type) && !integer_zerop (TYPE_SIZE (type))) + if (COMPLETE_TYPE_P (type)) return value; /* If we see X::Y, we build an OFFSET_TYPE which has @@ -145,12 +145,12 @@ complete_type (type) at some point. */ return error_mark_node; - if (type == error_mark_node || TYPE_SIZE (type) != NULL_TREE) + if (type == error_mark_node || COMPLETE_TYPE_P (type)) ; else if (TREE_CODE (type) == ARRAY_TYPE && TYPE_DOMAIN (type)) { tree t = complete_type (TREE_TYPE (type)); - if (TYPE_SIZE (t) != NULL_TREE && ! processing_template_decl) + if (COMPLETE_TYPE_P (t) && ! processing_template_decl) layout_type (type); TYPE_NEEDS_CONSTRUCTING (type) = TYPE_NEEDS_CONSTRUCTING (TYPE_MAIN_VARIANT (t)); @@ -176,7 +176,7 @@ complete_type_or_else (type, value) if (type == error_mark_node) /* We already issued an error. */ return NULL_TREE; - else if (!TYPE_SIZE (type) || integer_zerop (TYPE_SIZE (type))) + else if (!COMPLETE_TYPE_P (type)) { incomplete_type_error (value, type); return NULL_TREE; @@ -1584,7 +1584,7 @@ c_sizeof (type) return size_zero_node; } - if (TYPE_SIZE (complete_type (type)) == 0) + if (!COMPLETE_TYPE_P (complete_type (type))) { cp_error ("`sizeof' applied to incomplete type `%T'", type); return size_zero_node; @@ -1643,7 +1643,7 @@ c_sizeof_nowarn (type) if (code == REFERENCE_TYPE) type = TREE_TYPE (type); - if (TYPE_SIZE (type) == 0) + if (!COMPLETE_TYPE_P (type)) return size_zero_node; /* Convert in case a char is more than one unit. */ @@ -2436,7 +2436,7 @@ build_array_ref (array, idx) address arithmetic on its address. Likewise an array of elements of variable size. */ if (TREE_CODE (idx) != INTEGER_CST - || (TYPE_SIZE (TREE_TYPE (TREE_TYPE (array))) != 0 + || (COMPLETE_TYPE_P (TREE_TYPE (TREE_TYPE (array))) && (TREE_CODE (TYPE_SIZE (TREE_TYPE (TREE_TYPE (array)))) != INTEGER_CST))) { @@ -3163,7 +3163,7 @@ convert_arguments (typelist, values, fndecl, flags) /* Formal parm type is specified by a function prototype. */ tree parmval; - if (TYPE_SIZE (complete_type (type)) == 0) + if (!COMPLETE_TYPE_P (complete_type (type))) { error ("parameter type of called function is incomplete"); parmval = val; @@ -4228,7 +4228,7 @@ pointer_diff (op0, op1, ptrtype) cp_convert (restype, op1)); /* This generates an error if op1 is a pointer to an incomplete type. */ - if (TYPE_SIZE (TREE_TYPE (TREE_TYPE (op1))) == 0) + if (!COMPLETE_TYPE_P (TREE_TYPE (TREE_TYPE (op1)))) error ("invalid use of a pointer to an incomplete type in pointer arithmetic"); op1 = ((TREE_CODE (target_type) == VOID_TYPE @@ -4316,7 +4316,7 @@ build_x_unary_op (code, xarg) if (code == ADDR_EXPR && TREE_CODE (xarg) != TEMPLATE_ID_EXPR && ((IS_AGGR_TYPE_CODE (TREE_CODE (TREE_TYPE (xarg))) - && TYPE_SIZE (TREE_TYPE (xarg)) == NULL_TREE) + && !COMPLETE_TYPE_P (TREE_TYPE (xarg))) || (TREE_CODE (xarg) == OFFSET_REF))) /* don't look for a function */; else @@ -4524,7 +4524,9 @@ build_unary_op (code, xarg, noconvert) if (TREE_CODE (argtype) == POINTER_TYPE) { enum tree_code tmp = TREE_CODE (TREE_TYPE (argtype)); - if (TYPE_SIZE (complete_type (TREE_TYPE (argtype))) == 0) + tree type = complete_type (TREE_TYPE (argtype)); + + if (!COMPLETE_OR_VOID_TYPE_P (type)) cp_error ("cannot %s a pointer to incomplete type `%T'", ((code == PREINCREMENT_EXPR || code == POSTINCREMENT_EXPR) @@ -5536,8 +5538,8 @@ build_c_cast (type, expr) && TREE_CODE (otype) == POINTER_TYPE && TREE_CODE (TREE_TYPE (otype)) != VOID_TYPE && TREE_CODE (TREE_TYPE (otype)) != FUNCTION_TYPE - && TYPE_SIZE (TREE_TYPE (otype)) - && TYPE_SIZE (TREE_TYPE (type)) + && COMPLETE_TYPE_P (TREE_TYPE (otype)) + && COMPLETE_TYPE_P (TREE_TYPE (type)) && TYPE_ALIGN (TREE_TYPE (type)) > TYPE_ALIGN (TREE_TYPE (otype))) cp_warning ("cast from `%T' to `%T' increases required alignment of target type", otype, type); @@ -5819,7 +5821,7 @@ build_modify_expr (lhs, modifycode, rhs) { tree tmp = convert_from_reference (lhs); lhstype = TREE_TYPE (tmp); - if (TYPE_SIZE (lhstype) == 0) + if (!COMPLETE_TYPE_P (lhstype)) { incomplete_type_error (lhs, lhstype); return error_mark_node; @@ -5830,7 +5832,7 @@ build_modify_expr (lhs, modifycode, rhs) if (TREE_CODE (TREE_TYPE (newrhs)) == REFERENCE_TYPE) { tree tmp = convert_from_reference (newrhs); - if (TYPE_SIZE (TREE_TYPE (tmp)) == 0) + if (!COMPLETE_TYPE_P (TREE_TYPE (tmp))) { incomplete_type_error (newrhs, TREE_TYPE (tmp)); return error_mark_node; diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c index e3614d7..de52481 100644 --- a/gcc/cp/typeck2.c +++ b/gcc/cp/typeck2.c @@ -648,7 +648,7 @@ digest_init (type, init, tail) /* Come here only for records and arrays (and unions with constructors). */ - if (TYPE_SIZE (type) && ! TREE_CONSTANT (TYPE_SIZE (type))) + if (COMPLETE_TYPE_P (type) && ! TREE_CONSTANT (TYPE_SIZE (type))) { cp_error ("variable-sized object of type `%T' may not be initialized", type); @@ -1267,11 +1267,8 @@ build_functional_cast (exp, parms) then the slot being initialized will be filled in. */ - if (TYPE_SIZE (complete_type (type)) == NULL_TREE) - { - cp_error ("type `%T' is not yet defined", type); - return error_mark_node; - } + if (!complete_type_or_else (type, NULL_TREE)) + return error_mark_node; if (abstract_virtuals_error (NULL_TREE, type)) return error_mark_node; @@ -1474,7 +1471,7 @@ add_exception_specifier (list, spec, complain) else if (TREE_CODE (core) == TEMPLATE_TYPE_PARM) ok = 1; else - ok = TYPE_SIZE (complete_type (core)) != NULL_TREE; + ok = COMPLETE_TYPE_P (complete_type (core)); if (ok) { |