diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2008-02-11 01:09:17 +0000 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2008-02-11 01:09:17 +0000 |
commit | f54c4e5fea3ece7df6063f6bf0d63caf1b8d8bf7 (patch) | |
tree | cf123fba5652754eb77c5763d731c066a9696b7a /clang/CodeGen | |
parent | a5b2023810067b83bcb9149a2f282391dd2d7bbe (diff) | |
download | bcm5719-llvm-f54c4e5fea3ece7df6063f6bf0d63caf1b8d8bf7.tar.gz bcm5719-llvm-f54c4e5fea3ece7df6063f6bf0d63caf1b8d8bf7.zip |
A couple of minor fixes to aggregate codegen, to stop asserting on some
edge cases.
llvm-svn: 46944
Diffstat (limited to 'clang/CodeGen')
-rw-r--r-- | clang/CodeGen/CGExprAgg.cpp | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/clang/CodeGen/CGExprAgg.cpp b/clang/CodeGen/CGExprAgg.cpp index 377e90df702..0b12647efd7 100644 --- a/clang/CodeGen/CGExprAgg.cpp +++ b/clang/CodeGen/CGExprAgg.cpp @@ -142,8 +142,10 @@ void AggExprEmitter::VisitImplicitCastExpr(ImplicitCastExpr *E) { QualType STy = E->getSubExpr()->getType().getCanonicalType(); QualType Ty = E->getType().getCanonicalType(); - - assert(STy.getUnqualifiedType() == Ty && "Implicit cast types must be equal"); + + assert(CGF.getContext().typesAreCompatible( + STy.getUnqualifiedType(), Ty.getUnqualifiedType()) + && "Implicit cast types must be compatible"); Visit(E->getSubExpr()); } @@ -184,17 +186,22 @@ void AggExprEmitter::VisitBinaryOperator(const BinaryOperator *E) { } void AggExprEmitter::VisitBinAssign(const BinaryOperator *E) { - assert(E->getLHS()->getType().getCanonicalType() == - E->getRHS()->getType().getCanonicalType() && "Invalid assignment"); + // For an assignment to work, the value on the right has + // to be compatible with the value on the left. + assert(CGF.getContext().typesAreCompatible( + E->getLHS()->getType().getUnqualifiedType(), + E->getRHS()->getType().getUnqualifiedType()) + && "Invalid assignment"); LValue LHS = CGF.EmitLValue(E->getLHS()); // Codegen the RHS so that it stores directly into the LHS. CGF.EmitAggExpr(E->getRHS(), LHS.getAddress(), false /*FIXME: VOLATILE LHS*/); + if (DestPtr == 0) + return; + // If the result of the assignment is used, copy the RHS there also. - if (DestPtr) { - assert(0 && "FIXME: Chained agg assignment not implemented yet"); - } + EmitAggregateCopy(DestPtr, LHS.getAddress(), E->getType()); } void AggExprEmitter::VisitConditionalOperator(const ConditionalOperator *E) { |