[cfe-commits] r65105 - in /cfe/trunk: lib/AST/ExprConstant.cpp test/Sema/const-eval.c
Eli Friedman
eli.friedman at gmail.com
Thu Feb 19 17:57:16 PST 2009
Author: efriedma
Date: Thu Feb 19 19:57:15 2009
New Revision: 65105
URL: http://llvm.org/viewvc/llvm-project?rev=65105&view=rev
Log:
Add support for * (unary dereference) operator to ExprConstant.
Modified:
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/test/Sema/const-eval.c
Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=65105&r1=65104&r2=65105&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Thu Feb 19 19:57:15 2009
@@ -157,6 +157,7 @@
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 @@
return Result;
}
+APValue LValueExprEvaluator::VisitUnaryDeref(UnaryOperator *E)
+{
+ APValue Result;
+ if (!EvaluatePointer(E->getSubExpr(), Result, Info))
+ return APValue();
+ return Result;
+}
+
//===----------------------------------------------------------------------===//
// Pointer Evaluation
//===----------------------------------------------------------------------===//
Modified: cfe/trunk/test/Sema/const-eval.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/const-eval.c?rev=65105&r1=65104&r2=65105&view=diff
==============================================================================
--- cfe/trunk/test/Sema/const-eval.c (original)
+++ cfe/trunk/test/Sema/const-eval.c Thu Feb 19 19:57:15 2009
@@ -38,3 +38,5 @@
struct s {
int a[(int)-1.0f]; // expected-error {{array size is negative}}
};
+
+EVAL_EXPR(19, ((int)&*(char*)10 == 10 ? 1 : -1));
More information about the cfe-commits
mailing list