]> granicus.if.org Git - clang/commitdiff
Make sure to calculate value-dependence correctly when deal with ICEs.
authorEli Friedman <eli.friedman@gmail.com>
Thu, 11 Jun 2009 01:11:20 +0000 (01:11 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Thu, 11 Jun 2009 01:11:20 +0000 (01:11 +0000)
(Actually, this isn't precisely correct, but it doesn't make
sense to query whether an expression that isn't an ICE is
value-dependent anyway.)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73179 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExpr.cpp
test/SemaTemplate/instantiate-declref-ice.cpp [new file with mode: 0644]

index da32d4ec10619600cd20bd10b5ffdf903a4df909..1abd5fb302e7e948a87eb8c7c7eaafe74c525074 100644 (file)
@@ -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 (file)
index 0000000..21ee872
--- /dev/null
@@ -0,0 +1,7 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+
+template<int i> struct x {
+  static const int j = i;
+  x<j>* y;
+};
+