c-tree.h: Delete COMPARE_DIFFERENT_TU from enumeration.
* c-tree.h: Delete COMPARE_DIFFERENT_TU from enumeration. * c-typeck.c (same_translation_unit_p): New function. (comptypes): Use it instead of flags parameter to identify structure types from different translation units. * c-decl.c (duplicate_decls): Always call comptypes with COMPTYPE_STRICT flags argument. (c_reset_state): Set BLOCK_SUPERCONTEXT of the block formed to file_scope_decl. From-SVN: r70953
This commit is contained in:
parent
bf7a697f0a
commit
766beae187
|
@ -1,3 +1,14 @@
|
|||
2003-08-30 Zack Weinberg <zack@codesourcery.com>
|
||||
|
||||
* c-tree.h: Delete COMPARE_DIFFERENT_TU from enumeration.
|
||||
* c-typeck.c (same_translation_unit_p): New function.
|
||||
(comptypes): Use it instead of flags parameter to identify
|
||||
structure types from different translation units.
|
||||
* c-decl.c (duplicate_decls): Always call comptypes with
|
||||
COMPTYPE_STRICT flags argument.
|
||||
(c_reset_state): Set BLOCK_SUPERCONTEXT of the block formed
|
||||
to file_scope_decl.
|
||||
|
||||
2003-08-30 Zack Weinberg <zack@codesourcery.com>
|
||||
|
||||
* c-tree.h (C_TYPE_INCOMPLETE_VARS): New macro.
|
||||
|
|
13
gcc/c-decl.c
13
gcc/c-decl.c
|
@ -775,10 +775,8 @@ static int
|
|||
duplicate_decls (tree newdecl, tree olddecl, int different_binding_level,
|
||||
int different_tu)
|
||||
{
|
||||
int comptype_flags = (different_tu ? COMPARE_DIFFERENT_TU
|
||||
: COMPARE_STRICT);
|
||||
int types_match = comptypes (TREE_TYPE (newdecl), TREE_TYPE (olddecl),
|
||||
comptype_flags);
|
||||
COMPARE_STRICT);
|
||||
int new_is_definition = (TREE_CODE (newdecl) == FUNCTION_DECL
|
||||
&& DECL_INITIAL (newdecl) != 0);
|
||||
tree oldtype = TREE_TYPE (olddecl);
|
||||
|
@ -897,7 +895,7 @@ duplicate_decls (tree newdecl, tree olddecl, int different_binding_level,
|
|||
|
||||
if (trytype)
|
||||
{
|
||||
types_match = comptypes (newtype, trytype, comptype_flags);
|
||||
types_match = comptypes (newtype, trytype, COMPARE_STRICT);
|
||||
if (types_match)
|
||||
oldtype = trytype;
|
||||
if (! different_binding_level)
|
||||
|
@ -983,7 +981,7 @@ duplicate_decls (tree newdecl, tree olddecl, int different_binding_level,
|
|||
&& ! pedantic
|
||||
/* Return types must still match. */
|
||||
&& comptypes (TREE_TYPE (oldtype),
|
||||
TREE_TYPE (newtype), comptype_flags)
|
||||
TREE_TYPE (newtype), COMPARE_STRICT)
|
||||
&& TYPE_ARG_TYPES (newtype) == 0))
|
||||
{
|
||||
error ("%Hconflicting types for '%D'",
|
||||
|
@ -992,7 +990,7 @@ duplicate_decls (tree newdecl, tree olddecl, int different_binding_level,
|
|||
involving an empty arglist vs a nonempty one. */
|
||||
if (TREE_CODE (olddecl) == FUNCTION_DECL
|
||||
&& comptypes (TREE_TYPE (oldtype),
|
||||
TREE_TYPE (newtype), comptype_flags)
|
||||
TREE_TYPE (newtype), COMPARE_STRICT)
|
||||
&& ((TYPE_ARG_TYPES (oldtype) == 0
|
||||
&& DECL_INITIAL (olddecl) == 0)
|
||||
||
|
||||
|
@ -1135,7 +1133,7 @@ duplicate_decls (tree newdecl, tree olddecl, int different_binding_level,
|
|||
/* Type for passing arg must be consistent
|
||||
with that declared for the arg. */
|
||||
if (! comptypes (TREE_VALUE (parm), TREE_VALUE (type),
|
||||
comptype_flags))
|
||||
COMPARE_STRICT))
|
||||
{
|
||||
const location_t *locus = &DECL_SOURCE_LOCATION (newdecl);
|
||||
error ("%Hprototype for '%D' follows and argument %d "
|
||||
|
@ -6701,6 +6699,7 @@ c_reset_state (void)
|
|||
current_scope = global_scope;
|
||||
file_scope_decl = current_file_decl;
|
||||
DECL_INITIAL (file_scope_decl) = poplevel (1, 0, 0);
|
||||
BLOCK_SUPERCONTEXT (DECL_INITIAL (file_scope_decl)) = file_scope_decl;
|
||||
truly_local_externals = NULL_TREE;
|
||||
|
||||
/* Start a new global binding level. */
|
||||
|
|
|
@ -244,8 +244,7 @@ extern bool c_warn_unused_global_decl (tree);
|
|||
|
||||
/* For use with comptypes. */
|
||||
enum {
|
||||
COMPARE_STRICT = 0,
|
||||
COMPARE_DIFFERENT_TU = 1
|
||||
COMPARE_STRICT = 0
|
||||
};
|
||||
|
||||
extern tree require_complete_type (tree);
|
||||
|
|
|
@ -50,6 +50,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
|
|||
static int missing_braces_mentioned;
|
||||
|
||||
static tree qualify_type (tree, tree);
|
||||
static int same_translation_unit_p (tree, tree);
|
||||
static int tagged_types_tu_compatible_p (tree, tree, int);
|
||||
static int comp_target_types (tree, tree, int);
|
||||
static int function_types_compatible_p (tree, tree, int);
|
||||
|
@ -564,7 +565,7 @@ comptypes (tree type1, tree type2, int flags)
|
|||
|
||||
case ENUMERAL_TYPE:
|
||||
case UNION_TYPE:
|
||||
if (val != 1 && (flags & COMPARE_DIFFERENT_TU))
|
||||
if (val != 1 && !same_translation_unit_p (t1, t2))
|
||||
val = tagged_types_tu_compatible_p (t1, t2, flags);
|
||||
break;
|
||||
|
||||
|
@ -606,6 +607,34 @@ comp_target_types (tree ttl, tree ttr, int reflexive)
|
|||
|
||||
/* Subroutines of `comptypes'. */
|
||||
|
||||
/* Determine whether two types derive from the same translation unit.
|
||||
If the CONTEXT chain ends in a null, that type's context is still
|
||||
being parsed, so if two types have context chains ending in null,
|
||||
they're in the same translation unit. */
|
||||
static int
|
||||
same_translation_unit_p (tree t1, tree t2)
|
||||
{
|
||||
while (t1 && TREE_CODE (t1) != TRANSLATION_UNIT_DECL)
|
||||
switch (TREE_CODE_CLASS (TREE_CODE (t1)))
|
||||
{
|
||||
case 'd': t1 = DECL_CONTEXT (t1); break;
|
||||
case 't': t1 = TYPE_CONTEXT (t1); break;
|
||||
case 'b': t1 = BLOCK_SUPERCONTEXT (t1); break;
|
||||
default: abort ();
|
||||
}
|
||||
|
||||
while (t2 && TREE_CODE (t2) != TRANSLATION_UNIT_DECL)
|
||||
switch (TREE_CODE_CLASS (TREE_CODE (t2)))
|
||||
{
|
||||
case 'd': t2 = DECL_CONTEXT (t1); break;
|
||||
case 't': t2 = TYPE_CONTEXT (t2); break;
|
||||
case 'b': t2 = BLOCK_SUPERCONTEXT (t2); break;
|
||||
default: abort ();
|
||||
}
|
||||
|
||||
return t1 == t2;
|
||||
}
|
||||
|
||||
/* The C standard says that two structures in different translation
|
||||
units are compatible with each other only if the types of their
|
||||
fields are compatible (among other things). So, consider two copies
|
||||
|
|
Loading…
Reference in New Issue