diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-06-17 04:59:12 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-06-17 04:59:12 +0000 |
commit | 751ec9be961888f14342fb63b39bf8727f0dee49 (patch) | |
tree | 7de31704ff1c0a255ebdc59021a5f1aba8fb9017 /lib/Sema/SemaExpr.cpp | |
parent | 51d7cdd4bfd11e0eeac55517419d0ebba0abb4cb (diff) |
Implement proper support for generating code for compound literals in
C++, which means:
- binding the temporary as needed in Sema, so that we generate the
appropriate call to the destructor, and
- emitting the compound literal into the appropriate location for
the aggregate, rather than trying to emit it as a temporary and
memcpy() it.
Fixes PR10138 / <rdar://problem/9615901>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133235 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaExpr.cpp')
-rw-r--r-- | lib/Sema/SemaExpr.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index fe11c7e4fe..2d8ed17b70 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -5309,8 +5309,9 @@ Sema::BuildCompoundLiteralExpr(SourceLocation LParenLoc, TypeSourceInfo *TInfo, // In C, compound literals are l-values for some reason. ExprValueKind VK = getLangOptions().CPlusPlus ? VK_RValue : VK_LValue; - return Owned(new (Context) CompoundLiteralExpr(LParenLoc, TInfo, literalType, - VK, literalExpr, isFileScope)); + return MaybeBindToTemporary( + new (Context) CompoundLiteralExpr(LParenLoc, TInfo, literalType, + VK, literalExpr, isFileScope)); } ExprResult |