[cfe-dev] [ms-mode] Delayed parsing for a UnaryExprOrTypeTraitExpr?
Will Wilson
will at indefiant.com
Mon Jun 17 01:36:15 PDT 2013
Hi All,
I've been attempting to find a clean way of dealing with an issue parsing
the core MS ATL headers in clang. The issue is a missing typename keyword
in a sizeof expression containing a dependent name in the header atlstr.h.
Annoyingly, this is the last error I'm encountering in the core MS headers.
A simplified example is:
template <class T>
size_t GetSize() {
return sizeof(T::SubType); // Should have typename keyword
}
struct TestStruct {
typedef int SubType;
};
void test_typename_missing_msext() {
GetSize<TestStruct>();
}
This passes in MSVC as it leaves almost all template evaluation
until instantiation by which time it can deduce if T::SubType refers to a
typename or a static member.
Clang does the right thing and relies on the typename keyword to decide
before institution whether the dependent expression refers to a type or a
non-type member. Of note, clang already supports (with warnings) parsing
dependent names missing the typename keyword - but only in locations where
only a type is permitted (as implemented by Francois in r129425). The
problem is dealing with a sizeof expression where the ambiguity cannot be
resolved until instantiation.
So, in short are there any safe approaches I could take with this (with a
view to patching clang)? From my perspective it looks like there needs to
be a third "delayed evaluation" state for UnaryExprOrTypeTraitExpr in order
to support MicrosoftMode correctly. Or even a new
DelayedUnaryExprOrTypeTraitExpr for MicrosoftMode. Does this sound
reasonable or is there a better approach?
- Will.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130617/af0c198a/attachment.html>
More information about the cfe-dev
mailing list