[cfe-dev] ParseClassSpecifier: can "unions" inherit?

Doug Gregor doug.gregor at gmail.com
Thu Sep 4 09:58:12 PDT 2008

On Thu, Sep 4, 2008 at 12:55 PM, Ted Kremenek <kremenek at apple.com> wrote:
> On Sep 4, 2008, at 9:45 AM, Doug Gregor wrote:
>> In the C++ grammar, unions can have base classes, but it's
>> semantically incorrect according to [class.union]p1. So, the parser
>> parses it and Sema gives an error (see Sema::ActOnBaseSpecifier).
>>  - Doug
> Okay, that makes sense.  If the Parser is suppose to strictly follow the
> grammar then it makes sense why the error is handled in Sema.

There's a philosophy behind here, too: if we can parse it
unambiguously because it's obvious what the user was trying to do,
it's better to parse it and give an error in Sema rather than fail to
parse it.

  - Doug

More information about the cfe-dev mailing list