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/Sema/SemaChecking.cpp b/Sema/SemaChecking.cpp
index 20f0b81..81a18c9 100644
--- a/Sema/SemaChecking.cpp
+++ b/Sema/SemaChecking.cpp
@@ -564,10 +564,12 @@
case Stmt::ConditionalOperatorClass: {
ConditionalOperator *C = cast<ConditionalOperator>(E);
- if (DeclRefExpr* LHS = EvalAddr(C->getLHS()))
- return LHS;
- else
- return EvalAddr(C->getRHS());
+ // Handle the GNU extension for missing LHS.
+ if (Expr *lhsExpr = C->getLHS())
+ if (DeclRefExpr* LHS = EvalAddr(lhsExpr))
+ return LHS;
+
+ return EvalAddr(C->getRHS());
}
// For implicit casts, we need to handle conversions from arrays to
@@ -674,10 +676,12 @@
// non-NULL DeclRefExpr's. If one is non-NULL, we return it.
ConditionalOperator *C = cast<ConditionalOperator>(E);
- if (DeclRefExpr *LHS = EvalVal(C->getLHS()))
- return LHS;
- else
- return EvalVal(C->getRHS());
+ // Handle the GNU extension for missing LHS.
+ if (Expr *lhsExpr = C->getLHS())
+ if (DeclRefExpr *LHS = EvalVal(lhsExpr))
+ return LHS;
+
+ return EvalVal(C->getRHS());
}
// Accesses to members are potential references to data on the stack.