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 | a42ee44aab44a0c2094c035f3064a71ca6b2e67b (patch) | |
| tree | 8ee545198a0b77e29e2801d11fb4c6791fc20e26 /clang/lib | |
| parent | 4c76e935074a2aef01e3560f5acc3c55d4f017ae (diff) | |
| download | bcm5719-llvm-a42ee44aab44a0c2094c035f3064a71ca6b2e67b.tar.gz bcm5719-llvm-a42ee44aab44a0c2094c035f3064a71ca6b2e67b.zip | |
The address of a variable is only constant if the variable has global storage.
llvm-svn: 59939
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/AST/ExprConstant.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp index 7b927f46288..6cdbc80afa7 100644 --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/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); |

