diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-01-14 22:39:08 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-01-14 22:39:08 +0000 |
commit | 945f8d32fd40f4d42b62e4b9216a9cc2fe51b28d (patch) | |
tree | 2ddda4b727bee88c3f8945c194c70009faf19281 /clang/lib/Sema/SemaDecl.cpp | |
parent | 5c118fd2eca2d9e312c8b0361d5e362a4f72a80e (diff) | |
download | bcm5719-llvm-945f8d32fd40f4d42b62e4b9216a9cc2fe51b28d.tar.gz bcm5719-llvm-945f8d32fd40f4d42b62e4b9216a9cc2fe51b28d.zip |
Refactor to call ActOnFinishFullExpr on every full expression. Teach
ActOnFinishFullExpr that some of its checks only apply to discarded-value
expressions. This adds missing checks for unexpanded variadic template
parameter packs to a handful of constructs.
llvm-svn: 172485
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 7dc413e4990..537e70bfbe7 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -6873,9 +6873,6 @@ void Sema::AddInitializerToDecl(Decl *RealDecl, Expr *Init, if (!VDecl->isInvalidDecl() && (DclT != SavT)) VDecl->setType(DclT); - // Check any implicit conversions within the expression. - CheckImplicitConversions(Init, VDecl->getLocation()); - if (!VDecl->isInvalidDecl()) { checkUnsafeAssigns(VDecl->getLocation(), VDecl->getType(), Init); @@ -6898,7 +6895,24 @@ void Sema::AddInitializerToDecl(Decl *RealDecl, Expr *Init, } } - Init = MaybeCreateExprWithCleanups(Init); + // The initialization is usually a full-expression. + // + // FIXME: If this is a braced initialization of an aggregate, it is not + // an expression, and each individual field initializer is a separate + // full-expression. For instance, in: + // + // struct Temp { ~Temp(); }; + // struct S { S(Temp); }; + // struct T { S a, b; } t = { Temp(), Temp() } + // + // we should destroy the first Temp before constructing the second. + ExprResult Result = ActOnFinishFullExpr(Init, VDecl->getLocation()); + if (Result.isInvalid()) { + VDecl->setInvalidDecl(); + return; + } + Init = Result.take(); + // Attach the initializer to the decl. VDecl->setInit(Init); |