]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR ipa/60058 (internal compiler error: Segmentation fault)
authorMarkus Trippelsdorf <markus@trippelsdorf.de>
Tue, 4 Feb 2014 17:25:38 +0000 (17:25 +0000)
committerJan Hubicka <hubicka@gcc.gnu.org>
Tue, 4 Feb 2014 17:25:38 +0000 (17:25 +0000)
PR ipa/60058
* ipa-cp.c (ipa_get_indirect_edge_target_1): Check that target
is non-null.
* g++.dg/torture/pr60058.C: New testcase.

From-SVN: r207478

gcc/ChangeLog
gcc/ipa-cp.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/torture/pr60058.C [new file with mode: 0644]

index baa87764d688b9de59d8a9a9a80fec64db76e085..68ec96251eec71dfd04583b59a3b207db89c2fea 100644 (file)
@@ -1,3 +1,9 @@
+2014-02-04  Markus Trippelsdorf  <markus@trippelsdorf.de>
+
+       PR ipa/60058
+       * ipa-cp.c (ipa_get_indirect_edge_target_1): Check that target
+       is non-null.
+
 2014-02-04  Jan Hubicka  <hubicka@ucw.cz>
 
        * gimple-fold.c (can_refer_decl_in_current_unit_p): Default visibility is safe.
index 68afeb0d89e445f699105dac4b715688c10c612c..a2682bbe18d49dc2a565c792c53cc0afd405cc57 100644 (file)
@@ -1573,20 +1573,23 @@ ipa_get_indirect_edge_target_1 (struct cgraph_edge *ie,
        {
          target = gimple_get_virt_method_for_vtable (ie->indirect_info->otr_token,
                                                      vtable, offset);
-         if ((TREE_CODE (TREE_TYPE (target)) == FUNCTION_TYPE
-              && DECL_FUNCTION_CODE (target) == BUILT_IN_UNREACHABLE)
-             || !possible_polymorphic_call_target_p
-                  (ie, cgraph_get_node (target)))
+         if (target)
            {
-             if (dump_file)
-               fprintf (dump_file,
-                        "Type inconsident devirtualization: %s/%i->%s\n",
-                        ie->caller->name (), ie->caller->order,
-                        IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (target)));
-             target = builtin_decl_implicit (BUILT_IN_UNREACHABLE);
-             cgraph_get_create_node (target);
+             if ((TREE_CODE (TREE_TYPE (target)) == FUNCTION_TYPE
+                  && DECL_FUNCTION_CODE (target) == BUILT_IN_UNREACHABLE)
+                 || !possible_polymorphic_call_target_p
+                      (ie, cgraph_get_node (target)))
+               {
+                 if (dump_file)
+                   fprintf (dump_file,
+                            "Type inconsident devirtualization: %s/%i->%s\n",
+                            ie->caller->name (), ie->caller->order,
+                            IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (target)));
+                 target = builtin_decl_implicit (BUILT_IN_UNREACHABLE);
+                 cgraph_get_create_node (target);
+               }
+             return target;
            }
-         return target;
        }
     }
 
index e2d5ebcbc01483298d538e9f5eefcf184ff3e37f..028b911c271ea0ef3064d815cc87e497045e13b6 100644 (file)
@@ -1,3 +1,8 @@
+2014-02-04  Markus Trippelsdorf  <markus@trippelsdorf.de>
+
+       PR ipa/60058
+       * g++.dg/torture/pr60058.C: New testcase.
+
 2014-02-04  Max Ostapenko  <m.ostapenko@partner.samsung.com>
 
        * g++.dg/tsan/default_options.C: Invert check.
diff --git a/gcc/testsuite/g++.dg/torture/pr60058.C b/gcc/testsuite/g++.dg/torture/pr60058.C
new file mode 100644 (file)
index 0000000..1144137
--- /dev/null
@@ -0,0 +1,30 @@
+/* { dg-do compile } */
+/* { dg-require-visibility "" } */
+
+typedef enum {} UErrorCode;
+class A {
+public:
+  virtual A &m_fn1(A &, const A &, UErrorCode &) const;
+  void m_fn2();
+  A();
+  A(int);
+};
+class __attribute__((visibility("hidden"))) B : public A {
+public:
+  B(A &p1) : norm2(p1), set(0) {}
+  A &m_fn1(A &, const A &, UErrorCode &) const;
+  A &norm2;
+  const int &set;
+};
+
+UErrorCode a;
+A c;
+void fn1(A *p1) {
+  A b;
+  p1->m_fn1(b, 0, a).m_fn2();
+}
+
+void fn2() {
+  B d(c);
+  fn1(&d);
+}