<div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br><div>We should still be warning on this line, because it could either be declaring d to be a pointer to a function which returns T, or to be a pointer to T initialized by int(p). The place to handle this is probably GetFullTypeForDeclarator in SemaType.cpp. I don't know if you can move all of this checking to there, but if you can, that would be ideal. If not, splitting it up is OK.</div>


<div><br></div></blockquote><div><br></div><div>I moved everything to SemaType.cpp but I have a number of questions:</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div></div><div>Please factor the D.isAmbiguous() && !T->isVoidType() tests into an outer 'if'.</div></blockquote><div><br></div><div>I couldn't do this inside SemaDecl.cpp as the call to D.getTypeObject(0) crashed when I moved it outside the 'if'. Now that it's in SemaType.cpp, it seems to be working even outside the 'if''. Hope this isn't by chance, but tests show no problems.</div>

<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><br></div><div>It would be great to say "as a function declaration" here (but still use the "as a function declarator" in the pointer-to-function case).</div>


<div><br></div></blockquote><div><br></div><div>I added the message text, but I don't know how to differentiate between the two cases. I can see that D.getNumTypeObjects() returns 3 for the 'pointer to function' case, but I don't really understand what this function does. Same goes for D.getNumTypeObjects() == 1 condition.</div>

<div><br></div><div>Checking for FunctionTemplate would be another issue. These warnings don't fire at file scope, I'm guessing that this is because function declarations are much more likely here than global variables? It seems that template declarations are not allowed at block scope so this check is not really needed. I might be wrong.</div>

<div><br></div><div>Function return type used to be obtained from TypeSourceInfo but this parameter is 0 inside GetFullTypeForDeclaration. I saw that the rest of code uses declSpecType for checks about the return type so this is what I used too.</div>

<div><br></div><div>One of the diagnostics used NewFD variable (FunctionDecl *) in the message output, but I used the identifier that was used to do a lookup. I'm guessing that this works the same and only outputs the function name. The test case for this passes with my modification.</div>

<div><br></div><div>ActOnFuctionDeclaration had a 'Scope *' parameter but GetFullTypeForDeclaration doesn't.  I used S.getCurScope() to get the scope, but I'm not sure that this is entirely correct because I saw this in Sema::HandleDeclarator:</div>

<div><br></div></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div class="gmail_quote"><div><div>  // The scope passed in may not be a decl scope.  Zip up the scope tree until</div></div></div><div class="gmail_quote">

<div><div>  // we find one that is.</div></div></div><div class="gmail_quote"><div><div>  while ((S->getFlags() & Scope::DeclScope) == 0 ||</div></div></div><div class="gmail_quote"><div><div>         (S->getFlags() & Scope::TemplateParamScope) != 0)</div>

</div></div><div class="gmail_quote"><div><div>    S = S->getParent();</div></div></div></blockquote><div class="gmail_quote"><div><br></div><div>Comments are breaking the 80 width policy by one character and I have no idea what to do about them. I'm also not sure if we need the 'We don't catch this case earlier, since there is no ambiguity here.' comment.</div>

<div><br></div><div>This was a bit long but since I moved a lot of code it might be easier for you to check every change this way. All test are passing except the one with function pointer that now expects different wording.</div>

</div>