This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] Improve linker errors for missing key method definitions


Make gcc emit a use of the key method with each use of a vtable that
depends on it.  The idea here is to get the linker to mention the key
method in addition to the vtable, since the user should know how to
define the key method. In -O mode, we can sometimes optimize away the
vtable use, while the fake key method use will stick around, but
this'll just flag link errors that would have happened in -O0 mode. I
put this behind a new -fuse-key-methods flag because it will slightly
increase the size of the final binary if -ffunction-sections
-Wl,--gc-sections isn't used.

Tested on x86_64-unknown-linux-gnu, with output spew similar to a clean tree.

gcc/cp/ChangeLog:
2010-07-13  Jeffrey Yasskin  <jyasskin@google.com>

	* decl2.c (needed_key_methods): New.
	* decl2.c (import_export_class): Add imported class's key method to list.
	* decl2.c (emit_needed_key_methods): New.
	* decl2.c (cp_write_global_declarations): Call emit_needed_key_methods.
	* cp-tree.h (convert_member_func_to_ptr): Add tsubst_flags_t argument.
	* typeck.c (convert_member_func_to_ptr): Add tsubst_flags_t argument.
	* typeck.c (build_reinterpret_cast_1): Pass tsubst_flags_t argument.
	* cvt.c (cp_convert_to_pointer): Pass tsubst_flags_t argument.

gcc/c-family/ChangeLog:
	* c.opt: Add -fuse-key-methods.

gcc/ChangeLog:
2010-07-13  Jeffrey Yasskin  <jyasskin@google.com>

	* doc/invoke.texi: Document -fuse-key-methods.

gcc/testsuite/ChangeLog:
	* g++.dg/diagnostic/keymethod1.C: New test.

Attachment: keymethods.patch
Description: Binary data


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]