Index: lib/Sema/SemaChecking.cpp =================================================================== --- lib/Sema/SemaChecking.cpp +++ lib/Sema/SemaChecking.cpp @@ -11658,30 +11658,38 @@ notePostUse(O, E); } - void VisitBinComma(BinaryOperator *BO) { - // C++11 [expr.comma]p1: - // Every value computation and side effect associated with the left - // expression is sequenced before every value computation and side - // effect associated with the right expression. - SequenceTree::Seq LHS = Tree.allocate(Region); - SequenceTree::Seq RHS = Tree.allocate(Region); + void VisitSequencedLhsRhsExpressions(Expr *LHS, Expr *RHS) { + SequenceTree::Seq LHSRegion = Tree.allocate(Region); + SequenceTree::Seq RHSRegion = Tree.allocate(Region); SequenceTree::Seq OldRegion = Region; { SequencedSubexpression SeqLHS(*this); - Region = LHS; - Visit(BO->getLHS()); + Region = LHSRegion; + Visit(LHS); } - Region = RHS; - Visit(BO->getRHS()); + Region = RHSRegion; + Visit(RHS); Region = OldRegion; - // Forget that LHS and RHS are sequenced. They are both unsequenced - // with respect to other stuff. - Tree.merge(LHS); - Tree.merge(RHS); + Tree.merge(LHSRegion); + Tree.merge(RHSRegion); + } + + void VisitArraySubscriptExpr(ArraySubscriptExpr *ASE) { + // The expression E1[E2] is identical (by definition) to *((E1)+(E2)). The + // expression E1 is sequenced before the expression E2. + VisitSequencedLhsRhsExpressions(ASE->getLHS(), ASE->getLHS()); + } + + void VisitBinComma(BinaryOperator *BO) { + // C++11 [expr.comma]p1: + // Every value computation and side effect associated with the left + // expression is sequenced before every value computation and side + // effect associated with the right expression. + VisitSequencedLhsRhsExpressions(BO->getLHS(), BO->getLHS()); } void VisitBinAssign(BinaryOperator *BO) {