]> granicus.if.org Git - clang/commitdiff
implement codegen support for aggregates casted to void.
authorChris Lattner <sabre@nondot.org>
Sat, 16 Feb 2008 23:55:16 +0000 (23:55 +0000)
committerChris Lattner <sabre@nondot.org>
Sat, 16 Feb 2008 23:55:16 +0000 (23:55 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@47226 91177308-0d34-0410-b5e6-96231b3b80d8

CodeGen/CGExprScalar.cpp
test/CodeGen/compound.c

index 6db7beed0bd0ce089e1c227dbbc0d63ed6bb0a98..2c7763db8f20d31f3d4f229e43cb5a223ee2a86d 100644 (file)
@@ -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) {
index 09095656316293a4114f68279374eea844a4c67d..c8afceef7600e4bf0e12eb6d2e4cf1eb054f7f3f 100644 (file)
@@ -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;}
+