This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
A pair of more or less obvious --enable-checking fixes
- To: gcc-patches at gcc dot gnu dot org
- Subject: A pair of more or less obvious --enable-checking fixes
- From: Zack Weinberg <zack at wolery dot cumb dot org>
- Date: Wed, 7 Jun 2000 15:43:06 -0700
1) c-decl.c:pushdecl does not handle an ERROR_MARK in the type slots of
the prototype properly. For instance:
void a(void x) {}
This causes --enable-checking failures on noncompile/921116-1.c and
920216-2.c.
2) The transparent_union_flag of TYPE trees is now overloaded to mean
something else for array types. The TYPE_TRANSPARENT_UNION() macro
was changed to check that it's being called on a union type. But
print_node() blindly applies TYPE_TRANSPARENT_UNION to all types,
which means you get an abort if you try to print any type tree from
the debugger.
The appended patch fixes both issues. It survived a bootstrap with
all --enable-checking options active, on i386-linux. There are now no
regressions of --enable-checking versus the normal build, in the C
testsuite. There are regressions in the C++ testsuite; I think these
are all the VOID_TYPE_P() problem Geoff Keating mentioned earlier.
Anyway, they haven't anything to do with my changes.
I'm checking this in as an obvious patch.
zw
* c-decl.c (pushdecl): Do not call COMPLETE_TYPE_P on
error_mark_node.
* print-tree.c (print_node): The transparent_union_flag means
different things for unions and arrays. Do not inspect it
with TYPE_TRANSPARENT_UNION.
===================================================================
Index: c-decl.c
--- c-decl.c 2000/06/06 21:54:52 1.120
+++ c-decl.c 2000/06/07 22:36:00
@@ -2422,8 +2422,12 @@ pushdecl (x)
b->shadowed = tree_cons (name, oldlocal, b->shadowed);
}
- /* Keep count of variables in this level with incomplete type. */
- if (!COMPLETE_TYPE_P (TREE_TYPE (x)))
+ /* Keep count of variables in this level with incomplete type.
+ If the input is erroneous, we can have error_mark in the type
+ slot (e.g. "f(void a, ...)") - that doesn't count as an
+ incomplete type. */
+ if (TREE_TYPE (x) != error_mark_node
+ && !COMPLETE_TYPE_P (TREE_TYPE (x)))
++b->n_incomplete;
}
===================================================================
Index: print-tree.c
--- print-tree.c 2000/05/27 15:21:15 1.31
+++ print-tree.c 2000/06/07 22:36:02
@@ -480,8 +480,17 @@ print_node (file, prefix, node, indent)
fputs (" string-flag", file);
if (TYPE_NEEDS_CONSTRUCTING (node))
fputs (" needs-constructing", file);
- if (TYPE_TRANSPARENT_UNION (node))
- fputs (" transparent-union", file);
+ /* The transparent-union flag is used for different things in
+ different nodes. */
+ if (TYPE_CHECK (node)->type.transparent_union_flag)
+ {
+ if (TREE_CODE (node) == UNION_TYPE)
+ fputs (" transparent-union", file);
+ else if (TREE_CODE (node) == ARRAY_TYPE)
+ fputs (" nonaliased-component", file);
+ else
+ fputs (" tu-flag", file);
+ }
if (TYPE_PACKED (node))
fputs (" packed", file);