re PR c++/41183 (ICE compiling chromium)
authorJakub Jelinek <jakub@redhat.com>
Tue, 15 Dec 2009 15:13:08 +0000 (16:13 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 15 Dec 2009 15:13:08 +0000 (16:13 +0100)
PR c++/41183
* cp-tree.h (current_class_ptr): Give NULL even when cfun
has NULL cfun->language.

* g++.dg/torture/pr41183.C: New test.

From-SVN: r155254

gcc/cp/ChangeLog
gcc/cp/cp-tree.h
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/torture/pr41183.C [new file with mode: 0644]

index fbfed9f..d9d758f 100644 (file)
@@ -1,3 +1,9 @@
+2009-12-15  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/41183
+       * cp-tree.h (current_class_ptr): Give NULL even when cfun
+       has NULL cfun->language.
+
 2009-12-14  Jason Merrill  <jason@redhat.com>
 
        PR c++/42364
index eb7f06d..4e32f9b 100644 (file)
@@ -1026,7 +1026,8 @@ struct GTY(()) language_function {
    expression for `*this'.  */
 
 #define current_class_ptr \
-  (cfun ? cp_function_chain->x_current_class_ptr : NULL_TREE)
+  (cfun && cp_function_chain                                   \
+   ? cp_function_chain->x_current_class_ptr : NULL_TREE)
 #define current_class_ref \
   (cfun ? cp_function_chain->x_current_class_ref : NULL_TREE)
 
index eb9cf47..a4ccde9 100644 (file)
@@ -1,3 +1,8 @@
+2009-12-15  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/41183
+       * g++.dg/torture/pr41183.C: New test.
+
 2009-12-15  Tobias Burnus  <burnus@net-b.de>
 
        PR fortran/41235
diff --git a/gcc/testsuite/g++.dg/torture/pr41183.C b/gcc/testsuite/g++.dg/torture/pr41183.C
new file mode 100644 (file)
index 0000000..df3e303
--- /dev/null
@@ -0,0 +1,30 @@
+// PR c++/41183
+// { dg-do compile }
+
+void foo (const char *);
+
+template <int *>
+struct A
+{
+  template <typename T> A (const int &, T);
+  int i;
+};
+
+template <int *X>
+template <typename T>
+A<X>::A (const int &j, T) : i(j)
+{
+  foo (0);
+  foo (0);
+  foo (__PRETTY_FUNCTION__);
+}
+
+int N;
+
+struct B
+{
+  B ();
+  A<&N> a;
+};
+
+B::B() : a(N, 0) {}