diff options
author | Anders Carlsson <andersca@mac.com> | 2008-01-14 06:28:57 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2008-01-14 06:28:57 +0000 |
commit | e4707ff0bb48add651c6a1ad9acfcb22609462d1 (patch) | |
tree | 2fb155dd618eba8c197f8ea982589f265df3484a | |
parent | d9028b7d7d9a63a87608ec3fd870a22b2cc87891 (diff) |
Add codegen upport for implicit casts to aggregate exprs.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@45954 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | CodeGen/CGExprAgg.cpp | 12 | ||||
-rw-r--r-- | test/CodeGen/struct.c | 15 |
2 files changed, 26 insertions, 1 deletions
diff --git a/CodeGen/CGExprAgg.cpp b/CodeGen/CGExprAgg.cpp index 5470e7f9f5..5836262175 100644 --- a/CodeGen/CGExprAgg.cpp +++ b/CodeGen/CGExprAgg.cpp @@ -70,8 +70,8 @@ public: // Operators. // case Expr::UnaryOperatorClass: - // case Expr::ImplicitCastExprClass: // case Expr::CastExprClass: + void VisitImplicitCastExpr(ImplicitCastExpr *E); void VisitCallExpr(const CallExpr *E); void VisitStmtExpr(const StmtExpr *E); void VisitBinaryOperator(const BinaryOperator *BO); @@ -137,6 +137,16 @@ void AggExprEmitter::EmitAggLoadOfLValue(const Expr *E) { // Visitor Methods //===----------------------------------------------------------------------===// +void AggExprEmitter::VisitImplicitCastExpr(ImplicitCastExpr *E) +{ + QualType STy = E->getSubExpr()->getType().getCanonicalType(); + QualType Ty = E->getType().getCanonicalType(); + + assert(STy == Ty && "Implicit cast types must be equal"); + + Visit(E->getSubExpr()); +} + void AggExprEmitter::VisitCallExpr(const CallExpr *E) { RValue RV = CGF.EmitCallExpr(E); diff --git a/test/CodeGen/struct.c b/test/CodeGen/struct.c index a52e538a7f..8f9ecd6080 100644 --- a/test/CodeGen/struct.c +++ b/test/CodeGen/struct.c @@ -112,3 +112,18 @@ struct _w _Bool j,k; } ws; + +/* Implicit casts (due to typedefs) */ +typedef struct _a +{ + int a; +} a; + +void f11() +{ + struct _a a1; + a a2; + + a1 = a2; + a2 = a1; +} |