]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/38577 (ICE: tree check: expected call_expr, have compound_expr in build_new...
authorJakub Jelinek <jakub@redhat.com>
Fri, 19 Dec 2008 19:33:28 +0000 (20:33 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 19 Dec 2008 19:33:28 +0000 (20:33 +0100)
PR c++/38577
* call.c (build_new_method_call): Handle call being COMPOUND_EXPR
or NOP_EXPR.

* g++.dg/template/call6.C: New test.

From-SVN: r142842

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

index 0a84812fa86fa63ad8dbada3ee087a3c56ff64a6..ad0506a6985e33b824518240d9965f26f33e1904 100644 (file)
@@ -1,3 +1,9 @@
+2008-12-19  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/38577
+       * call.c (build_new_method_call): Handle call being COMPOUND_EXPR
+       or NOP_EXPR.
+
 2008-12-18  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/38427
index 952e151f94b9fdb84046105a6fa7790e50f802ed..09dc57d7a252c95615c4f0da84ceb5cc86a90d72 100644 (file)
@@ -5993,6 +5993,15 @@ build_new_method_call (tree instance, tree fns, tree args,
 
   if (processing_template_decl && call != error_mark_node)
     {
+      bool cast_to_void = false;
+
+      if (TREE_CODE (call) == COMPOUND_EXPR)
+       call = TREE_OPERAND (call, 1);
+      else if (TREE_CODE (call) == NOP_EXPR)
+       {
+         cast_to_void = true;
+         call = TREE_OPERAND (call, 0);
+       }
       if (TREE_CODE (call) == INDIRECT_REF)
        call = TREE_OPERAND (call, 0);
       call = (build_min_non_dep_call_list
@@ -6001,6 +6010,8 @@ build_new_method_call (tree instance, tree fns, tree args,
                          orig_instance, orig_fns, NULL_TREE),
               orig_args));
       call = convert_from_reference (call);
+      if (cast_to_void)
+       call = build_nop (void_type_node, call);
     }
 
  /* Free all the conversions we allocated.  */
index 1337b471c4d98908876896aaf6ff7145128cdbca..eae3cc333042bfaea5c4ae71d36605a15b959037 100644 (file)
@@ -1,3 +1,8 @@
+2008-12-19  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/38577
+       * g++.dg/template/call6.C: New test.
+
 2008-12-19  Janis Johnson  <janis187@us.ibm.com>
 
        Revert:
diff --git a/gcc/testsuite/g++.dg/template/call6.C b/gcc/testsuite/g++.dg/template/call6.C
new file mode 100644 (file)
index 0000000..b79d624
--- /dev/null
@@ -0,0 +1,24 @@
+// PR c++/38577
+// { dg-do compile }
+
+struct A
+{
+  static A *bar ();
+};
+
+struct B : public A
+{
+  static void baz ();
+};
+
+template <class T>
+void foo ()
+{
+  (static_cast<B *> (A::bar ()))->baz ();
+}
+
+void
+bar ()
+{
+  foo<int> ();
+}