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