PR c++/56684
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 22 Mar 2013 20:24:17 +0000 (20:24 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 22 Mar 2013 20:24:17 +0000 (20:24 +0000)
* pt.c (instantiation_dependent_r): Check DECL_INITIAL of VAR_DECL
and CONST_DECL.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@196983 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/g++.dg/template/const6.C [new file with mode: 0644]

index e3428ba..0a943a1 100644 (file)
@@ -1,3 +1,9 @@
+2013-03-22  Jason Merrill  <jason@redhat.com>
+
+       PR c++/56684
+       * pt.c (instantiation_dependent_r): Check DECL_INITIAL of VAR_DECL
+       and CONST_DECL.
+
 2013-03-21  Gabriel Dos Reis  <gdr@integrable-solutions.net>
 
        * cp-tree.h (identifier_p): New.
index b44c632..b6066c1 100644 (file)
@@ -19942,6 +19942,13 @@ instantiation_dependent_r (tree *tp, int *walk_subtrees,
     case TREE_VEC:
       return NULL_TREE;
 
+    case VAR_DECL:
+    case CONST_DECL:
+      /* A constant with a dependent initializer is dependent.  */
+      if (value_dependent_expression_p (*tp))
+       return *tp;
+      break;
+
     case TEMPLATE_PARM_INDEX:
       return *tp;
 
diff --git a/gcc/testsuite/g++.dg/template/const6.C b/gcc/testsuite/g++.dg/template/const6.C
new file mode 100644 (file)
index 0000000..3c40d26
--- /dev/null
@@ -0,0 +1,7 @@
+// PR c++/56684
+
+template < int T > struct S
+{
+  static const int Ti = T;
+  S() { 1 << Ti; }
+};