<div dir="ltr">Hi All,
<div><br></div><div style>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.</div>
<div style><br></div><div style>A simplified example is:</div><div style><br></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div style><div style>template <class T></div></div><div style><div style>
size_t GetSize() {</div></div><div style><div style><span class="" style="white-space:pre">   </span>return sizeof(T::SubType);<span class="" style="white-space:pre">                </span>// Should have typename keyword</div></div><div style>
<div style>}</div></div><div style><div style><br></div></div><div style><div style>struct TestStruct {</div></div><div style><div style><span class="" style="white-space:pre">  </span>typedef int SubType;</div></div><div style>
<div style>};</div></div><div style><div style><br></div></div><div style><div style>void test_typename_missing_msext() {</div></div><div style><div style><span class="" style="white-space:pre">        </span>GetSize<TestStruct>();</div>
</div><div style><div style>}</div></div></blockquote><div style><br></div><div style>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.</div>
<div style><br></div><div style>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.</div>
<div style><br></div><div style>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?</div>
<div style><br></div><div style>- Will.</div><div style><br></div></div>