This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: [C++ PATCH]: size_zero_node
Nathan --
This patch looks pretty good. It looks like I slightly misguessed
what that code in cp/typeck.c was for; I thought it was for handling
partial instantiations (which got a non-sizetype integer zero node as
their size as a marker that they were partial instantiations.) But,
now I see what's going on.
First, I think we need an better abstraction here. Let's make a
COMPLETE_TYPE_P macro, where we can hide whatever complexity is
required. There are all kinds of places in the C++ front-end where it
says `TYPE_SIZE (t) != NULL_TREE' and that's not nearly as intuitive
as saying `COMPLETE_TYPE_P'.
Also, why does `void' need a size at all? Does this have to do with
making the GCC extension:
void *p;
p++;
work? Otherwise, size `void' is an incomplete type, it would seem
that we could simply not set its TYPE_SIZE; no other incomplete types
have a TYPE_SIZE. Perhaps this is set to simplify checking whether
something like:
void f() {}
is legal; here, the return type must be a complete type, or void, even
though void is incomplete. Perhaps by setting TYPE_SIZE for void, we
can get away with just checking TYPE_SIZE. But, then, we have to
specifically check for `void' on:
void v;
rather than just checking that the TYPE_SIZE is non-NULL.
I suggest:
o Don't set TYPE_SIZE for `void'.
o Define COMPLETE_TYPE_P as macro which checks for non-NULL
TYPE_SIZE.
What do people think of this plan?
--
Mark Mitchell mark@codesourcery.com
CodeSourcery, LLC http://www.codesourcery.com