diff options
| author | Douglas Gregor <dgregor@apple.com> | 2010-09-08 21:40:08 +0000 |
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2010-09-08 21:40:08 +0000 |
| commit | 8ec5173f9a7d2ce38162bcf2acc5ea1ccb7c9295 (patch) | |
| tree | 1a10f9d65bbda53f0ba94041cbd5faf72d4cf8f8 /clang/lib/Sema/SemaExprCXX.cpp | |
| parent | db45278cbdd46c841aab8d15e98ddd426ddcf5d8 (diff) | |
| download | bcm5719-llvm-8ec5173f9a7d2ce38162bcf2acc5ea1ccb7c9295.tar.gz bcm5719-llvm-8ec5173f9a7d2ce38162bcf2acc5ea1ccb7c9295.zip | |
Use the new-initialization code for initializing scalars with a
function-style cast. Previously, we had a (redundant, incorrect)
semantic-checking path for non-class types, which allowed
value-initialization of a reference type and then crashed.
llvm-svn: 113415
Diffstat (limited to 'clang/lib/Sema/SemaExprCXX.cpp')
| -rw-r--r-- | clang/lib/Sema/SemaExprCXX.cpp | 46 |
1 files changed, 11 insertions, 35 deletions
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp index c3e2c503122..5dc2713d64d 100644 --- a/clang/lib/Sema/SemaExprCXX.cpp +++ b/clang/lib/Sema/SemaExprCXX.cpp @@ -615,41 +615,17 @@ Sema::BuildCXXTypeConstructExpr(TypeSourceInfo *TInfo, RParenLoc)); } - if (Ty->isRecordType()) { - InitializedEntity Entity = InitializedEntity::InitializeTemporary(TInfo); - InitializationKind Kind - = NumExprs ? InitializationKind::CreateDirect(TyBeginLoc, - LParenLoc, RParenLoc) - : InitializationKind::CreateValue(TyBeginLoc, - LParenLoc, RParenLoc); - InitializationSequence InitSeq(*this, Entity, Kind, Exprs, NumExprs); - ExprResult Result = InitSeq.Perform(*this, Entity, Kind, move(exprs)); - - // FIXME: Improve AST representation? - return move(Result); - } - - // C++ [expr.type.conv]p1: - // If the expression list specifies more than a single value, the type shall - // be a class with a suitably declared constructor. - // - if (NumExprs > 1) - return ExprError(Diag(PP.getLocForEndOfToken(Exprs[0]->getLocEnd()), - diag::err_builtin_func_cast_more_than_one_arg) - << FullRange); - - assert(NumExprs == 0 && "Expected 0 expressions"); - // FIXME: Why doesn't this go through the new-initialization code? - - // C++ [expr.type.conv]p2: - // The expression T(), where T is a simple-type-specifier for a non-array - // complete object type or the (possibly cv-qualified) void type, creates an - // rvalue of the specified type, which is value-initialized. - // - exprs.release(); - return Owned(new (Context) CXXScalarValueInitExpr( - TInfo->getType().getNonLValueExprType(Context), - TInfo, RParenLoc)); + InitializedEntity Entity = InitializedEntity::InitializeTemporary(TInfo); + InitializationKind Kind + = NumExprs ? InitializationKind::CreateDirect(TyBeginLoc, + LParenLoc, RParenLoc) + : InitializationKind::CreateValue(TyBeginLoc, + LParenLoc, RParenLoc); + InitializationSequence InitSeq(*this, Entity, Kind, Exprs, NumExprs); + ExprResult Result = InitSeq.Perform(*this, Entity, Kind, move(exprs)); + + // FIXME: Improve AST representation? + return move(Result); } |

