diff options
| author | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-09-23 02:20:00 +0000 |
|---|---|---|
| committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-09-23 02:20:00 +0000 |
| commit | 90061908f669864e95715edefa97ab3419bbdb13 (patch) | |
| tree | b2ddb21f8e4fad3701c43d44b75c2c86bc6cd734 /clang/lib | |
| parent | 51617c3d2c12641f2fca53e39b597af0588be82c (diff) | |
| download | bcm5719-llvm-90061908f669864e95715edefa97ab3419bbdb13.tar.gz bcm5719-llvm-90061908f669864e95715edefa97ab3419bbdb13.zip | |
PR16529: Don't forget to add the CXXFunctionalCastExpr type sugar to an
InitListExpr for a C++11-style T{...} construction, if initialization
registered a destructor for it.
llvm-svn: 191182
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/Sema/SemaExprCXX.cpp | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp index f0417f72495..e6dd5fb1af4 100644 --- a/clang/lib/Sema/SemaExprCXX.cpp +++ b/clang/lib/Sema/SemaExprCXX.cpp @@ -903,18 +903,21 @@ Sema::BuildCXXTypeConstructExpr(TypeSourceInfo *TInfo, InitializationSequence InitSeq(*this, Entity, Kind, Exprs); ExprResult Result = InitSeq.Perform(*this, Entity, Kind, Exprs); - if (!Result.isInvalid() && ListInitialization && - isa<InitListExpr>(Result.get())) { + if (Result.isInvalid() || !ListInitialization) + return Result; + + Expr *Inner = Result.get(); + if (CXXBindTemporaryExpr *BTE = dyn_cast_or_null<CXXBindTemporaryExpr>(Inner)) + Inner = BTE->getSubExpr(); + if (isa<InitListExpr>(Inner)) { // If the list-initialization doesn't involve a constructor call, we'll get // the initializer-list (with corrected type) back, but that's not what we // want, since it will be treated as an initializer list in further // processing. Explicitly insert a cast here. - InitListExpr *List = cast<InitListExpr>(Result.take()); - Result = Owned(CXXFunctionalCastExpr::Create(Context, List->getType(), - Expr::getValueKindForType(TInfo->getType()), - TInfo, CK_NoOp, List, - /*Path=*/0, - LParenLoc, RParenLoc)); + QualType ResultType = Result.get()->getType(); + Result = Owned(CXXFunctionalCastExpr::Create( + Context, ResultType, Expr::getValueKindForType(TInfo->getType()), TInfo, + CK_NoOp, Result.take(), /*Path=*/ 0, LParenLoc, RParenLoc)); } // FIXME: Improve AST representation? |

