binutils-gdb/gdb/common
Pedro Alves 60adb36c08 gdb: make_scoped_restore and types convertible to T
A following patch will want to do

   string_file str_file;

   scoped_restore save_stdout
    = make_scoped_restore (&gdb_stdout, &str_file);

where gdb_stdout is a ui_file *, and string_file is a type that
inherits from ui_file, but that doesn't compile today:

  src/gdb/top.c: In function ‘std::__cxx11::string execute_command_to_string(char*, int)’:
  src/gdb/top.c:710:50: error: no matching function for call to ‘make_scoped_restore(ui_file**, string_file*)’
       = make_scoped_restore (&gdb_stdout, &str_file);
						    ^
  [...]
  In file included from src/gdb/utils.h:25:0,
		   from src/gdb/defs.h:732,
		   from src/gdb/top.c:20:
  src/gdb/common/scoped_restore.h:94:24: note: candidate: template<class T> scoped_restore_tmpl<T> make_scoped_restore(T*, T)
   scoped_restore_tmpl<T> make_scoped_restore (T *var, T value)
			  ^
  src/gdb/common/scoped_restore.h:94:24: note:   template argument deduction/substitution failed:
  src/gdb/top.c:710:50: note:   deduced conflicting types for parameter ‘T’ (‘ui_file*’ and ‘string_file*’)
       = make_scoped_restore (&gdb_stdout, &str_file);
						    ^

This commit makes code such as the above possible.

gdb/ChangeLog:
2017-01-31  Pedro Alves  <palves@redhat.com>

	* common/scoped_restore.h
	(scoped_restore_tmpl::scoped_restore_tmpl): Template on T2, and
	change the value's parameter type to T2.
	(make_scoped_restore): Likewise.
2017-01-31 17:56:35 +00:00
..
agent.c update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
agent.h update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
ax.def update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
break-common.h update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
btrace-common.c update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
btrace-common.h update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
buffer.c update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
buffer.h update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
cleanups.c update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
cleanups.h update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
common-debug.c update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
common-debug.h update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
common-defs.h update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
common-exceptions.c update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
common-exceptions.h update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
common-regcache.c update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
common-regcache.h update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
common-types.h update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
common-utils.c update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
common-utils.h update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
common.host update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
common.m4 update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
create-version.sh update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
enum-flags.h update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
errors.c update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
errors.h update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
fileio.c update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
fileio.h update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
filestuff.c update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
filestuff.h update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
format.c update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
format.h update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
gdb_assert.h update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
gdb_locale.h update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
gdb_ref_ptr.h Use class to manage BFD reference counts 2017-01-10 19:14:10 -07:00
gdb_setjmp.h update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
gdb_signals.h update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
gdb_sys_time.h update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
gdb_unique_ptr.h update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
gdb_unlinker.h Introduce and use gdb::unlinker 2017-01-10 19:14:11 -07:00
gdb_vecs.c update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
gdb_vecs.h update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
gdb_wait.h update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
host-defs.h update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
mingw-strerror.c update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
new-op.c update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
posix-strerror.c update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
print-utils.c update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
print-utils.h update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
ptid.c update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
ptid.h update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
queue.h update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
rsp-low.c update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
rsp-low.h update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
run-time-clock.c update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
run-time-clock.h update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
scoped_restore.h gdb: make_scoped_restore and types convertible to T 2017-01-31 17:56:35 +00:00
signals-state-save-restore.c update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
signals-state-save-restore.h update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
signals.c update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
symbol.h update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
vec.c update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
vec.h update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
version.h update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
x86-xstate.h update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
xml-utils.c update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
xml-utils.h update copyright year range in GDB files 2017-01-01 10:52:34 +04:00