re PR c++/84445 (ICE with __builtin_launder and virtual function)
authorJakub Jelinek <jakub@redhat.com>
Tue, 20 Feb 2018 08:22:31 +0000 (09:22 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 20 Feb 2018 08:22:31 +0000 (09:22 +0100)
PR c++/84445
* class.c (fixed_type_or_null) <case CALL_EXPR>: Only test
TREE_HAS_CONSTRUCTOR if instance is not an internal function call.

* g++.dg/cpp1z/launder7.C: New test.

From-SVN: r257840

gcc/cp/ChangeLog
gcc/cp/class.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp1z/launder7.C [new file with mode: 0644]

index 8a786bb4c0692de324bfccc713c619766a8e0d31..1e0f9eb321f88f94d35aa5b79c2e272ea1887cf3 100644 (file)
@@ -1,5 +1,9 @@
 2018-02-20  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c++/84445
+       * class.c (fixed_type_or_null) <case CALL_EXPR>: Only test
+       TREE_HAS_CONSTRUCTOR if instance is not an internal function call.
+
        PR c++/84449
        * tree.c (bot_manip): If build_cplus_new or break_out_target_exprs
        returns error_mark_node, return it immediately.
index 296305ea644a7d4ab9a23237c7bac9acb3ad4498..afa5c41bfff0e10b3c4b8f29475cd2bcdb56627f 100644 (file)
@@ -7128,7 +7128,8 @@ fixed_type_or_null (tree instance, int *nonnull, int *cdtorp)
 
     case CALL_EXPR:
       /* This is a call to a constructor, hence it's never zero.  */
-      if (TREE_HAS_CONSTRUCTOR (instance))
+      if (CALL_EXPR_FN (instance)
+         && TREE_HAS_CONSTRUCTOR (instance))
        {
          if (nonnull)
            *nonnull = 1;
index fd21d3b8a42bf390d77bf009e6a13f4e85025862..29157ac3c24d05cb4ad2063b3dc4093fa5089236 100644 (file)
@@ -1,5 +1,8 @@
 2018-02-20  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c++/84445
+       * g++.dg/cpp1z/launder7.C: New test.
+
        PR c++/84449
        * g++.dg/cpp0x/constexpr-84449.C: New test.
 
diff --git a/gcc/testsuite/g++.dg/cpp1z/launder7.C b/gcc/testsuite/g++.dg/cpp1z/launder7.C
new file mode 100644 (file)
index 0000000..e418329
--- /dev/null
@@ -0,0 +1,10 @@
+// PR c++/84445
+// { dg-do compile }
+
+struct A { virtual void foo (); };
+
+void
+bar (A *p)
+{
+  __builtin_launder (p)->foo ();
+}