<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div>On Mar 28, 2013, at 1:27 PM, Alexander Zinenko <<a href="mailto:ftynse@gmail.com">ftynse@gmail.com</a>> wrote:</div><blockquote type="cite"><div dir="ltr"><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></div></div></blockquote><br></div><div>Is there any reasonable way we can tie this to applying an explicit CC attribute instead of putting explicit checks in a ton of places? It's not so much that I'm concerned about the compile-time impact of checking this in a bunch of places (although there is that). It's that there's really no earthly way that the three or four places you've found to insert a check for this are really covering all the cases, and it seems unlikely that you'll reasonably be able to find them all. (e.g., what if a pointer-to-function appears at an arbitrary position within some other type?)</div><div><br></div><div>John.</div><br></body></html>