Implement initialization of a reference (C++ [dcl.init.ref]) as part
of copy initialization. Other pieces of the puzzle:
- Try/Perform-ImplicitConversion now handles implicit conversions
that don't involve references.
- Try/Perform-CopyInitialization uses
CheckSingleAssignmentConstraints for C. PerformCopyInitialization
is now used for all argument passing and returning values from a
function.
- Diagnose errors with declaring references and const values without
an initializer. (Uses a new Action callback, ActOnUninitializedDecl).
We do not yet have implicit conversion sequences for reference
binding, which means that we don't have any overloading support for
reference parameters yet.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58353 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp
index f75758e..e7ccdda 100644
--- a/lib/Sema/SemaStmt.cpp
+++ b/lib/Sema/SemaStmt.cpp
@@ -693,7 +693,7 @@
return new BreakStmt(BreakLoc);
}
-/// ActOnBlockReturnStmt - Utilty routine to figure out block's return type.
+/// ActOnBlockReturnStmt - Utility routine to figure out block's return type.
///
Action::StmtResult
Sema::ActOnBlockReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp) {
@@ -782,10 +782,11 @@
// C99 6.8.6.4p3(136): The return statement is not an assignment. The
// overlap restriction of subclause 6.5.16.1 does not apply to the case of
// function return.
- AssignConvertType ConvTy = CheckSingleAssignmentConstraints(FnRetType,
- RetValExp);
- if (DiagnoseAssignmentResult(ConvTy, ReturnLoc, FnRetType,
- RetValType, RetValExp, "returning"))
+
+ // In C++ the return statement is handled via a copy initialization.
+ // the C version of which boils down to
+ // CheckSingleAssignmentConstraints.
+ if (PerformCopyInitialization(RetValExp, FnRetType, "returning"))
return true;
if (RetValExp) CheckReturnStackAddr(RetValExp, FnRetType, ReturnLoc);