[cfe-commits] r60359 - in /cfe/trunk: include/clang/Basic/DiagnosticKinds.def lib/Parse/ParseDeclCXX.cpp test/SemaCXX/ms-exception-spec.cpp

Doug Gregor doug.gregor at gmail.com
Mon Dec 1 13:33:34 PST 2008

On Mon, Dec 1, 2008 at 1:21 PM, Chris Lattner <clattner at apple.com> wrote:
> On Dec 1, 2008, at 10:00 AM, Douglas Gregor wrote:
>> +  // Parse throw(...), a Microsoft extension that means "this function
>> +  // can throw anything".
>> +  if (Tok.is(tok::ellipsis)) {
>> +    SourceLocation EllipsisLoc = ConsumeToken();
>> +    if (!getLang().Microsoft)
>> +      Diag(EllipsisLoc, diag::ext_ellipsis_exception_spec);
>> +    SourceLocation RParenLoc = MatchRHSPunctuation(tok::r_paren,
>> LParenLoc);
> I think that this should unconditionally emit the extension warning (and let
> the diagnostics machinery filter it if appropriate).  When -fms-extensions
> isn't specified, should clang just completely reject this?

The problem with completely rejecting it is that we don't give good
error messages. We want to say: this is a Microsoft extension that we
know about, but you'll have to turn on Microsoft extensions so that we
won't complain. If we just fail to parse it, we'll get some generic
message about expecting a type-id.

I ran into the same issue with Microsoft's "asm" syntax: I got some
basic parse error (e.g., "expected '('") in the Windows headers. After
hunting for documentation of Microsoft's asm syntax and finding the
appropriate place in Clang to add it... I realized that I just needed
to add -fms-extensions to make everything work.

Perhaps we should make the error message a WARNING that is emitted
only if -fms-extensions is not specified (?). Either that or we want
subcategories of EXTENSION that match certain classes of
extensions---GNU, Microsoft, Blocks, whatever---and can be
enabled/disabled separately.

  - Doug

More information about the cfe-commits mailing list