]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/53836 (ICE: unexpected expression of kind template_parm_index)
authorJason Merrill <jason@redhat.com>
Thu, 13 Sep 2012 15:13:24 +0000 (11:13 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Thu, 13 Sep 2012 15:13:24 +0000 (11:13 -0400)
PR c++/53836
* pt.c (value_dependent_expression_p): A TREE_LIST initializer must
be dependent.

From-SVN: r191261

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

index bd620469df1718c587e2c14cf4425377c76bf3bc..b7d8a1d43d5e5e16e80e411c87128d539af0249e 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  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/54541
index 768f141accf05605d2a6d969a787d66fc9b8f70d..4cf2ed8917bd50102a050821375bd8ebb50f7c99 100644 (file)
@@ -19199,10 +19199,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 d6c6e239f2e4f6de6dcf1f70cb767776bfac2b09..debdd885c3039c89ce8093ab747b782b1f2b0f5f 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-13  Tobias Burnus  <burnus@net-b.de>
 
        PR fortran/54556
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>();
+}