PATCH for Re: foo.cc:15: Internal compiler error.
Mark Mitchell
mark@markmitchell.com
Mon May 25 10:51:00 GMT 1998
>>>>> "Alexandre" == Alexandre Oliva <oliva@dcc.unicamp.br> writes:
Alexandre> Mark Mitchell <mark@markmitchell.com> writes:
>> template <class A*> void f();
>> declares an (anonymous) non-type parameter of type `class A*',
>> and forward-declares `class A'. Would you believe it?
Alexandre> IMO, it shouldn't forward-declare `class A'; this code
Alexandre> should only be accepted if `class A' is declared
Alexandre> already. Although not explicitly stated in section
Alexandre> [temp.param], this requirement is implied in the last
Alexandre> sentence of [dcl.type.elab]/3:
Alexandre> If name lookup does not find a
Alexandre> declaration for the name, the elaborated-type-specifier
Alexandre> is ill-formed unless it is of the simple form class-key
Alexandre> identifier in which case the identifier is declared as
Alexandre> described in _basic.scope.pdecl_.
I think you're misreading this. It's legal, for example, to say:
void foo(class A* ap);
with no prior declaration of `A'. You can't say:
void foo(class A::B* bp);
without a prior declaration of `A::B'; here the elaborated type
specifier does not have the form `class-key identifier'.
The situation with template parameters is analagous, although I agree
that it is not explicitly discussed by the standard. The stuff if
[basic.scope.pdecl] discusses the function parameter case explicitly,
but not the template parameter case.
Alexandre> Perhaps we should take this to comp.std.c++ ?
Perhaps. But, we want to make sure we implement the right thing, so
we should bring it back here afterwards!
--
Mark Mitchell mark@markmitchell.com
Mark Mitchell Consulting http://www.markmitchell.com
More information about the Gcc-bugs
mailing list