This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] Fix PR c++/29022


Lee Millward wrote:

cp/
2006-10-18  Lee Millward  <lee.millward@codesourcery.com>

       PR c++/29022
       * parser.c (cp_parser_base_clause): If any of the
       base clauses are invalid, discard all of them.

testsuite/
2006-10-18  Lee Millward  <lee.millward@codesourcery.com>

       PR c++/29022
       * g++.dg/inherit/virtual2.C: New test.

I don't think this is the right fix. In particular, I would expect this variant:


struct A
{
  operator int();
};

struct B : virtual A;

int foo(B &b)
{
  return b;
}

to fail even with your change. I think the problem is that we're remembering that B inherits from A, even when we don't have a definition of B. We shouldn't do that; if B isn't actually complete, then we should just forget all of its base classes. I would suggest moving the xref_basetypes call out of cp_parser_class_head into cp_parser_class_specifier, and calling it only if we find the open curly brace for the class. At that point, we're committed to completing the class, so we would avoid the inconsistent incomplete-but-has-bases situation we get at present.

Would you mind trying that approach?

Thanks,

--
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]