This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [C++ PATCH] [PR2204] Check for parameters of abstract types - Take 3
Mark Mitchell wrote:
> Curiously, EDG diagnoses the example I gave, but not:
>
> struct S;
>
> extern S s;
>
> struct S { virtual void g() = 0; };
I would call this a bug in EDG.
> Anyhow, why not just keep a list of all VAR_DECLs and FUNCTION_DECLs
> that have a parameter of an incomplete type, attached to that
> incomplete type? Then, when a type is completed, if it is abstract, run down
the
> list issuing error messages. After the type is complete, clear the
> list.
This is basically what I am doing in my patch. Instead of using a list
attacched to each type, I'm reusing the existing global incomplete_vars list,
which keeps declaration of incomplete types, so that we can layout stuff when
the types are completed. It was something that was already in place, I just
added my own decls to them, and added the check for abstractness. Replacing the
list with a hash table is just an optimization which could be done as a follow
up patch I believe.
But there is a problem in reusing existing decls: we never construct a
PARM_DECL with array type, because it gets decayed to pointer before we
construct the declaration. My patch was coping with this by constructing a
"fake" PARM_DECL with array type to be inserted into the list (or attacched to
the type [or hash table], using your suggestion). Since this happens to be too
memory hungry, I was going to change the list into couples of [IDENTIFIER_NODE,
TYPE].
Giovanni Bajo