implement codegen support for aggregates casted to void.

llvm-svn: 47226
This commit is contained in:
Chris Lattner 2008-02-16 23:55:16 +00:00
parent 231fe4746b
commit df53e20f2d
2 changed files with 18 additions and 5 deletions

View File

@ -508,16 +508,24 @@ Value *ScalarExprEmitter::VisitImplicitCastExpr(const ImplicitCastExpr *E) {
// handle things like function to ptr-to-function decay etc. // handle things like function to ptr-to-function decay etc.
Value *ScalarExprEmitter::EmitCastExpr(const Expr *E, QualType DestTy) { Value *ScalarExprEmitter::EmitCastExpr(const Expr *E, QualType DestTy) {
// Handle cases where the source is an non-complex type. // 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)); Value *Src = Visit(const_cast<Expr*>(E));
// Use EmitScalarConversion to perform the conversion. // Use EmitScalarConversion to perform the conversion.
return EmitScalarConversion(Src, E->getType(), DestTy); 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. // Okay, this is a cast from an aggregate. It must be a cast to void. Just
return EmitComplexToScalarConversion(CGF.EmitComplexExpr(E), E->getType(), // evaluate the result and return.
DestTy); CGF.EmitAggExpr(E, 0, false);
return 0;
} }
Value *ScalarExprEmitter::VisitStmtExpr(const StmtExpr *E) { Value *ScalarExprEmitter::VisitStmtExpr(const StmtExpr *E) {

View File

@ -1,4 +1,4 @@
// RUN: clang %s -emit-llvm // RUN: clang < %s -emit-llvm
int A; int A;
long long B; long long B;
int C; int C;
@ -18,3 +18,8 @@ void foo(char *strbuf) {
int stufflen = 4; int stufflen = 4;
strbuf += stufflen; strbuf += stufflen;
} }
// Aggregate cast to void
union uu { int a;}; void f(union uu p) { (void) p;}