OSDN Git Service

PR c++/53836
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 13 Sep 2012 15:14:27 +0000 (15:14 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 13 Sep 2012 15:14:27 +0000 (15:14 +0000)
* pt.c (value_dependent_expression_p): A TREE_LIST initializer must
be dependent.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_7-branch@191264 138bc75d-0d04-0410-961f-82ee72b054a4

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

index f33a6e3..5536b92 100644 (file)
@@ -1,3 +1,9 @@
+2012-09-13  Jason Merrill  <jason@redhat.com>
+
+       PR c++/53836
+       * pt.c (value_dependent_expression_p): A TREE_LIST initializer must
+       be dependent.
+
 2012-09-10  Jason Merrill  <jason@redhat.com>
 
        PR c++/54506
index 585878f..8bc7330 100644 (file)
@@ -19470,10 +19470,15 @@ value_dependent_expression_p (tree expression)
 
     case VAR_DECL:
        /* A constant with literal type and is initialized
-         with an expression that is value-dependent.  */
+         with an expression that is value-dependent.
+
+          Note that a non-dependent parenthesized initializer will have
+          already been replaced with its constant value, so if we see
+          a TREE_LIST it must be dependent.  */
       if (DECL_INITIAL (expression)
          && decl_constant_var_p (expression)
-         && value_dependent_expression_p (DECL_INITIAL (expression)))
+         && (TREE_CODE (DECL_INITIAL (expression)) == TREE_LIST
+             || value_dependent_expression_p (DECL_INITIAL (expression))))
        return true;
       return false;
 
index 729c4b9..f4c039b 100644 (file)
@@ -1,3 +1,8 @@
+2012-09-13  Jason Merrill  <jason@redhat.com>
+
+       PR c++/53836
+       * g++.dg/template/init10.C: New.
+
 2012-09-12  Tobias Burnus  <burnus@net-b.de>
 
        PR fortran/54225
diff --git a/gcc/testsuite/g++.dg/template/init10.C b/gcc/testsuite/g++.dg/template/init10.C
new file mode 100644 (file)
index 0000000..1480622
--- /dev/null
@@ -0,0 +1,15 @@
+template <int N>
+struct A { };
+
+template <int Q>
+void g()
+{
+    const int M ( Q );
+
+    A<M> a;
+}
+
+void h()
+{
+    g<3>();
+}