[cfe-commits] [PATCH] Allow typedef with unnecessary "typename" when ms-extensions are enabled.

Will Wilson will at indefiant.com
Sun Dec 9 13:54:27 PST 2012


After looking at the problem a while longer, I've tried an approach
which is simple if not a little nasty in
Parser::TryAnnotateTypeOrScopeToken():

// >>>> clang\lib\Parse\Parser.cpp line 1481 <<<<
    if (!SS.isSet()) {

      // MS compatibility: typename can appear before CV-qualifiers
      if (getLangOpts().MicrosoftExt && isTypeQualifier()) {
        Diag(Tok.getLocation(), diag::warn_expected_qualified_after_typename);
        // Ignore the typename token
        return false;
      }

      if (Tok.is(tok::identifier) || Tok.is(tok::annot_template_id) ||
          Tok.is(tok::annot_decltype)) {
[...]

This works for simple cases, but obviously looses the meaning of the
typename keyword which would impact any occurrences of annotated or
scoped types thereafter. That said, given this is MicrosoftExt
specific and it allows a little more existing code to compile without
too much code churn perhaps it's a reasonable approach? It doesn't
solve all of the MS compat issues in this area but it's a small
improvement after all.

If it's not too disgusting, let me know and I'll knock up a patch with
test cases...

- Will.



More information about the cfe-commits mailing list