aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/AST/ExprConstant.cpp9
-rw-r--r--test/Sema/const-eval.c2
2 files changed, 11 insertions, 0 deletions
diff --git a/lib/AST/ExprConstant.cpp b/lib/AST/ExprConstant.cpp
index fe44297438..0fcbdf12f0 100644
--- a/lib/AST/ExprConstant.cpp
+++ b/lib/AST/ExprConstant.cpp
@@ -157,6 +157,7 @@ public:
APValue VisitMemberExpr(MemberExpr *E);
APValue VisitStringLiteral(StringLiteral *E) { return APValue(E, 0); }
APValue VisitArraySubscriptExpr(ArraySubscriptExpr *E);
+ APValue VisitUnaryDeref(UnaryOperator *E);
};
} // end anonymous namespace
@@ -234,6 +235,14 @@ APValue LValueExprEvaluator::VisitArraySubscriptExpr(ArraySubscriptExpr *E)
return Result;
}
+APValue LValueExprEvaluator::VisitUnaryDeref(UnaryOperator *E)
+{
+ APValue Result;
+ if (!EvaluatePointer(E->getSubExpr(), Result, Info))
+ return APValue();
+ return Result;
+}
+
//===----------------------------------------------------------------------===//
// Pointer Evaluation
//===----------------------------------------------------------------------===//
diff --git a/test/Sema/const-eval.c b/test/Sema/const-eval.c
index af785e4bdd..30075d5c77 100644
--- a/test/Sema/const-eval.c
+++ b/test/Sema/const-eval.c
@@ -38,3 +38,5 @@ EVAL_EXPR(18, ((int)((void*)10 + 10)) == 20 ? 1 : -1);
struct s {
int a[(int)-1.0f]; // expected-error {{array size is negative}}
};
+
+EVAL_EXPR(19, ((int)&*(char*)10 == 10 ? 1 : -1));