[patch] Fix PR c++/28347

Mark Mitchell mark@codesourcery.com
Wed Aug 2 23:00:00 GMT 2006


Lee Millward wrote:
> There's a comment in start_decl which reads:
> 
> Is it valid for this decl to have an initializer at all?
> If not, set INITIALIZED to zero, which will indirectly
> tell `cp_finish_decl' to ignore the initializer once it is parsed.

Yes, that comment does seem to be obsolete.

> libstdc++ so I abandoned that approach. The fix in the patch I've
> attached is to discard the decl once a diagnostic is issued about an
> invalid initialiser and to return error_mark_node at that point rather
> than continue.

I agree, that makes sense.  In particular, if the user wrote:

  typedef int i = 0;

it's not at all clear that they meant to type "typedef int i;" -- they
might equally well have meant "static int i = 0;", for example.  So, for
error-recovery purposes, just discarding the typedef is probably reasonable.

The patch is OK.

Thanks,

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



More information about the Gcc-patches mailing list