Return statements are initialization; don't forget to revert the initializer to

its syntactic form before re-analyzing it during template instantiation.

llvm-svn: 216224
This commit is contained in:
Richard Smith 2014-08-21 20:51:13 +00:00
parent 1961f14cf9
commit 3b717527f4
2 changed files with 11 additions and 1 deletions

View File

@ -5821,7 +5821,8 @@ TreeTransform<Derived>::TransformBreakStmt(BreakStmt *S) {
template<typename Derived>
StmtResult
TreeTransform<Derived>::TransformReturnStmt(ReturnStmt *S) {
ExprResult Result = getDerived().TransformExpr(S->getRetValue());
ExprResult Result = getDerived().TransformInitializer(S->getRetValue(),
/*NotCopyInit*/false);
if (Result.isInvalid())
return StmtError();

View File

@ -133,3 +133,12 @@ namespace PR16903 {
fun(in);
}
}
namespace ReturnStmtIsInitialization {
struct X {
X() {}
X(const X &) = delete;
};
template<typename T> X f() { return {}; }
auto &&x = f<void>();
}