aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaStmt.cpp
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2009-06-19 23:37:08 +0000
committerFariborz Jahanian <fjahanian@apple.com>2009-06-19 23:37:08 +0000
commit7d5c74ecbbd8719436c071f38657bc8e97ee4a24 (patch)
treeef9798a35d3bfb0cf4cfaa7771874c65e29f3dee /lib/Sema/SemaStmt.cpp
parentf8dcb866d344aa9355595e14c429852830b63095 (diff)
Use QualType to represent block's implicit return type as
to not lose its 'const/volatile' qualifier. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73795 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaStmt.cpp')
-rw-r--r--lib/Sema/SemaStmt.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp
index 7797e270f5..914839cbf7 100644
--- a/lib/Sema/SemaStmt.cpp
+++ b/lib/Sema/SemaStmt.cpp
@@ -748,16 +748,23 @@ Action::OwningStmtResult
Sema::ActOnBlockReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp) {
// If this is the first return we've seen in the block, infer the type of
// the block from it.
- if (CurBlock->ReturnType == 0) {
+ if (CurBlock->ReturnType.isNull()) {
if (RetValExp) {
// Don't call UsualUnaryConversions(), since we don't want to do
// integer promotions here.
DefaultFunctionArrayConversion(RetValExp);
- CurBlock->ReturnType = RetValExp->getType().getTypePtr();
+ 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.removeConst();
+ }
} else
- CurBlock->ReturnType = Context.VoidTy.getTypePtr();
+ CurBlock->ReturnType = Context.VoidTy;
}
- QualType FnRetType = QualType(CurBlock->ReturnType, 0);
+ QualType FnRetType = CurBlock->ReturnType;
if (CurBlock->TheDecl->hasAttr<NoReturnAttr>(Context)) {
Diag(ReturnLoc, diag::err_noreturn_block_has_return_expr)