GCC has an extension where the left hand side of the ? : operator can be omitted. Handle this in a few more places.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@44462 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/AST/Expr.cpp b/AST/Expr.cpp
index 682b4bd..0aee702 100644
--- a/AST/Expr.cpp
+++ b/AST/Expr.cpp
@@ -494,7 +494,8 @@
case ConditionalOperatorClass: {
const ConditionalOperator *Exp = cast<ConditionalOperator>(this);
if (!Exp->getCond()->isConstantExpr(Ctx, Loc) ||
- !Exp->getLHS()->isConstantExpr(Ctx, Loc) ||
+ // Handle the GNU extension for missing LHS.
+ !(Exp->getLHS() && Exp->getLHS()->isConstantExpr(Ctx, Loc)) ||
!Exp->getRHS()->isConstantExpr(Ctx, Loc))
return false;
return true;
@@ -809,10 +810,11 @@
if (Result == 0) std::swap(TrueExp, FalseExp);
// Evaluate the false one first, discard the result.
- if (!FalseExp->isIntegerConstantExpr(Result, Ctx, Loc, false))
+ if (FalseExp && !FalseExp->isIntegerConstantExpr(Result, Ctx, Loc, false))
return false;
// Evalute the true one, capture the result.
- if (!TrueExp->isIntegerConstantExpr(Result, Ctx, Loc, isEvaluated))
+ if (TrueExp &&
+ !TrueExp->isIntegerConstantExpr(Result, Ctx, Loc, isEvaluated))
return false;
break;
}