===================================================================
@@ -360,8 +360,10 @@ use_thunk (tree thunk_fndecl, bool emit_p)
{
resolve_unique_section (thunk_fndecl, 0, flag_function_sections);
- /* Output the thunk into the same section as function. */
- DECL_SECTION_NAME (thunk_fndecl) = DECL_SECTION_NAME (function);
+ /* Output the thunk into the same section as function if function reordering
+ is not switched on. */
+ if (!flag_reorder_functions)
+ DECL_SECTION_NAME (thunk_fndecl) = DECL_SECTION_NAME (function);
}
}
===================================================================
@@ -0,0 +1,30 @@
+/* { dg-require-named-sections "" } */
+/* { dg-do compile } */
+/* { dg-options "-O2 -fno-reorder-blocks-and-partition -ffunction-sections" } */
+
+class base_class_1
+{
+public:
+ virtual void vfn () {}
+};
+
+class base_class_2
+{
+public:
+ virtual void vfn () {}
+};
+
+class need_thunk_class : public base_class_1, public base_class_2
+{
+public:
+ virtual void vfn () {}
+};
+
+int main (int argc, char *argv[])
+{
+ base_class_1 *c = new need_thunk_class ();
+ c->vfn();
+ return 0;
+}
+
+/* { dg-final { scan-assembler "\.text\._ZThn8_N16need_thunk_class3vfnEv" } } */