2012-05-03 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/53186
* call.c (build_over_call): Handle final member functions
and class types.
(build_new_method_call_1): Do not handle here.
/testsuite
2012-05-03 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/53186
* g++.dg/other/final2.C: New.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_7-branch@187098
138bc75d-0d04-0410-961f-
82ee72b054a4
+2012-05-03 Paolo Carlini <paolo.carlini@oracle.com>
+
+ PR c++/53186
+ * call.c (build_over_call): Handle final member functions
+ and class types.
+ (build_new_method_call_1): Do not handle here.
+
2012-04-17 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/53003
return error_mark_node;
}
+ /* See if the function member or the whole class type is declared
+ final and the call can be devirtualized. */
+ if (DECL_FINAL_P (fn)
+ || CLASSTYPE_FINAL (TYPE_METHOD_BASETYPE (TREE_TYPE (fn))))
+ flags |= LOOKUP_NONVIRTUAL;
+
/* [class.mfct.nonstatic]: If a nonstatic member function of a class
X is called for an object that is not of type X, or of a type
derived from X, the behavior is undefined.
/* Optimize away vtable lookup if we know that this function
can't be overridden. */
if (DECL_VINDEX (fn) && ! (flags & LOOKUP_NONVIRTUAL)
- && (resolves_to_fixed_type_p (instance, 0)
- || DECL_FINAL_P (fn) || CLASSTYPE_FINAL (basetype)))
+ && resolves_to_fixed_type_p (instance, 0))
flags |= LOOKUP_NONVIRTUAL;
if (explicit_targs)
flags |= LOOKUP_EXPLICIT_TMPL_ARGS;
+2012-05-03 Paolo Carlini <paolo.carlini@oracle.com>
+
+ PR c++/53186
+ * g++.dg/other/final2.C: New.
+
2012-05-03 Jakub Jelinek <jakub@redhat.com>
PR debug/53174
--- /dev/null
+// PR c++/53186
+// { dg-options "-fdump-tree-original -std=c++11" }
+
+struct F1
+{
+ virtual void operator()() final;
+ virtual operator int() final;
+ virtual int operator++() final;
+};
+
+struct F2 final
+{
+ virtual void operator()();
+ virtual operator int();
+ virtual int operator++();
+};
+
+void fooF1(F1& a) { a(); int m = a; ++a; }
+void fooF2(F2& a) { a(); int m = a; ++a; }
+
+// { dg-final { scan-tree-dump-times "F1::operator\\(\\)" 1 "original" } }
+// { dg-final { scan-tree-dump-times "F1::operator int" 1 "original" } }
+// { dg-final { scan-tree-dump-times "F1::operator\\+\\+" 1 "original" } }
+// { dg-final { scan-tree-dump-times "F2::operator\\(\\)" 1 "original" } }
+// { dg-final { scan-tree-dump-times "F2::operator int" 1 "original" } }
+// { dg-final { scan-tree-dump-times "F2::operator\\+\\+" 1 "original" } }
+// { dg-final { cleanup-tree-dump "original" } }