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

Will Wilson will at indefiant.com
Sun Dec 9 13:01:12 PST 2012


Hi All,

I've uncovered an edge case not covered by the patch I submitted back
in May. The patch in question is the MS compatibility fix kindly
submitted by Richard: r156786. This following example demonstrates the
issue:

template <typename T>
class Foo {
  typedef typename T* Ptr;              // OK
  typedef const typename T* Ptr;     // OK
  typedef typename const T* CPtr;   // Error: But acceptable on VC++
};

The output is this, followed by a failure to resolve CPtr in any later usage:

  warning: expected a qualified name after 'typename'
  warning: expected member name or ';' after declaration specifiers
          typedef typename const T* CPtr;

Obviously, this is ugly C++ but the trouble is I'm running into it on
quite a few codebases compiled against VC++. Manually fixing the
problem is, I'm afraid, not always an option. So I was wondering if
anyone (Richard?) might know a safe approach to deal with unexpected
CV-qualifiers appearing in this case? Providing a handler for this
case would also reduce the cascading errors caused by the undefined
typedef being used later in the TU so there is a slight benefit to
fixing it for the general case.

I'm more than happy to pull the patch together, I'm just a little
unsure of the best approach. Any ideas very gladly welcomed.

Many thanks!
Will Wilson.



More information about the cfe-commits mailing list