aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Sema/SemaExpr.cpp7
-rw-r--r--test/SemaTemplate/instantiate-declref-ice.cpp7
2 files changed, 13 insertions, 1 deletions
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index da32d4ec10..1abd5fb302 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -1177,7 +1177,12 @@ Sema::ActOnDeclarationNameExpr(Scope *S, SourceLocation Loc,
ValueDependent = true;
// - a constant with integral or enumeration type and is
// initialized with an expression that is value-dependent
- // (FIXME!).
+ else if (const VarDecl *Dcl = dyn_cast<VarDecl>(VD)) {
+ if (Dcl->getType().getCVRQualifiers() == QualType::Const &&
+ Dcl->getInit()) {
+ ValueDependent = Dcl->getInit()->isValueDependent();
+ }
+ }
}
return Owned(BuildDeclRefExpr(VD, VD->getType().getNonReferenceType(), Loc,
diff --git a/test/SemaTemplate/instantiate-declref-ice.cpp b/test/SemaTemplate/instantiate-declref-ice.cpp
new file mode 100644
index 0000000000..21ee872027
--- /dev/null
+++ b/test/SemaTemplate/instantiate-declref-ice.cpp
@@ -0,0 +1,7 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+
+template<int i> struct x {
+ static const int j = i;
+ x<j>* y;
+};
+