<div dir="ltr"><div dir="ltr">On Fri, 21 Aug 2020 at 13:29, Manu agarwal via cfe-users <<a href="mailto:cfe-users@lists.llvm.org">cfe-users@lists.llvm.org</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div dir="ltr">
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Hello,</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
In the below code the compiler throws "undeclared identifier" when the commented line is uncommented. Whereas the line just before compiles fine.</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Regards,</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Manu</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<div><br>
</div>
<div>typedef bool (* DummyFunc) ();</div>
<div><br>
</div>
<div><br>
</div>
<div>bool ExecDummy (DummyFunc fptr) {</div>
<div><br>
</div>
<div> if (fptr)</div>
<div> return fptr ();</div>
<div><br>
</div>
<div> return false;</div>
<div>}</div>
<div><br>
</div>
<div>constexpr unsigned int IsMyAppClient = 0;</div>
<div><br>
</div>
<div>constexpr bool CheckForTypeClient (unsigned int pAppType)</div>
<div>{</div>
<div> return ((pAppType & IsMyAppClient) != 0);</div>
<div>}</div>
<div><br>
</div>
<div><br>
</div>
<div>class MyAppTemplate</div>
<div>{</div>
<div>public:</div>
<div> template <unsigned int T></div>
<div> static bool MyAppInit ();</div>
<div>};</div>
<div><br>
</div>
<div>template <unsigned int T></div>
<div>bool</div>
<div>MyAppTemplate::MyAppInit ()</div>
<div>{</div>
<div> if constexpr (CheckForTypeClient(T)) {</div>
<div><br>
</div>
<div><b> return ClientMain (); // no error</b></div>
<div><b> //return ExecDummy(ClientMain); // error: use of undeclared identifier 'ClientMain'</b></div>
<div> }</div></div></div></blockquote><div><br></div><div>This code is invalid, as David Blaikie explains. However, in MSVC-compatible mode (under -fms-compatibility, which is enabled by default for some Windows-targeting modes), Clang attempts to to accept certain invalid code that MSVC has historically accepted, including this case, where we allow the call to ClientMain() to find declarations of a ClientMain function that appear after the template definition. That recovery from invalid code is only done for certain syntactic patterns, such as unqualified function calls -- so it applies to ClientMain() but not to (ClientMain).</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<div><br>
</div>
<div> return false;</div>
<div>}</div>
<div><br>
</div>
<div>int __cdecl</div>
<div>main (int pArgc, char* pArgv[])</div>
<div>{</div>
<div> constexpr int TVal = 3;</div>
<div><br>
</div>
<div> MyAppTemplate::MyAppInit<TVal> ();</div>
<div><br>
</div>
<div> return 0;</div>
<div>}</div>
<br>
<br>
</div>
</div>
_______________________________________________<br>
cfe-users mailing list<br>
<a href="mailto:cfe-users@lists.llvm.org" target="_blank">cfe-users@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users</a><br>
</blockquote></div></div>