[cfe-commits] r145774 - in /cfe/trunk: include/clang/AST/Decl.h include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaExpr.cpp lib/Sema/SemaStmt.cpp lib/Sema/TreeTransform.h test/Sema/block-explicit-noreturn-type.c test/Sema/block-return.c test/SemaCXX/instantiate-blocks.cpp
Fariborz Jahanian
fjahanian at apple.com
Sat Dec 3 15:58:26 PST 2011
On Dec 3, 2011, at 10:08 AM, Douglas Gregor wrote:
>
> On Dec 3, 2011, at 9:47 AM, Fariborz Jahanian wrote:
>
>>
>
> More importantly, I think this is the wrong place for this check, because the code isn't performing function or array lvalue conversions before checking the type of the return expression. I suggest making sure that blocks with inferred return types always go into this code:
>
> if (CurBlock->ReturnType.isNull()) {
> if (RetValExp) {
> // Don't call UsualUnaryConversions(), since we don't want to do
> // integer promotions here.
> ExprResult Result = DefaultFunctionArrayLvalueConversion(RetValExp);
> if (Result.isInvalid())
> return StmtError();
> RetValExp = Result.take();
>
> if (!RetValExp->isTypeDependent()) {
> CurBlock->ReturnType = RetValExp->getType();
> if (BlockDeclRefExpr *CDRE = dyn_cast<BlockDeclRefExpr>(RetValExp)) {
> // We have to remove a 'const' added to copied-in variable which was
> // part of the implementation spec. and not the actual qualifier for
> // the variable.
> if (CDRE->isConstQualAdded())
> CurBlock->ReturnType.removeLocalConst(); // FIXME: local???
> }
> } else
> CurBlock->ReturnType = Context.DependentTy;
> } else
> CurBlock->ReturnType = Context.VoidTy;
> }
>
> so they all get the same adjustments before checking against previously-deduced return types.
Yes thanks. In r145782. It improved a couple of diagnostics too.
- Fariborz
>
> - Doug
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20111203/8ab70996/attachment.html>
More information about the cfe-commits
mailing list