re PR c++/48265 ([C++0x] ICE: SIGSEGV (recursion in value_dependent_expression_p...
authorJason Merrill <jason@redhat.com>
Wed, 30 Mar 2011 02:16:22 +0000 (22:16 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Wed, 30 Mar 2011 02:16:22 +0000 (22:16 -0400)
PR c++/48265
* pt.c (value_dependent_expression_p) [VAR_DECL]: Make sure
the variable is constant before looking at its initializer.

From-SVN: r171714

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/regress/value-dep1.C [new file with mode: 0644]

index c4df48dd746101c03236df5be7aacdb8fea5e5df..855844688b66fdaec513e03648013f6aa405c3fa 100644 (file)
@@ -1,5 +1,9 @@
 2011-03-29  Jason Merrill  <jason@redhat.com>
 
+       PR c++/48265
+       * pt.c (value_dependent_expression_p) [VAR_DECL]: Make sure
+       the variable is constant before looking at its initializer.
+
        PR c++/48319
        * pt.c (value_dependent_expression_p): Handle TEMPLATE_ID_EXPR.
 
index aa0901be3be8f2e8cc6796e6ecf52a298becbdce..5960e4624b633ed9681bf99b52d4e298ec58b429 100644 (file)
@@ -18085,10 +18085,10 @@ value_dependent_expression_p (tree expression)
       return value_dependent_expression_p (DECL_INITIAL (expression));
 
     case VAR_DECL:
-       /* A constant with integral or enumeration type and is initialized
+       /* A constant with literal type and is initialized
          with an expression that is value-dependent.  */
       if (DECL_INITIAL (expression)
-         && INTEGRAL_OR_ENUMERATION_TYPE_P (TREE_TYPE (expression))
+         && decl_constant_var_p (expression)
          && value_dependent_expression_p (DECL_INITIAL (expression)))
        return true;
       return false;
index 48199a2fb7bdd817954639ed954c7a8cebab1ab7..ede28b20e37e2ff34ee089ea644c48c222212d7e 100644 (file)
@@ -1,3 +1,7 @@
+2011-03-29  Jason Merrill  <jason@redhat.com>
+
+       * g++.dg/cpp0x/regress/value-dep1.C: New.
+
 2011-03-29  Steve Ellcey  <sje@cup.hp.com>
 
        * gcc.dg/torture/pr47917.c: Use -std=gnu99 on HP-UX.
diff --git a/gcc/testsuite/g++.dg/cpp0x/regress/value-dep1.C b/gcc/testsuite/g++.dg/cpp0x/regress/value-dep1.C
new file mode 100644 (file)
index 0000000..112389d
--- /dev/null
@@ -0,0 +1,7 @@
+// PR c++/48265
+// { dg-options -std=c++0x }
+
+template < int > struct S
+{
+  S () { const int i = i; i; };
+};