This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH 05/40] command.h: Include scoped_restore_command.h
On 06/27/2017 12:45 PM, Pedro Alves wrote:
>
> On 06/27/2017 12:30 PM, Yao Qi wrote:
>> Pedro Alves <palves@redhat.com> writes:
>>
>>> This file depends on scoped_restore:
>>>
>>> extern scoped_restore_tmpl<int> prevent_dont_repeat (void);
>>>
>>> But doesn't include the corresponding header.
>>
>> It is a function declaration, so why does it need scoped_restore?
>
> I don't understand. Why wouldn't it? If the compiler doesn't
> know what scoped_restore_tmpl is, how can that compile?
>
>>
>> $ make check-headers CHECK_HEADERS="command.h"
>>
>> The command above doesn't complain anything. I tried gcc-5, 6, and 7.
>
> Odd. Let me take another look.
OK, so defs.h includes utils.h, which includes scoped_restore.h,
as found via this hack:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
diff --git c/gdb/command.h w/gdb/command.h
index aa179e9..f587ebd 100644
--- c/gdb/command.h
+++ w/gdb/command.h
@@ -415,6 +415,8 @@ extern void error_no_arg (const char *) ATTRIBUTE_NORETURN;
extern void dont_repeat (void);
+template <typename T> union scoped_restore_tmpl;
+
extern scoped_restore_tmpl<int> prevent_dont_repeat (void);
/* Used to mark commands that don't do anything. If we just leave the
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/gdb/command.h:418:29: error: ‘union’ tag used in naming ‘struct scoped_restore_tmpl<T>’ [-fpermissive]
template <typename T> union scoped_restore_tmpl;
^
In file included from src/gdb/utils.h:25:0,
from src/gdb/defs.h:785,
from <command-line>:0:
src/gdb/common/scoped_restore.h:50:7: note: ‘struct scoped_restore_tmpl<T>’ was previously declared here
class scoped_restore_tmpl : public scoped_restore_base
^
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> I ran into this because at some point I added "#include "command.h"
> somewhere, which then failed to compile.
I don't remember exactly where I added the #include "command.h" that
triggered this. Must have been somewhere that caused "command.h" to
be included via "defs.h", before the "#include utils.h" line.
Let me try removing it from the series, see if I can still reproduce it.
Thanks,
Pedro Alves