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 | 5d7aa7fa0ae5154c8ca7fe8851b0cafcf8d61700 (patch) | |
tree | 38f87da151f3ebb955b1ae4bf818aa60ef74f66f /clang/lib/Sema | |
parent | 8d67d2f5f8fcf8eeb269ab33315a848f4acfba06 (diff) | |
download | bcm5719-llvm-5d7aa7fa0ae5154c8ca7fe8851b0cafcf8d61700.tar.gz bcm5719-llvm-5d7aa7fa0ae5154c8ca7fe8851b0cafcf8d61700.zip |
The type of a compound literal expression is not necessarily the same as the
type which was syntactically written. Fixes PR 6080.
llvm-svn: 93933
Diffstat (limited to 'clang/lib/Sema')
-rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 4 | ||||
-rw-r--r-- | clang/lib/Sema/TreeTransform.h | 4 |
2 files changed, 6 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index f8f3e05f56e..8c740dd1dbf 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/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/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h index 587c93d1ad5..b2102afdfc4 100644 --- a/clang/lib/Sema/TreeTransform.h +++ b/clang/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)); |