diff options
author | John McCall <rjmccall@apple.com> | 2010-01-19 22:33:45 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2010-01-19 22:33:45 +0000 |
commit | 1d7d8d66eff7ed0f3e957d330930cc9ab8047add (patch) | |
tree | 1ada4a5795c1088b39a9f25b82be4bbe146842c2 /lib/Sema | |
parent | e8c7043f6c11aa8e2420b97046f7dbcb6d7e51ab (diff) |
The type of a compound literal expression is not necessarily the same as the
type which was syntactically written. Fixes PR 6080.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93933 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema')
-rw-r--r-- | lib/Sema/SemaExpr.cpp | 4 | ||||
-rw-r--r-- | lib/Sema/TreeTransform.h | 4 |
2 files changed, 6 insertions, 2 deletions
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index f8f3e05f56..8c740dd1db 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -3707,7 +3707,7 @@ Sema::BuildCompoundLiteralExpr(SourceLocation LParenLoc, TypeSourceInfo *TInfo, Result.release(); - return Owned(new (Context) CompoundLiteralExpr(LParenLoc, TInfo, + return Owned(new (Context) CompoundLiteralExpr(LParenLoc, TInfo, literalType, literalExpr, isFileScope)); } @@ -4718,7 +4718,7 @@ static void ConstructTransparentUnion(ASTContext &C, Expr *&E, // Build a compound literal constructing a value of the transparent // union type from this initializer list. TypeSourceInfo *unionTInfo = C.getTrivialTypeSourceInfo(UnionType); - E = new (C) CompoundLiteralExpr(SourceLocation(), unionTInfo, + E = new (C) CompoundLiteralExpr(SourceLocation(), unionTInfo, UnionType, Initializer, false); } diff --git a/lib/Sema/TreeTransform.h b/lib/Sema/TreeTransform.h index 587c93d1ad..b2102afdfc 100644 --- a/lib/Sema/TreeTransform.h +++ b/lib/Sema/TreeTransform.h @@ -3867,6 +3867,10 @@ TreeTransform<Derived>::TransformCompoundLiteralExpr(CompoundLiteralExpr *E) { Init.get() == E->getInitializer()) return SemaRef.Owned(E->Retain()); + // Note: the expression type doesn't necessarily match the + // type-as-written, but that's okay, because it should always be + // derivable from the initializer. + return getDerived().RebuildCompoundLiteralExpr(E->getLParenLoc(), NewT, /*FIXME:*/E->getInitializer()->getLocEnd(), move(Init)); |