summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-02-16 23:55:16 +0000
committerChris Lattner <sabre@nondot.org>2008-02-16 23:55:16 +0000
commitdf53e20f2dee4b3b89abe0a9f30ff8758de62ea4 (patch)
treed98820f978e45e4ac399d2be18191b70b7743e9b
parent231fe4746b7931dda9e739bea6f9b8fa1d7d8e4e (diff)
downloadbcm5719-llvm-df53e20f2dee4b3b89abe0a9f30ff8758de62ea4.tar.gz
bcm5719-llvm-df53e20f2dee4b3b89abe0a9f30ff8758de62ea4.zip
implement codegen support for aggregates casted to void.
llvm-svn: 47226
-rw-r--r--clang/CodeGen/CGExprScalar.cpp16
-rw-r--r--clang/test/CodeGen/compound.c7
2 files changed, 18 insertions, 5 deletions
diff --git a/clang/CodeGen/CGExprScalar.cpp b/clang/CodeGen/CGExprScalar.cpp
index 6db7beed0bd..2c7763db8f2 100644
--- a/clang/CodeGen/CGExprScalar.cpp
+++ b/clang/CodeGen/CGExprScalar.cpp
@@ -508,16 +508,24 @@ Value *ScalarExprEmitter::VisitImplicitCastExpr(const ImplicitCastExpr *E) {
// handle things like function to ptr-to-function decay etc.
Value *ScalarExprEmitter::EmitCastExpr(const Expr *E, QualType DestTy) {
// Handle cases where the source is an non-complex type.
- if (!E->getType()->isComplexType()) {
+
+ if (!CGF.hasAggregateLLVMType(E->getType())) {
Value *Src = Visit(const_cast<Expr*>(E));
// Use EmitScalarConversion to perform the conversion.
return EmitScalarConversion(Src, E->getType(), DestTy);
}
+
+ if (E->getType()->isComplexType()) {
+ // Handle cases where the source is a complex type.
+ return EmitComplexToScalarConversion(CGF.EmitComplexExpr(E), E->getType(),
+ DestTy);
+ }
- // Handle cases where the source is a complex type.
- return EmitComplexToScalarConversion(CGF.EmitComplexExpr(E), E->getType(),
- DestTy);
+ // Okay, this is a cast from an aggregate. It must be a cast to void. Just
+ // evaluate the result and return.
+ CGF.EmitAggExpr(E, 0, false);
+ return 0;
}
Value *ScalarExprEmitter::VisitStmtExpr(const StmtExpr *E) {
diff --git a/clang/test/CodeGen/compound.c b/clang/test/CodeGen/compound.c
index 09095656316..c8afceef760 100644
--- a/clang/test/CodeGen/compound.c
+++ b/clang/test/CodeGen/compound.c
@@ -1,4 +1,4 @@
-// RUN: clang %s -emit-llvm
+// RUN: clang < %s -emit-llvm
int A;
long long B;
int C;
@@ -18,3 +18,8 @@ void foo(char *strbuf) {
int stufflen = 4;
strbuf += stufflen;
}
+
+
+// Aggregate cast to void
+union uu { int a;}; void f(union uu p) { (void) p;}
+
OpenPOWER on IntegriCloud