25c7f1
2017-02-28  Jakub Jelinek  <jakub@redhat.com>
25c7f1
25c7f1
	Backport from mainline
25c7f1
	2015-12-02  Jan Hubicka  <hubicka@ucw.cz>
25c7f1
25c7f1
	PR ipa/68184
25c7f1
	* cgraphunit.c (cgraph_node::analyze): Set can_throw_external.
25c7f1
25c7f1
	* g++.dg/torture/pr68184.C: New testcase.
25c7f1
25c7f1
--- gcc/cgraphunit.c.jj	2014-09-10 09:15:51.000000000 +0200
25c7f1
+++ gcc/cgraphunit.c	2017-02-28 08:24:44.387385510 +0100
25c7f1
@@ -626,8 +626,10 @@ cgraph_analyze_function (struct cgraph_n
25c7f1
     }
25c7f1
   else if (node->thunk.thunk_p)
25c7f1
     {
25c7f1
-      cgraph_create_edge (node, cgraph_get_node (node->thunk.alias),
25c7f1
-			  NULL, 0, CGRAPH_FREQ_BASE);
25c7f1
+      struct cgraph_node *t = cgraph_get_node (node->thunk.alias);
25c7f1
+      cgraph_create_edge (node, t, NULL, 0,
25c7f1
+			  CGRAPH_FREQ_BASE)->can_throw_external
25c7f1
+	= !TREE_NOTHROW (t->symbol.decl);
25c7f1
     }
25c7f1
   else if (node->dispatcher_function)
25c7f1
     {
25c7f1
--- gcc/testsuite/g++.dg/torture/pr68184.C.jj	2017-02-28 08:26:09.205246069 +0100
25c7f1
+++ gcc/testsuite/g++.dg/torture/pr68184.C	2015-12-03 16:39:34.589010321 +0100
25c7f1
@@ -0,0 +1,31 @@
25c7f1
+// { dg-do run }
25c7f1
+namespace {
25c7f1
+struct IFoo { virtual void foo() = 0; };
25c7f1
+struct IBar { virtual void bar() = 0; };
25c7f1
+
25c7f1
+struct FooBar : private IBar, private IFoo
25c7f1
+{
25c7f1
+    void call_foo()
25c7f1
+    {
25c7f1
+        try
25c7f1
+        {
25c7f1
+            static_cast<IFoo*>(this)->foo();
25c7f1
+        }
25c7f1
+        catch( ... ) {}
25c7f1
+    }
25c7f1
+    void foo() { throw 1; }
25c7f1
+    void bar()  {}
25c7f1
+};
25c7f1
+
25c7f1
+void test()
25c7f1
+{
25c7f1
+    FooBar foobar;
25c7f1
+    foobar.call_foo();
25c7f1
+}
25c7f1
+}
25c7f1
+int main()
25c7f1
+{
25c7f1
+    test();
25c7f1
+    return 0;
25c7f1
+}
25c7f1
+