<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, May 22, 2014 at 11:06 AM, jahanian <span dir="ltr"><<a href="mailto:fjahanian@apple.com" target="_blank">fjahanian@apple.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div style="word-wrap:break-word"><div class=""><br><div><div>
On May 21, 2014, at 5:19 PM, Richard Smith <<a href="mailto:richard@metafoo.co.uk" target="_blank">richard@metafoo.co.uk</a>> wrote:</div><br><blockquote type="cite"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">
<div><br></div><div>How about this: drop the setInvalidDecl() call. In its place, when we get a type mismatch between two function declarations, if Old is implicit then check whether it used to be a builtin. If so, check the type against the most recent declaration instead.</div>

</div></div></div>
</blockquote><br></div></div><div>Without adding an extra flag to FunctionDecl, I am not sure how I can check that an implicit Old used to be a “builtin”?</div><div>I don’t thing that checking for <span style="font-family:Menlo;font-size:11px;color:rgb(79,129,135)">Builtin</span><span style="font-family:Menlo;font-size:11px">::</span><font color="#31595d" face="Menlo"><span style="font-size:11px">NotBuiltin means this as it is a value of 0. Are you proposing</span></font></div>
<div><font color="#31595d" face="Menlo"><span style="font-size:11px">addition of a new flag? Or a special BID?</span></font></div></div></blockquote><div><br></div><div>The clang::Builtin::Context object seems to retain enough information to work out whether an identifier was ever a builtin. But perhaps this isn't the best approach.</div>
<div><br></div><div>Another problem with our current model is that we build a broken redeclaration chain (the local declaration is marked as being a redeclaration of the implicitly-declared builtin, which it isn't). This leads to other bugs; for instance:</div>
<div><br></div><div>void f() { int memcpy(void); } void g() { memcpy(0,0,0); }<br></div><div><br></div><div>... misses the "implicitly declaring library function" warning.</div><div><br></div><div>If you fix *that* bug, then it should be possible to teach FunctionDecl::getBuiltinID to do the right thing, by checking whether the canonical decl is implicit.</div>
</div></div></div>