aboutsummaryrefslogtreecommitdiff
path: root/lib/AST/ExprConstant.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-11-01 20:32:48 +0000
committerDouglas Gregor <dgregor@apple.com>2009-11-01 20:32:48 +0000
commitcf3293eaeb3853d12cff47e648bbe835004e929f (patch)
tree14b48e79cfb981e7df5e1bc23622096f478f2c3d /lib/AST/ExprConstant.cpp
parent7a343142901f7f6bd1965051a24ae6a12c6f2148 (diff)
When determining whether a reference to a static data member is an
integral constant expression, make sure to find where the initializer was provided---inside or outside the class definition---since that can affect whether we have an integral constant expression (and, we need to see the initializer itself). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85741 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/ExprConstant.cpp')
-rw-r--r--lib/AST/ExprConstant.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/lib/AST/ExprConstant.cpp b/lib/AST/ExprConstant.cpp
index 6ddeba99a7..804684cc2b 100644
--- a/lib/AST/ExprConstant.cpp
+++ b/lib/AST/ExprConstant.cpp
@@ -270,8 +270,9 @@ APValue LValueExprEvaluator::VisitDeclRefExpr(DeclRefExpr *E) {
if (!VD->getType()->isReferenceType())
return APValue(E, 0);
// FIXME: Check whether VD might be overridden!
- if (VD->getInit())
- return Visit(VD->getInit());
+ const VarDecl *Def = 0;
+ if (const Expr *Init = VD->getDefinition(Def))
+ return Visit(const_cast<Expr *>(Init));
}
return APValue();
@@ -855,11 +856,14 @@ bool IntExprEvaluator::VisitDeclRefExpr(const DeclRefExpr *E) {
// In C++, const, non-volatile integers initialized with ICEs are ICEs.
// In C, they can also be folded, although they are not ICEs.
- if (E->getType().getCVRQualifiers() == Qualifiers::Const) {
+ if (Info.Ctx.getCanonicalType(E->getType()).getCVRQualifiers()
+ == Qualifiers::Const) {
if (const VarDecl *D = dyn_cast<VarDecl>(E->getDecl())) {
- if (APValue *V = D->getEvaluatedValue())
- return Success(V->getInt(), E);
- if (const Expr *Init = D->getInit()) {
+ const VarDecl *Def = 0;
+ if (const Expr *Init = D->getDefinition(Def)) {
+ if (APValue *V = D->getEvaluatedValue())
+ return Success(V->getInt(), E);
+
if (Visit(const_cast<Expr*>(Init))) {
// Cache the evaluated value in the variable declaration.
D->setEvaluatedValue(Info.Ctx, Result);