<div dir="ltr"><div style>Hi John,</div><div style><br></div><div style>Thanks for review!</div><br><div class="gmail_extra"><div class="gmail_quote">On 28 March 2013 20:07, John McCall <span dir="ltr"><<a href="mailto:rjmccall@apple.com" target="_blank">rjmccall@apple.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><div><div class="h5"><div>On Mar 28, 2013, at 10:57 AM, Alexander Zinenko <<a href="mailto:ftynse@gmail.com" target="_blank">ftynse@gmail.com</a>> wrote:</div>

</div></div><blockquote type="cite"><div><div class="h5"><div class="gmail_extra"><div class="gmail_quote">On 23 March 2013 01:22, Alexander Zinenko <span dir="ltr"><<a href="mailto:ftynse@gmail.com" target="_blank">ftynse@gmail.com</a>></span> wrote:<br>



<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Hi John, João!</div><div><br></div><div>This patch adds a diagnostic if the following declarations have illegal calling conventions:</div>



<div>* pointer to function, reference to function, pointer to member function variable (or function attribute) declaration;</div>
<div>* function declaration;</div><div>* typedef declaration.</div><div><br></div><div>It was proposed in PR13457 discussion (<a href="http://llvm.org/bugs/show_bug.cgi?id=13457#c22" target="_blank">http://llvm.org/bugs/show_bug.cgi?id=13457#c22</a>).</div>




<div><br></div>We already have such error for variadic functions declared with CC_X86Fastcall that is emitted from SemaType.  But microsoft ABI has different allowed CCs depending on whether it is a member function and it can't be determined given FunctionType only (AFAIK, standard doesn't differentiate between free function and member function types).  So this checking has to be done on declarations.<div>




<br></div><div>With this patch, allowed calling conventions are ABI-specific. Therefore if we teach affected ABIs to disallow fastcall on variadic functions, we can remove the previous diagnostic.</div><div><br>
</div><div>Please review!</div><div><br></div><div>--</div><div>Alex</div></div>
</blockquote></div><br></div>
</div></div><span><callconv.patch></span></blockquote></div><br><div>I would only pass a flag distinguishing non-static member functions vs. everything else.</div></div></blockquote><div><br></div><div style>It makes perfect sense in ABI part, fixed.  </div>

<div style>But I left separate flags in the function that emits diagnostic since it allows to make it more precise.  Namely to distinguish between __thiscall used on non-member function and on static member function.  It is difficult to do otherwise while keeping the single diagnostic message because we would have to know the reason why check failed rather than just passed-or-not flag.</div>

<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><br></div><div><div>+  if (T->isFunctionProtoType())</div><div>+    ProtoType = T->getAs<FunctionProtoType>();</div>

<div>+  else if (T->isFunctionPointerType())</div><div>+    ProtoType = T->getPointeeType()->getAs<FunctionProtoType>();</div><div>+  else if (T->isReferenceType()) {</div><div>+    QualType RefType = T->getAs<ReferenceType>()->getPointeeType();</div>

<div>+    ProtoType = RefType->getAs<FunctionProtoType>();</div><div>+  } else if (T->isMemberFunctionPointerType()) {</div><div>+    QualType PointerType = T->getAs<MemberPointerType>()->getPointeeType();</div>

</div><div><br></div><div>Test the result of getAs<>, please.</div></div></blockquote><div style>Done.</div><div style><br></div><div style>--</div><div style>Alex</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div style="word-wrap:break-word"><span class="HOEnZb"><font color="#888888"><div><br></div><div>John.</div></font></span></div></blockquote></div><br></div></div>