diff options
author | Anders Carlsson <andersca@mac.com> | 2008-11-24 04:41:22 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2008-11-24 04:41:22 +0000 |
commit | 35873c49adad211ff466e34342a52665742794f5 (patch) | |
tree | 4111efbb74897c78a697afb1deaa2efd9d871d23 /lib/AST/ExprConstant.cpp | |
parent | 4bbc0e05a714d4ee4918a92a4a7049dd6ef33ad0 (diff) |
The address of a variable is only constant if the variable has global storage.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59939 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/ExprConstant.cpp')
-rw-r--r-- | lib/AST/ExprConstant.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/AST/ExprConstant.cpp b/lib/AST/ExprConstant.cpp index 7b927f4628..6cdbc80afa 100644 --- a/lib/AST/ExprConstant.cpp +++ b/lib/AST/ExprConstant.cpp @@ -121,7 +121,7 @@ public: } APValue VisitParenExpr(ParenExpr *E) { return Visit(E->getSubExpr()); } - APValue VisitDeclRefExpr(DeclRefExpr *E) { return APValue(E, 0); } + APValue VisitDeclRefExpr(DeclRefExpr *E); APValue VisitPredefinedExpr(PredefinedExpr *E) { return APValue(E, 0); } APValue VisitCompoundLiteralExpr(CompoundLiteralExpr *E); APValue VisitMemberExpr(MemberExpr *E); @@ -135,6 +135,14 @@ static bool EvaluateLValue(const Expr* E, APValue& Result, EvalInfo &Info) { return Result.isLValue(); } +APValue LValueExprEvaluator::VisitDeclRefExpr(DeclRefExpr *E) +{ + if (!E->hasGlobalStorage()) + return APValue(); + + return APValue(E, 0); +} + APValue LValueExprEvaluator::VisitCompoundLiteralExpr(CompoundLiteralExpr *E) { if (E->isFileScope()) return APValue(E, 0); |