diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 604eaea921c..7413811cb80 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,13 @@ +2004-06-13 Joseph S. Myers + + * c-typeck.c (comptypes, tagged_types_tu_compatible_p, + function_types_compatible_p, type_lists_compatible_p): Remove + flags parameter. + * c-tree.h (comptypes): Likewise. + (COMPARE_STRICT): Remove. + * c-decl.c, c-lang.c, c-parse.in, c-typeck.c, objc/objc-act.c: All + callers changed. + 2004-06-13 Eric Christopher * c-decl.c (diagnose_mismatched_decls): Improve error message. diff --git a/gcc/c-decl.c b/gcc/c-decl.c index 2fd53ea7b50..713be8fa464 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -936,7 +936,7 @@ diagnose_arglist_conflict (tree newdecl, tree olddecl, tree t; if (TREE_CODE (olddecl) != FUNCTION_DECL - || !comptypes (TREE_TYPE (oldtype), TREE_TYPE (newtype), COMPARE_STRICT) + || !comptypes (TREE_TYPE (oldtype), TREE_TYPE (newtype)) || !((TYPE_ARG_TYPES (oldtype) == 0 && DECL_INITIAL (olddecl) == 0) || (TYPE_ARG_TYPES (newtype) == 0 && DECL_INITIAL (newdecl) == 0))) @@ -1008,7 +1008,7 @@ validate_proto_after_old_defn (tree newdecl, tree newtype, tree oldtype) /* Type for passing arg must be consistent with that declared for the arg. */ - else if (! comptypes (oldargtype, newargtype, COMPARE_STRICT)) + else if (! comptypes (oldargtype, newargtype)) { error ("%Jprototype for '%D' declares arg %d with incompatible type", newdecl, newdecl, i); @@ -1090,7 +1090,7 @@ diagnose_mismatched_decls (tree newdecl, tree olddecl, return false; } - if (!comptypes (oldtype, newtype, COMPARE_STRICT)) + if (!comptypes (oldtype, newtype)) { if (TREE_CODE (olddecl) == FUNCTION_DECL && DECL_BUILT_IN (olddecl) && !C_DECL_DECLARED_BUILTIN (olddecl)) @@ -1099,7 +1099,7 @@ diagnose_mismatched_decls (tree newdecl, tree olddecl, This is for the ffs and fprintf builtins. */ tree trytype = match_builtin_function_types (newtype, oldtype); - if (trytype && comptypes (newtype, trytype, COMPARE_STRICT)) + if (trytype && comptypes (newtype, trytype)) *oldtypep = oldtype = trytype; else { @@ -6008,8 +6008,7 @@ store_parm_decls_oldstyle (tree fndecl, tree arg_info) declared for the arg. ISO C says we take the unqualified type for parameters declared with qualified type. */ if (! comptypes (TYPE_MAIN_VARIANT (DECL_ARG_TYPE (parm)), - TYPE_MAIN_VARIANT (TREE_VALUE (type)), - COMPARE_STRICT)) + TYPE_MAIN_VARIANT (TREE_VALUE (type)))) { if (TYPE_MAIN_VARIANT (TREE_TYPE (parm)) == TYPE_MAIN_VARIANT (TREE_VALUE (type))) diff --git a/gcc/c-lang.c b/gcc/c-lang.c index cf422cb3cc5..3bdd246c783 100644 --- a/gcc/c-lang.c +++ b/gcc/c-lang.c @@ -216,7 +216,7 @@ finish_file (void) int c_types_compatible_p (tree x, tree y) { - return comptypes (TYPE_MAIN_VARIANT (x), TYPE_MAIN_VARIANT (y), 0); + return comptypes (TYPE_MAIN_VARIANT (x), TYPE_MAIN_VARIANT (y)); } static void c_initialize_diagnostics (diagnostic_context *context) diff --git a/gcc/c-parse.in b/gcc/c-parse.in index b89c19d80b6..08badedb002 100644 --- a/gcc/c-parse.in +++ b/gcc/c-parse.in @@ -700,7 +700,7 @@ primary: e1 = TYPE_MAIN_VARIANT (groktypename ($3)); e2 = TYPE_MAIN_VARIANT (groktypename ($5)); - $$ = comptypes (e1, e2, COMPARE_STRICT) + $$ = comptypes (e1, e2) ? build_int_2 (1, 0) : build_int_2 (0, 0); } | TYPES_COMPATIBLE_P '(' error ')' diff --git a/gcc/c-tree.h b/gcc/c-tree.h index e698c871a12..e758c98afd8 100644 --- a/gcc/c-tree.h +++ b/gcc/c-tree.h @@ -214,14 +214,9 @@ extern bool c_warn_unused_global_decl (tree); /* in c-typeck.c */ -/* For use with comptypes. */ -enum { - COMPARE_STRICT = 0 -}; - extern tree require_complete_type (tree); extern int same_translation_unit_p (tree, tree); -extern int comptypes (tree, tree, int); +extern int comptypes (tree, tree); extern tree c_size_in_bytes (tree); extern bool c_mark_addressable (tree); extern void c_incomplete_type_error (tree, tree); diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index 321607c2263..c1a262b82d8 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -54,10 +54,10 @@ static int require_constant_value; static int require_constant_elements; static tree qualify_type (tree, tree); -static int tagged_types_tu_compatible_p (tree, tree, int); +static int tagged_types_tu_compatible_p (tree, tree); static int comp_target_types (tree, tree, int); -static int function_types_compatible_p (tree, tree, int); -static int type_lists_compatible_p (tree, tree, int); +static int function_types_compatible_p (tree, tree); +static int type_lists_compatible_p (tree, tree); static tree decl_constant_value_for_broken_optimization (tree); static tree default_function_array_conversion (tree); static tree lookup_field (tree, tree); @@ -338,8 +338,7 @@ composite_type (tree t1, tree t2) tree memb; for (memb = TYPE_FIELDS (TREE_VALUE (p1)); memb; memb = TREE_CHAIN (memb)) - if (comptypes (TREE_TYPE (memb), TREE_VALUE (p2), - COMPARE_STRICT)) + if (comptypes (TREE_TYPE (memb), TREE_VALUE (p2))) { TREE_VALUE (n) = TREE_VALUE (p2); if (pedantic) @@ -353,8 +352,7 @@ composite_type (tree t1, tree t2) tree memb; for (memb = TYPE_FIELDS (TREE_VALUE (p2)); memb; memb = TREE_CHAIN (memb)) - if (comptypes (TREE_TYPE (memb), TREE_VALUE (p1), - COMPARE_STRICT)) + if (comptypes (TREE_TYPE (memb), TREE_VALUE (p1))) { TREE_VALUE (n) = TREE_VALUE (p1); if (pedantic) @@ -558,7 +556,7 @@ common_type (tree t1, tree t2) but a warning may be needed if you use them together. */ int -comptypes (tree type1, tree type2, int flags) +comptypes (tree type1, tree type2) { tree t1 = type1; tree t2 = type2; @@ -625,11 +623,11 @@ comptypes (tree type1, tree type2, int flags) if (c_dialect_objc () && (val = objc_comptypes (t1, t2, 0)) >= 0) break; val = (TREE_TYPE (t1) == TREE_TYPE (t2) - ? 1 : comptypes (TREE_TYPE (t1), TREE_TYPE (t2), flags)); + ? 1 : comptypes (TREE_TYPE (t1), TREE_TYPE (t2))); break; case FUNCTION_TYPE: - val = function_types_compatible_p (t1, t2, flags); + val = function_types_compatible_p (t1, t2); break; case ARRAY_TYPE: @@ -642,8 +640,7 @@ comptypes (tree type1, tree type2, int flags) /* Target types must match incl. qualifiers. */ if (TREE_TYPE (t1) != TREE_TYPE (t2) - && 0 == (val = comptypes (TREE_TYPE (t1), TREE_TYPE (t2), - flags))) + && 0 == (val = comptypes (TREE_TYPE (t1), TREE_TYPE (t2)))) return 0; /* Sizes must match unless one is missing or variable. */ @@ -681,12 +678,12 @@ comptypes (tree type1, tree type2, int flags) case ENUMERAL_TYPE: case UNION_TYPE: if (val != 1 && !same_translation_unit_p (t1, t2)) - val = tagged_types_tu_compatible_p (t1, t2, flags); + val = tagged_types_tu_compatible_p (t1, t2); break; case VECTOR_TYPE: val = TYPE_VECTOR_SUBPARTS (t1) == TYPE_VECTOR_SUBPARTS (t2) - && comptypes (TREE_TYPE (t1), TREE_TYPE (t2), 0); + && comptypes (TREE_TYPE (t1), TREE_TYPE (t2)); break; default: @@ -712,7 +709,7 @@ comp_target_types (tree ttl, tree ttr, int reflexive) return val; val = comptypes (TYPE_MAIN_VARIANT (TREE_TYPE (ttl)), - TYPE_MAIN_VARIANT (TREE_TYPE (ttr)), COMPARE_STRICT); + TYPE_MAIN_VARIANT (TREE_TYPE (ttr))); if (val == 2 && pedantic) pedwarn ("types are not quite compatible"); @@ -772,7 +769,7 @@ static const struct tagged_tu_seen * tagged_tu_seen_base; rules. */ static int -tagged_types_tu_compatible_p (tree t1, tree t2, int flags) +tagged_types_tu_compatible_p (tree t1, tree t2) { tree s1, s2; bool needs_warning = false; @@ -869,7 +866,7 @@ tagged_types_tu_compatible_p (tree t1, tree t2, int flags) if (DECL_NAME (s1) == DECL_NAME (s2)) { int result; - result = comptypes (TREE_TYPE (s1), TREE_TYPE (s2), flags); + result = comptypes (TREE_TYPE (s1), TREE_TYPE (s2)); if (result == 0) break; if (result == 2) @@ -907,7 +904,7 @@ tagged_types_tu_compatible_p (tree t1, tree t2, int flags) if (TREE_CODE (s1) != TREE_CODE (s2) || DECL_NAME (s1) != DECL_NAME (s2)) break; - result = comptypes (TREE_TYPE (s1), TREE_TYPE (s2), flags); + result = comptypes (TREE_TYPE (s1), TREE_TYPE (s2)); if (result == 0) break; if (result == 2) @@ -937,7 +934,7 @@ tagged_types_tu_compatible_p (tree t1, tree t2, int flags) Otherwise, the argument types must match. */ static int -function_types_compatible_p (tree f1, tree f2, int flags) +function_types_compatible_p (tree f1, tree f2) { tree args1, args2; /* 1 if no need for warning yet, 2 if warning cause has been seen. */ @@ -958,7 +955,7 @@ function_types_compatible_p (tree f1, tree f2, int flags) if (TYPE_VOLATILE (ret2)) ret2 = build_qualified_type (TYPE_MAIN_VARIANT (ret2), TYPE_QUALS (ret2) & ~TYPE_QUAL_VOLATILE); - val = comptypes (ret1, ret2, flags); + val = comptypes (ret1, ret2); if (val == 0) return 0; @@ -976,8 +973,7 @@ function_types_compatible_p (tree f1, tree f2, int flags) compare that with the other type's arglist. If they don't match, ask for a warning (but no error). */ if (TYPE_ACTUAL_ARG_TYPES (f1) - && 1 != type_lists_compatible_p (args2, TYPE_ACTUAL_ARG_TYPES (f1), - flags)) + && 1 != type_lists_compatible_p (args2, TYPE_ACTUAL_ARG_TYPES (f1))) val = 2; return val; } @@ -986,14 +982,13 @@ function_types_compatible_p (tree f1, tree f2, int flags) if (!self_promoting_args_p (args1)) return 0; if (TYPE_ACTUAL_ARG_TYPES (f2) - && 1 != type_lists_compatible_p (args1, TYPE_ACTUAL_ARG_TYPES (f2), - flags)) + && 1 != type_lists_compatible_p (args1, TYPE_ACTUAL_ARG_TYPES (f2))) val = 2; return val; } /* Both types have argument lists: compare them and propagate results. */ - val1 = type_lists_compatible_p (args1, args2, flags); + val1 = type_lists_compatible_p (args1, args2); return val1 != 1 ? val1 : val; } @@ -1002,7 +997,7 @@ function_types_compatible_p (tree f1, tree f2, int flags) or 2 for compatible with warning. */ static int -type_lists_compatible_p (tree args1, tree args2, int flags) +type_lists_compatible_p (tree args1, tree args2) { /* 1 if no need for warning yet, 2 if warning cause has been seen. */ int val = 1; @@ -1035,8 +1030,7 @@ type_lists_compatible_p (tree args1, tree args2, int flags) || TREE_CODE (TREE_VALUE (args2)) == ERROR_MARK) ; else if (! (newval = comptypes (TYPE_MAIN_VARIANT (TREE_VALUE (args1)), - TYPE_MAIN_VARIANT (TREE_VALUE (args2)), - flags))) + TYPE_MAIN_VARIANT (TREE_VALUE (args2))))) { /* Allow wait (union {union wait *u; int *i} *) and wait (union wait *) to be compatible. */ @@ -1050,8 +1044,7 @@ type_lists_compatible_p (tree args1, tree args2, int flags) tree memb; for (memb = TYPE_FIELDS (TREE_VALUE (args1)); memb; memb = TREE_CHAIN (memb)) - if (comptypes (TREE_TYPE (memb), TREE_VALUE (args2), - flags)) + if (comptypes (TREE_TYPE (memb), TREE_VALUE (args2))) break; if (memb == 0) return 0; @@ -1066,8 +1059,7 @@ type_lists_compatible_p (tree args1, tree args2, int flags) tree memb; for (memb = TYPE_FIELDS (TREE_VALUE (args2)); memb; memb = TREE_CHAIN (memb)) - if (comptypes (TREE_TYPE (memb), TREE_VALUE (args1), - flags)) + if (comptypes (TREE_TYPE (memb), TREE_VALUE (args1))) break; if (memb == 0) return 0; @@ -1837,7 +1829,7 @@ build_function_call (tree function, tree params) && TREE_CODE (function) == NOP_EXPR && TREE_CODE (tem = TREE_OPERAND (function, 0)) == ADDR_EXPR && TREE_CODE (tem = TREE_OPERAND (tem, 0)) == FUNCTION_DECL - && ! comptypes (fntype, TREE_TYPE (tem), COMPARE_STRICT)) + && ! comptypes (fntype, TREE_TYPE (tem))) { tree return_type = TREE_TYPE (fntype); tree trap = build_function_call (built_in_decls[BUILT_IN_TRAP], @@ -3013,7 +3005,7 @@ build_c_cast (tree type, tree expr) for (field = TYPE_FIELDS (type); field; field = TREE_CHAIN (field)) if (comptypes (TYPE_MAIN_VARIANT (TREE_TYPE (field)), - TYPE_MAIN_VARIANT (TREE_TYPE (value)), COMPARE_STRICT)) + TYPE_MAIN_VARIANT (TREE_TYPE (value)))) break; if (field) @@ -3361,7 +3353,7 @@ convert_for_assignment (tree type, tree rhs, const char *errtype, This code doesn't fully support references, it's just for the special case of va_start and va_copy. */ if (codel == REFERENCE_TYPE - && comptypes (TREE_TYPE (type), TREE_TYPE (rhs), COMPARE_STRICT) == 1) + && comptypes (TREE_TYPE (type), TREE_TYPE (rhs)) == 1) { if (!lvalue_p (rhs)) { @@ -3409,7 +3401,7 @@ convert_for_assignment (tree type, tree rhs, const char *errtype, tree memb_type = TREE_TYPE (memb_types); if (comptypes (TYPE_MAIN_VARIANT (memb_type), - TYPE_MAIN_VARIANT (rhstype), COMPARE_STRICT)) + TYPE_MAIN_VARIANT (rhstype))) break; if (TREE_CODE (memb_type) != POINTER_TYPE) @@ -3988,7 +3980,7 @@ digest_init (tree type, tree init, int require_constant) && ((inside_init && TREE_CODE (inside_init) == STRING_CST))) { if (comptypes (TYPE_MAIN_VARIANT (TREE_TYPE (inside_init)), - TYPE_MAIN_VARIANT (type), COMPARE_STRICT)) + TYPE_MAIN_VARIANT (type))) return inside_init; if ((TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (inside_init))) @@ -4035,8 +4027,7 @@ digest_init (tree type, tree init, int require_constant) { if (TREE_CODE (inside_init) == VECTOR_CST && comptypes (TYPE_MAIN_VARIANT (TREE_TYPE (inside_init)), - TYPE_MAIN_VARIANT (type), - COMPARE_STRICT)) + TYPE_MAIN_VARIANT (type))) return inside_init; else return build_vector (type, CONSTRUCTOR_ELTS (inside_init)); @@ -4047,19 +4038,19 @@ digest_init (tree type, tree init, int require_constant) if (inside_init && TREE_TYPE (inside_init) != 0 && (comptypes (TYPE_MAIN_VARIANT (TREE_TYPE (inside_init)), - TYPE_MAIN_VARIANT (type), COMPARE_STRICT) + TYPE_MAIN_VARIANT (type)) || (code == ARRAY_TYPE - && comptypes (TREE_TYPE (inside_init), type, COMPARE_STRICT)) + && comptypes (TREE_TYPE (inside_init), type)) || (code == VECTOR_TYPE - && comptypes (TREE_TYPE (inside_init), type, COMPARE_STRICT)) + && comptypes (TREE_TYPE (inside_init), type)) || (code == POINTER_TYPE && TREE_CODE (TREE_TYPE (inside_init)) == ARRAY_TYPE && comptypes (TREE_TYPE (TREE_TYPE (inside_init)), - TREE_TYPE (type), COMPARE_STRICT)) + TREE_TYPE (type))) || (code == POINTER_TYPE && TREE_CODE (TREE_TYPE (inside_init)) == FUNCTION_TYPE && comptypes (TREE_TYPE (inside_init), - TREE_TYPE (type), COMPARE_STRICT)))) + TREE_TYPE (type))))) { if (code == POINTER_TYPE) { @@ -5500,7 +5491,7 @@ output_init_element (tree value, tree type, tree field, int pending) && TREE_CODE (type) == ARRAY_TYPE && TREE_CODE (TREE_TYPE (type)) == INTEGER_TYPE) && !comptypes (TYPE_MAIN_VARIANT (TREE_TYPE (value)), - TYPE_MAIN_VARIANT (type), COMPARE_STRICT))) + TYPE_MAIN_VARIANT (type)))) value = default_conversion (value); if (TREE_CODE (value) == COMPOUND_LITERAL_EXPR diff --git a/gcc/objc/objc-act.c b/gcc/objc/objc-act.c index 791f320a12a..96e29b181ba 100644 --- a/gcc/objc/objc-act.c +++ b/gcc/objc/objc-act.c @@ -1,6 +1,6 @@ /* Implement classes and message passing for Objective C. Copyright (C) 1992, 1993, 1994, 1995, 1997, 1998, 1999, 2000, - 2001, 2002, 2003 Free Software Foundation, Inc. + 2001, 2002, 2003, 2004 Free Software Foundation, Inc. Contributed by Steve Naroff. This file is part of GCC. @@ -4257,7 +4257,7 @@ check_ivars (tree inter, tree imp) t1 = TREE_TYPE (intdecls); t2 = TREE_TYPE (impdecls); - if (!comptypes (t1, t2, false) + if (!comptypes (t1, t2) || !tree_int_cst_equal (TREE_VALUE (TREE_VALUE (rawintdecls)), TREE_VALUE (TREE_VALUE (rawimpdecls)))) { @@ -7612,8 +7612,7 @@ comp_method_with_proto (tree method, tree proto) /* install return type */ TREE_TYPE (function1_template) = groktypename (TREE_TYPE (proto)); - return comptypes (TREE_TYPE (METHOD_DEFINITION (method)), function1_template, - false); + return comptypes (TREE_TYPE (METHOD_DEFINITION (method)), function1_template); } /* Return 1 if TYPE1 is equivalent to TYPE2. */