This patch adds a DEFINITE_TYPE_P macro for testing whether a type has been fully-defined. The definition is the same as the current definition of COMPLETE_TYPE_P, but later patches redefine COMPLETE_TYPE_P and make it local to the C and C++ frontends. The name "definite type" comes from the SVE ACLE specification.
The patch also replaces all *.c uses of COMPLETE_TYPE_P outside the frontends (along with a couple of *.h uses). 2018-10-15 Richard Sandiford <richard.sandif...@arm.com> gcc/ * tree.h (DEFINITE_TYPE_P): New macro. (type_with_alias_set_p): Use it instead of COMPLETE_TYPE_P. * alias.c (get_alias_set): Likewise. * calls.c (initialize_argument_information): Likewise. * config/i386/winnt.c (gen_stdcall_or_fastcall_suffix): Likewise. * convert.c (convert_to_integer_1): Likewise. * dbxout.c (dbxout_type, dbxout_symbol): Likewise. * dwarf2out.c (add_pubtype, gen_generic_params_dies) (add_subscript_info, gen_scheduled_generic_parms_dies): Likewise. * function.c (assign_temp): Likewise. * gimple-expr.c (create_tmp_var): Likewise. * gimplify.c (gimplify_expr): Likewise. * ipa-devirt.c (set_type_binfo, warn_types_mismatch) (odr_types_equivalent_p, add_type_duplicate, get_odr_type): Likewise. * ipa-icf.c (sem_item::add_type): Likewise. * langhooks.c (lhd_omp_mappable_type): Likewise. * omp-low.c (scan_sharing_clauses): Likewise. * tree-ssa-sccvn.c (fully_constant_vn_reference_p): Likewise. * tree.c (type_cache_hasher::equal, build_function_type) (build_method_type_directly, build_offset_type, build_complex_type) (verify_type_variant, gimple_canonical_types_compatible_p) (verify_type): Likewise. gcc/ada/ * gcc-interface/decl.c (gnat_to_gnu_entity): Likewise. * gcc-interface/utils2.c (build_simple_component_ref): Likewise. gcc/fortran/ * trans-decl.c (gfc_build_qualified_array): Likewise. (create_function_arglist): Likewise. gcc/lto/ * lto-symtab.c (lto_symtab_merge_decls_1): Likewise. Index: gcc/tree.h =================================================================== --- gcc/tree.h 2018-10-05 13:46:08.863806452 +0100 +++ gcc/tree.h 2018-10-15 14:12:59.036511679 +0100 @@ -592,6 +592,10 @@ #define POINTER_TYPE_P(TYPE) \ #define FUNCTION_POINTER_TYPE_P(TYPE) \ (POINTER_TYPE_P (TYPE) && TREE_CODE (TREE_TYPE (TYPE)) == FUNCTION_TYPE) +/* Nonzero if this type is "definite"; that is, if we have enough information + to create objects of that type. The type might be sized or sizeless. */ +#define DEFINITE_TYPE_P(NODE) (TYPE_SIZE (NODE) != NULL_TREE) + /* Nonzero if this type is a complete type. */ #define COMPLETE_TYPE_P(NODE) (TYPE_SIZE (NODE) != NULL_TREE) @@ -5796,12 +5800,12 @@ type_with_alias_set_p (const_tree t) if (TREE_CODE (t) == FUNCTION_TYPE || TREE_CODE (t) == METHOD_TYPE) return false; - if (COMPLETE_TYPE_P (t)) + if (DEFINITE_TYPE_P (t)) return true; /* Incomplete types can not be accessed in general except for arrays where we can fetch its element despite we have no array bounds. */ - if (TREE_CODE (t) == ARRAY_TYPE && COMPLETE_TYPE_P (TREE_TYPE (t))) + if (TREE_CODE (t) == ARRAY_TYPE && DEFINITE_TYPE_P (TREE_TYPE (t))) return true; return false; Index: gcc/alias.c =================================================================== --- gcc/alias.c 2018-10-05 13:46:11.111788242 +0100 +++ gcc/alias.c 2018-10-15 14:12:59.020511811 +0100 @@ -922,15 +922,15 @@ get_alias_set (tree t) if (TYPE_ALIAS_SET_KNOWN_P (t)) return TYPE_ALIAS_SET (t); - /* We don't want to set TYPE_ALIAS_SET for incomplete types. */ - if (!COMPLETE_TYPE_P (t)) + /* We don't want to set TYPE_ALIAS_SET for indefinite types. */ + if (!DEFINITE_TYPE_P (t)) { /* For arrays with unknown size the conservative answer is the alias set of the element type. */ if (TREE_CODE (t) == ARRAY_TYPE) return get_alias_set (TREE_TYPE (t)); - /* But return zero as a conservative answer for incomplete types. */ + /* But return zero as a conservative answer for indefinite types. */ return 0; } @@ -1006,7 +1006,7 @@ get_alias_set (tree t) for (p = t; POINTER_TYPE_P (p) || (TREE_CODE (p) == ARRAY_TYPE && (!TYPE_NONALIASED_COMPONENT (p) - || !COMPLETE_TYPE_P (p) + || !DEFINITE_TYPE_P (p) || TYPE_STRUCTURAL_EQUALITY_P (p))) || TREE_CODE (p) == VECTOR_TYPE; p = TREE_TYPE (p)) Index: gcc/calls.c =================================================================== --- gcc/calls.c 2018-10-15 14:12:54.016553288 +0100 +++ gcc/calls.c 2018-10-15 14:12:59.024511777 +0100 @@ -1950,7 +1950,7 @@ initialize_argument_information (int num machine_mode mode; /* Replace erroneous argument with constant zero. */ - if (type == error_mark_node || !COMPLETE_TYPE_P (type)) + if (type == error_mark_node || !DEFINITE_TYPE_P (type)) args[i].tree_value = integer_zero_node, type = integer_type_node; /* If TYPE is a transparent union or record, pass things the way Index: gcc/config/i386/winnt.c =================================================================== --- gcc/config/i386/winnt.c 2018-06-14 12:27:39.888033693 +0100 +++ gcc/config/i386/winnt.c 2018-10-15 14:12:59.024511777 +0100 @@ -200,7 +200,7 @@ gen_stdcall_or_fastcall_suffix (tree dec HOST_WIDE_INT parm_size; HOST_WIDE_INT parm_boundary_bytes = PARM_BOUNDARY / BITS_PER_UNIT; - if (! COMPLETE_TYPE_P (arg)) + if (! DEFINITE_TYPE_P (arg)) break; parm_size = int_size_in_bytes (arg); Index: gcc/convert.c =================================================================== --- gcc/convert.c 2018-05-02 08:38:19.345317649 +0100 +++ gcc/convert.c 2018-10-15 14:12:59.024511777 +0100 @@ -521,9 +521,9 @@ convert_to_integer_1 (tree type, tree ex unsigned int outprec = element_precision (type); location_t loc = EXPR_LOCATION (expr); - /* An INTEGER_TYPE cannot be incomplete, but an ENUMERAL_TYPE can - be. Consider `enum E = { a, b = (enum E) 3 };'. */ - if (!COMPLETE_TYPE_P (type)) + /* An INTEGER_TYPE cannot be indefinite (incomplete), but an + ENUMERAL_TYPE can be. Consider `enum E = { a, b = (enum E) 3 };'. */ + if (!DEFINITE_TYPE_P (type)) { error ("conversion to incomplete type"); return error_mark_node; Index: gcc/dbxout.c =================================================================== --- gcc/dbxout.c 2018-10-05 13:46:09.999797249 +0100 +++ gcc/dbxout.c 2018-10-15 14:12:59.024511777 +0100 @@ -1881,7 +1881,7 @@ dbxout_type (tree type, int full) and either that's all we want or that's the best we could do, don't repeat the cross reference. Sun dbx crashes if we do. */ - if (! full || !COMPLETE_TYPE_P (type) + if (! full || !DEFINITE_TYPE_P (type) /* No way in DBX fmt to describe a variable size. */ || ! tree_fits_uhwi_p (TYPE_SIZE (type))) return; @@ -1906,7 +1906,7 @@ dbxout_type (tree type, int full) && ! (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL && DECL_IGNORED_P (TYPE_NAME (type))) && !full) - || !COMPLETE_TYPE_P (type) + || !DEFINITE_TYPE_P (type) /* No way in DBX fmt to describe a variable size. */ || ! tree_fits_uhwi_p (TYPE_SIZE (type))) { @@ -2164,7 +2164,7 @@ dbxout_type (tree type, int full) && ! (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL && DECL_IGNORED_P (TYPE_NAME (type))) && !full) - || !COMPLETE_TYPE_P (type) + || !DEFINITE_TYPE_P (type) /* No way in DBX fmt to describe a variable size. */ || ! tree_fits_uhwi_p (TYPE_SIZE (type))) { @@ -2289,7 +2289,7 @@ dbxout_type (tree type, int full) && ! (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL && DECL_IGNORED_P (TYPE_NAME (type))) && !full) - || !COMPLETE_TYPE_P (type)) + || !DEFINITE_TYPE_P (type)) { stabstr_S ("xe"); dbxout_type_name (type); @@ -2815,7 +2815,7 @@ dbxout_symbol (tree decl, int local ATTR from explicit ones that might be found in C. */ && DECL_ARTIFICIAL (decl) /* Do not generate a tag for incomplete records. */ - && COMPLETE_TYPE_P (type) + && DEFINITE_TYPE_P (type) /* Do not generate a tag for records of variable size, since this type can not be properly described in the DBX format, and it confuses some tools such as objdump. */ @@ -2864,13 +2864,13 @@ dbxout_symbol (tree decl, int local ATTR did_output = 1; } - /* Don't output a tag if this is an incomplete type. This prevents - the sun4 Sun OS 4.x dbx from crashing. */ + /* Don't output a tag if this is an indefinite (incomplete) type. + This prevents the sun4 Sun OS 4.x dbx from crashing. */ if (tag_needed && TYPE_NAME (type) != 0 && (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE || (DECL_NAME (TYPE_NAME (type)) != 0)) - && COMPLETE_TYPE_P (type) + && DEFINITE_TYPE_P (type) && !TREE_ASM_WRITTEN (TYPE_NAME (type))) { /* For a TYPE_DECL with no name, but the type has a name, Index: gcc/dwarf2out.c =================================================================== --- gcc/dwarf2out.c 2018-10-05 13:46:10.003797217 +0100 +++ gcc/dwarf2out.c 2018-10-15 14:12:59.028511745 +0100 @@ -11306,7 +11306,7 @@ add_pubtype (tree decl, dw_die_ref die) if ((TREE_PUBLIC (decl) || is_cu_die (die->die_parent) || is_namespace_die (die->die_parent)) - && (die->die_tag == DW_TAG_typedef || COMPLETE_TYPE_P (decl))) + && (die->die_tag == DW_TAG_typedef || DEFINITE_TYPE_P (decl))) { tree scope = NULL; const char *scope_name = ""; @@ -13448,7 +13448,7 @@ gen_generic_params_dies (tree t) dw_die_ref die = NULL; int non_default; - if (!t || (TYPE_P (t) && !COMPLETE_TYPE_P (t))) + if (!t || (TYPE_P (t) && !DEFINITE_TYPE_P (t))) return; if (TYPE_P (t)) @@ -20924,7 +20924,7 @@ add_subscript_info (dw_die_ref type_die, { if (upper) add_bound_info (subrange_die, DW_AT_upper_bound, upper, NULL); - else if ((is_c () || is_cxx ()) && COMPLETE_TYPE_P (type)) + else if ((is_c () || is_cxx ()) && DEFINITE_TYPE_P (type)) /* Zero-length array. */ add_bound_info (subrange_die, DW_AT_count, build_int_cst (TREE_TYPE (lower), 0), NULL); @@ -27011,7 +27011,7 @@ gen_scheduled_generic_parms_dies (void) return; FOR_EACH_VEC_ELT (*generic_type_instances, i, t) - if (COMPLETE_TYPE_P (t)) + if (DEFINITE_TYPE_P (t)) gen_generic_params_dies (t); generic_type_instances = NULL; Index: gcc/function.c =================================================================== --- gcc/function.c 2018-08-28 11:25:46.018881803 +0100 +++ gcc/function.c 2018-10-15 14:12:59.028511745 +0100 @@ -979,7 +979,7 @@ assign_temp (tree type_or_decl, int memo /* Allocating temporaries of TREE_ADDRESSABLE type must be done in the front end. See also create_tmp_var for the gimplification-time check. */ - gcc_assert (!TREE_ADDRESSABLE (type) && COMPLETE_TYPE_P (type)); + gcc_assert (!TREE_ADDRESSABLE (type) && DEFINITE_TYPE_P (type)); if (mode == BLKmode || memory_required) { Index: gcc/gimple-expr.c =================================================================== --- gcc/gimple-expr.c 2018-05-02 08:38:14.433364094 +0100 +++ gcc/gimple-expr.c 2018-10-15 14:12:59.028511745 +0100 @@ -476,7 +476,7 @@ create_tmp_var (tree type, const char *p The processing for variable sizes is performed in gimple_add_tmp_var, point at which it really matters and possibly reached via paths not going through this function, e.g. after direct calls to create_tmp_var_raw. */ - gcc_assert (!TREE_ADDRESSABLE (type) && COMPLETE_TYPE_P (type)); + gcc_assert (!TREE_ADDRESSABLE (type) && DEFINITE_TYPE_P (type)); tmp_var = create_tmp_var_raw (type, prefix); gimple_add_tmp_var (tmp_var); Index: gcc/gimplify.c =================================================================== --- gcc/gimplify.c 2018-09-25 08:03:44.415261520 +0100 +++ gcc/gimplify.c 2018-10-15 14:12:59.032511711 +0100 @@ -12421,7 +12421,7 @@ gimplify_expr (tree *expr_p, gimple_seq *expr_p = NULL; } - else if (COMPLETE_TYPE_P (TREE_TYPE (*expr_p)) + else if (DEFINITE_TYPE_P (TREE_TYPE (*expr_p)) && TYPE_MODE (TREE_TYPE (*expr_p)) != BLKmode) { /* Historically, the compiler has treated a bare reference Index: gcc/ipa-devirt.c =================================================================== --- gcc/ipa-devirt.c 2018-08-21 14:47:07.791167876 +0100 +++ gcc/ipa-devirt.c 2018-10-15 14:12:59.032511711 +0100 @@ -650,7 +650,7 @@ #define odr_types (*odr_types_ptr) set_type_binfo (tree type, tree binfo) { for (; type; type = TYPE_NEXT_VARIANT (type)) - if (COMPLETE_TYPE_P (type)) + if (DEFINITE_TYPE_P (type)) TYPE_BINFO (type) = binfo; else gcc_assert (!TYPE_BINFO (type)); @@ -1171,7 +1171,8 @@ warn_types_mismatch (tree t1, tree t2, l if (TREE_CODE (t1) == TREE_CODE (t2)) { if (TREE_CODE (t1) == ARRAY_TYPE - && COMPLETE_TYPE_P (t1) && COMPLETE_TYPE_P (t2)) + && DEFINITE_TYPE_P (t1) + && DEFINITE_TYPE_P (t2)) { tree i1 = TYPE_DOMAIN (t1); tree i2 = TYPE_DOMAIN (t2); @@ -1513,7 +1514,7 @@ odr_types_equivalent_p (tree t1, tree t2 tree f1, f2; /* For aggregate types, all the fields must be the same. */ - if (COMPLETE_TYPE_P (t1) && COMPLETE_TYPE_P (t2)) + if (DEFINITE_TYPE_P (t1) && DEFINITE_TYPE_P (t2)) { if (TYPE_BINFO (t1) && TYPE_BINFO (t2) && polymorphic_type_binfo_p (TYPE_BINFO (t1)) @@ -1641,7 +1642,8 @@ odr_types_equivalent_p (tree t1, tree t2 "is defined in another translation unit")); return false; } - if (COMPLETE_TYPE_P (t1) && COMPLETE_TYPE_P (t2) + if (DEFINITE_TYPE_P (t1) + && DEFINITE_TYPE_P (t2) && TYPE_ALIGN (t1) != TYPE_ALIGN (t2)) { warn_odr (t1, t2, NULL, NULL, warn, warned, @@ -1698,12 +1700,12 @@ add_type_duplicate (odr_type val, tree t build_bases = true; } /* Always prefer complete type to be the leader. */ - else if (!COMPLETE_TYPE_P (val->type) && COMPLETE_TYPE_P (type)) + else if (!DEFINITE_TYPE_P (val->type) && DEFINITE_TYPE_P (type)) { prevail = true; build_bases = TYPE_BINFO (type); } - else if (COMPLETE_TYPE_P (val->type) && !COMPLETE_TYPE_P (type)) + else if (DEFINITE_TYPE_P (val->type) && !DEFINITE_TYPE_P (type)) ; else if (TREE_CODE (val->type) == ENUMERAL_TYPE && TREE_CODE (type) == ENUMERAL_TYPE @@ -1740,7 +1742,8 @@ add_type_duplicate (odr_type val, tree t vec_safe_push (val->types, type); /* If both are class types, compare the bases. */ - if (COMPLETE_TYPE_P (type) && COMPLETE_TYPE_P (val->type) + if (DEFINITE_TYPE_P (type) + && DEFINITE_TYPE_P (val->type) && TREE_CODE (val->type) == RECORD_TYPE && TREE_CODE (type) == RECORD_TYPE && TYPE_BINFO (val->type) && TYPE_BINFO (type)) @@ -1879,7 +1882,8 @@ add_type_duplicate (odr_type val, tree t gcc_assert (val->odr_violated || !odr_must_violate); /* Sanity check that all bases will be build same way again. */ if (flag_checking - && COMPLETE_TYPE_P (type) && COMPLETE_TYPE_P (val->type) + && DEFINITE_TYPE_P (type) + && DEFINITE_TYPE_P (val->type) && TREE_CODE (val->type) == RECORD_TYPE && TREE_CODE (type) == RECORD_TYPE && TYPE_BINFO (val->type) && TYPE_BINFO (type) @@ -2059,7 +2063,7 @@ get_odr_type (tree type, bool insert) val->anonymous_namespace = type_in_anonymous_namespace_p (type); else val->anonymous_namespace = 0; - build_bases = COMPLETE_TYPE_P (val->type); + build_bases = DEFINITE_TYPE_P (val->type); insert_to_odr_array = true; if (slot) *slot = val; Index: gcc/ipa-icf.c =================================================================== --- gcc/ipa-icf.c 2018-10-05 13:46:14.391761673 +0100 +++ gcc/ipa-icf.c 2018-10-15 14:12:59.032511711 +0100 @@ -1584,8 +1584,8 @@ sem_item::add_type (const_tree type, inc } else if (RECORD_OR_UNION_TYPE_P (type)) { - /* Incomplete types must be skipped here. */ - if (!COMPLETE_TYPE_P (type)) + /* Indefinite types must be skipped here. */ + if (!DEFINITE_TYPE_P (type)) { hstate.add_int (RECORD_TYPE); return; Index: gcc/langhooks.c =================================================================== --- gcc/langhooks.c 2018-10-05 13:46:11.107788274 +0100 +++ gcc/langhooks.c 2018-10-15 14:12:59.032511711 +0100 @@ -593,8 +593,8 @@ lhd_omp_firstprivatize_type_sizes (struc bool lhd_omp_mappable_type (tree type) { - /* Mappable type has to be complete. */ - if (type == error_mark_node || !COMPLETE_TYPE_P (type)) + /* Mappable type has to be definite. */ + if (type == error_mark_node || !DEFINITE_TYPE_P (type)) return false; return true; } Index: gcc/omp-low.c =================================================================== --- gcc/omp-low.c 2018-08-28 11:25:45.614885279 +0100 +++ gcc/omp-low.c 2018-10-15 14:12:59.032511711 +0100 @@ -1023,7 +1023,7 @@ scan_sharing_clauses (tree clauses, omp_ break; } gcc_assert (is_taskreg_ctx (ctx)); - gcc_assert (!COMPLETE_TYPE_P (TREE_TYPE (decl)) + gcc_assert (!DEFINITE_TYPE_P (TREE_TYPE (decl)) || !is_variable_sized (decl)); /* Global variables don't need to be copied, the receiver side will use them directly. */ @@ -1429,7 +1429,7 @@ scan_sharing_clauses (tree clauses, omp_ if ((OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_POINTER || OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_FIRSTPRIVATE_POINTER) && TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE - && !COMPLETE_TYPE_P (TREE_TYPE (decl))) + && !DEFINITE_TYPE_P (TREE_TYPE (decl))) { tree new_decl = lookup_decl (decl, ctx); TREE_TYPE (new_decl) Index: gcc/tree-ssa-sccvn.c =================================================================== --- gcc/tree-ssa-sccvn.c 2018-10-05 13:46:08.871806387 +0100 +++ gcc/tree-ssa-sccvn.c 2018-10-15 14:12:59.032511711 +0100 @@ -1424,7 +1424,7 @@ fully_constant_vn_reference_p (vn_refere /* Simplify reads from constants or constant initializers. */ else if (BITS_PER_UNIT == 8 - && COMPLETE_TYPE_P (ref->type) + && DEFINITE_TYPE_P (ref->type) && is_gimple_reg_type (ref->type)) { poly_int64 off = 0; Index: gcc/tree.c =================================================================== --- gcc/tree.c 2018-10-05 13:46:08.863806452 +0100 +++ gcc/tree.c 2018-10-15 14:12:59.036511679 +0100 @@ -6523,7 +6523,8 @@ type_cache_hasher::equal (type_hash *a, /* Be careful about comparing arrays before and after the element type has been completed; don't compare TYPE_ALIGN unless both types are complete. */ - if (COMPLETE_TYPE_P (a->type) && COMPLETE_TYPE_P (b->type) + if (DEFINITE_TYPE_P (a->type) + && DEFINITE_TYPE_P (b->type) && (TYPE_ALIGN (a->type) != TYPE_ALIGN (b->type) || TYPE_MODE (a->type) != TYPE_MODE (b->type))) return 0; @@ -8083,7 +8084,7 @@ build_function_type (tree value_type, tr TYPE_CANONICAL (t) = build_function_type (TYPE_CANONICAL (value_type), canon_argtypes); - if (!COMPLETE_TYPE_P (t)) + if (!DEFINITE_TYPE_P (t)) layout_type (t); return t; } @@ -8242,7 +8243,7 @@ build_method_type_directly (tree basetyp = build_method_type_directly (TYPE_CANONICAL (basetype), TYPE_CANONICAL (rettype), canon_argtypes); - if (!COMPLETE_TYPE_P (t)) + if (!DEFINITE_TYPE_P (t)) layout_type (t); return t; @@ -8282,7 +8283,7 @@ build_offset_type (tree basetype, tree t hashval_t hash = type_hash_canon_hash (t); t = type_hash_canon (hash, t); - if (!COMPLETE_TYPE_P (t)) + if (!DEFINITE_TYPE_P (t)) layout_type (t); if (TYPE_CANONICAL (t) == t) @@ -8328,7 +8329,7 @@ build_complex_type (tree component_type, /* We created a new type. The hash insertion will have laid out the type. We need to check the canonicalization and maybe set the name. */ - gcc_checking_assert (COMPLETE_TYPE_P (t) + gcc_checking_assert (DEFINITE_TYPE_P (t) && !TYPE_NAME (t) && TYPE_CANONICAL (t) == t); @@ -13216,12 +13217,12 @@ #define verify_variant_match(flag) else verify_variant_match (TYPE_SATURATING); /* FIXME: This check trigger during libstdc++ build. */ - if (RECORD_OR_UNION_TYPE_P (t) && COMPLETE_TYPE_P (t) && 0) + if (RECORD_OR_UNION_TYPE_P (t) && DEFINITE_TYPE_P (t) && 0) verify_variant_match (TYPE_FINAL_P); /* tree_type_common checks. */ - if (COMPLETE_TYPE_P (t)) + if (DEFINITE_TYPE_P (t)) { verify_variant_match (TYPE_MODE); if (TREE_CODE (TYPE_SIZE (t)) != PLACEHOLDER_EXPR @@ -13274,7 +13275,7 @@ #define verify_variant_match(flag) debug_tree (tv); return false; } - if ((TREE_CODE (t) == ENUMERAL_TYPE && COMPLETE_TYPE_P (t)) + if ((TREE_CODE (t) == ENUMERAL_TYPE && DEFINITE_TYPE_P (t)) || TREE_CODE (t) == INTEGER_TYPE || TREE_CODE (t) == BOOLEAN_TYPE || TREE_CODE (t) == REAL_TYPE @@ -13293,7 +13294,7 @@ #define verify_variant_match(flag) or even type's main variant. This is needed to make bootstrap pass and the bug seems new in GCC 5. C++ FE should be updated to make this consistent and we should check - that TYPE_BINFO is always NULL for !COMPLETE_TYPE_P and otherwise there + that TYPE_BINFO is always NULL for !DEFINITE_TYPE_P and otherwise there is a match with main variant. Also disable the check for Java for now because of parser hack that builds @@ -13323,7 +13324,7 @@ #define verify_variant_match(flag) /* Permit incomplete variants of complete type. While FEs may complete all variants, this does not happen for C++ templates in all cases. */ else if (RECORD_OR_UNION_TYPE_P (t) - && COMPLETE_TYPE_P (t) + && DEFINITE_TYPE_P (t) && TYPE_FIELDS (t) != TYPE_FIELDS (tv)) { tree f1, f2; @@ -13625,7 +13626,7 @@ gimple_canonical_types_compatible_p (con /* Don't try to compare variants of an incomplete type, before TYPE_FIELDS has been copied around. */ - if (!COMPLETE_TYPE_P (t1) && !COMPLETE_TYPE_P (t2)) + if (!DEFINITE_TYPE_P (t1) && !DEFINITE_TYPE_P (t2)) return true; @@ -13723,7 +13724,8 @@ verify_type (const_tree t) error_found = true; } - if (COMPLETE_TYPE_P (t) && TYPE_CANONICAL (t) + if (DEFINITE_TYPE_P (t) + && TYPE_CANONICAL (t) && TYPE_MODE (t) != TYPE_MODE (TYPE_CANONICAL (t))) { error ("TYPE_MODE of TYPE_CANONICAL is not compatible"); @@ -13897,7 +13899,7 @@ verify_type (const_tree t) } else if (RECORD_OR_UNION_TYPE_P (t)) { - if (TYPE_FIELDS (t) && !COMPLETE_TYPE_P (t) && in_lto_p) + if (TYPE_FIELDS (t) && !DEFINITE_TYPE_P (t) && in_lto_p) { error ("TYPE_FIELDS defined in incomplete type"); error_found = true; Index: gcc/ada/gcc-interface/decl.c =================================================================== --- gcc/ada/gcc-interface/decl.c 2018-10-15 14:08:45.694611103 +0100 +++ gcc/ada/gcc-interface/decl.c 2018-10-15 14:12:59.020511811 +0100 @@ -2118,7 +2118,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entit Var are also built later with the fields of the final type, the aliasing machinery may consider that the accesses are distinct if the FIELD_DECLs are distinct as objects. */ - if (COMPLETE_TYPE_P (gnu_fat_type)) + if (DEFINITE_TYPE_P (gnu_fat_type)) { tem = TYPE_FIELDS (gnu_fat_type); TREE_TYPE (tem) = ptr_type_node; Index: gcc/ada/gcc-interface/utils2.c =================================================================== --- gcc/ada/gcc-interface/utils2.c 2018-05-02 08:38:09.069414813 +0100 +++ gcc/ada/gcc-interface/utils2.c 2018-10-15 14:12:59.020511811 +0100 @@ -2004,7 +2004,7 @@ build_simple_component_ref (tree record, tree type = TYPE_MAIN_VARIANT (TREE_TYPE (record)); tree ref; - gcc_assert (RECORD_OR_UNION_TYPE_P (type) && COMPLETE_TYPE_P (type)); + gcc_assert (RECORD_OR_UNION_TYPE_P (type) && DEFINITE_TYPE_P (type)); /* Try to fold a conversion from another record or union type unless the type contains a placeholder as it might be needed for a later substitution. */ Index: gcc/fortran/trans-decl.c =================================================================== --- gcc/fortran/trans-decl.c 2018-10-05 13:46:10.559792714 +0100 +++ gcc/fortran/trans-decl.c 2018-10-15 14:12:59.028511745 +0100 @@ -1059,7 +1059,7 @@ gfc_build_qualified_array (tree decl, gf type = TREE_TYPE (type); } - if (! COMPLETE_TYPE_P (type) && GFC_TYPE_ARRAY_SIZE (type)) + if (!DEFINITE_TYPE_P (type) && GFC_TYPE_ARRAY_SIZE (type)) { tree size, range; @@ -2542,7 +2542,7 @@ create_function_arglist (gfc_symbol * sy && TREE_CODE (type) == POINTER_TYPE && GFC_ARRAY_TYPE_P (type) && f->sym->as->type != AS_ASSUMED_SIZE - && ! COMPLETE_TYPE_P (TREE_TYPE (type))) + && !DEFINITE_TYPE_P (TREE_TYPE (type))) { if (f->sym->attr.flavor == FL_PROCEDURE) type = build_pointer_type (gfc_get_function_type (f->sym)); Index: gcc/lto/lto-symtab.c =================================================================== --- gcc/lto/lto-symtab.c 2018-10-15 14:12:54.040553089 +0100 +++ gcc/lto/lto-symtab.c 2018-10-15 14:12:59.032511711 +0100 @@ -787,8 +787,8 @@ lto_symtab_merge_decls_1 (symtab_node *f { for (e = prevailing->next_sharing_asm_name; e; e = e->next_sharing_asm_name) - if (!COMPLETE_TYPE_P (TREE_TYPE (prevailing->decl)) - && COMPLETE_TYPE_P (TREE_TYPE (e->decl)) + if (!DEFINITE_TYPE_P (TREE_TYPE (prevailing->decl)) + && DEFINITE_TYPE_P (TREE_TYPE (e->decl)) && lto_symtab_symbol_p (e)) prevailing = e; }