2019-07-08 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/65143
* g++.dg/tree-ssa/final2.C: New.
* g++.dg/tree-ssa/final3.C: Likewise.
From-SVN: r273228
+2019-07-08 Paolo Carlini <paolo.carlini@oracle.com>
+
+ PR c++/65143
+ * g++.dg/tree-ssa/final2.C: New.
+ * g++.dg/tree-ssa/final3.C: Likewise.
+
2019-07-08 Javier Miranda <miranda@adacore.com>
* gnat.dg/interface10.adb: New testcase.
--- /dev/null
+// PR c++/65143
+// { dg-do compile { target c++11 } }
+// { dg-additional-options -fdump-tree-gimple }
+// { dg-final { scan-tree-dump-times "vptr" 1 gimple } }
+
+struct A
+{
+ int i();
+};
+
+struct B : public virtual A
+{
+ int get()
+ {
+ return A::i() + 1;
+ }
+};
+
+struct C final : public B
+{
+ int get()
+ {
+ return A::i() + 2;
+ }
+};
+
+int foo(C& c)
+{
+ return c.get(); // Need not go via vtable pointer as class C is final
+}
+
+int foo(B& b2)
+{
+ return b2.get(); // This has to go via vtable as most derived class can change the location of A
+}
--- /dev/null
+// PR c++/65143
+// { dg-do compile { target c++11 } }
+// { dg-additional-options -fdump-tree-gimple }
+// { dg-final { scan-tree-dump-not "vptr" gimple } }
+
+struct A
+{
+ int j;
+};
+
+struct B : public virtual A
+{
+};
+
+struct C final : public B
+{
+ int get();
+};
+
+int C::get()
+{
+ return A::j;
+}