r216224 - Return statements are initialization; don't forget to revert the initializer to
Richard Smith
richard-llvm at metafoo.co.uk
Thu Aug 21 13:51:14 PDT 2014
Author: rsmith
Date: Thu Aug 21 15:51:13 2014
New Revision: 216224
URL: http://llvm.org/viewvc/llvm-project?rev=216224&view=rev
Log:
Return statements are initialization; don't forget to revert the initializer to
its syntactic form before re-analyzing it during template instantiation.
Modified:
cfe/trunk/lib/Sema/TreeTransform.h
cfe/trunk/test/SemaTemplate/instantiate-init.cpp
Modified: cfe/trunk/lib/Sema/TreeTransform.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TreeTransform.h?rev=216224&r1=216223&r2=216224&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/TreeTransform.h (original)
+++ cfe/trunk/lib/Sema/TreeTransform.h Thu Aug 21 15:51:13 2014
@@ -5821,7 +5821,8 @@ TreeTransform<Derived>::TransformBreakSt
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();
Modified: cfe/trunk/test/SemaTemplate/instantiate-init.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/instantiate-init.cpp?rev=216224&r1=216223&r2=216224&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/instantiate-init.cpp (original)
+++ cfe/trunk/test/SemaTemplate/instantiate-init.cpp Thu Aug 21 15:51:13 2014
@@ -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>();
+}
More information about the cfe-commits
mailing list