Workaround build bug with GCC 6.2.1

Message ID 20171123155745.41193-1-prudo@linux.vnet.ibm.com
State New, archived
Headers

Commit Message

Philipp Rudo Nov. 23, 2017, 3:57 p.m. UTC
  Building GDB with GCC 6.2.1 gives multiple errors like

gdb/dtrace-probe.c: In member function ‘void dtrace_probe::build_arg_exprs(gdbarch*)’:
gdb/dtrace-probe.c:627:8: error: types may not be defined in a for-range-declaration [-Werror]
    for (struct dtrace_probe_arg &arg : m_args

Fix it by removing the 'struct' keyword.

A similar Bug was already fixed for GCC 6.3.1
https://sourceware.org/ml/gdb-patches/2017-10/msg00442.html
---
 gdb/dtrace-probe.c | 8 ++++----
 gdb/probe.c        | 4 ++--
 2 files changed, 6 insertions(+), 6 deletions(-)
  

Comments

Sergio Durigan Junior Nov. 23, 2017, 7:38 p.m. UTC | #1
On Thursday, November 23 2017, Philipp Rudo wrote:

> Building GDB with GCC 6.2.1 gives multiple errors like
>
> gdb/dtrace-probe.c: In member function ‘void dtrace_probe::build_arg_exprs(gdbarch*)’:
> gdb/dtrace-probe.c:627:8: error: types may not be defined in a for-range-declaration [-Werror]
>     for (struct dtrace_probe_arg &arg : m_args
>
> Fix it by removing the 'struct' keyword.

Thanks for the patch, Philipp.

This is missing a ChangeLog entry.  It's OK to push once this is
addressed.

> A similar Bug was already fixed for GCC 6.3.1
> https://sourceware.org/ml/gdb-patches/2017-10/msg00442.html
> ---
>  gdb/dtrace-probe.c | 8 ++++----
>  gdb/probe.c        | 4 ++--
>  2 files changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/gdb/dtrace-probe.c b/gdb/dtrace-probe.c
> index ace3d306a1..1c88f89054 100644
> --- a/gdb/dtrace-probe.c
> +++ b/gdb/dtrace-probe.c
> @@ -624,7 +624,7 @@ dtrace_probe::build_arg_exprs (struct gdbarch *gdbarch)
>    /* Iterate over the arguments in the probe and build the
>       corresponding GDB internal expression that will generate the
>       value of the argument when executed at the PC of the probe.  */
> -  for (struct dtrace_probe_arg &arg : m_args)
> +  for (dtrace_probe_arg &arg : m_args)
>      {
>        struct cleanup *back_to;
>        struct parser_state pstate;
> @@ -684,7 +684,7 @@ dtrace_probe::is_enabled () const
>  {
>    struct gdbarch *gdbarch = this->get_gdbarch ();
>  
> -  for (const struct dtrace_probe_enabler &enabler : m_enablers)
> +  for (const dtrace_probe_enabler &enabler : m_enablers)
>      if (!gdbarch_dtrace_probe_is_enabled (gdbarch, enabler.address))
>        return false;
>  
> @@ -796,7 +796,7 @@ dtrace_probe::enable ()
>  
>    /* Iterate over all defined enabler in the given probe and enable
>       them all using the corresponding gdbarch hook.  */
> -  for (const struct dtrace_probe_enabler &enabler : m_enablers)
> +  for (const dtrace_probe_enabler &enabler : m_enablers)
>      if (gdbarch_dtrace_enable_probe_p (gdbarch))
>        gdbarch_dtrace_enable_probe (gdbarch, enabler.address);
>  }
> @@ -826,7 +826,7 @@ dtrace_probe::disable ()
>  
>    /* Iterate over all defined enabler in the given probe and disable
>       them all using the corresponding gdbarch hook.  */
> -  for (struct dtrace_probe_enabler &enabler : m_enablers)
> +  for (dtrace_probe_enabler &enabler : m_enablers)
>      if (gdbarch_dtrace_disable_probe_p (gdbarch))
>        gdbarch_dtrace_disable_probe (gdbarch, enabler.address);
>  }
> diff --git a/gdb/probe.c b/gdb/probe.c
> index 1be8faad35..e20bf31630 100644
> --- a/gdb/probe.c
> +++ b/gdb/probe.c
> @@ -367,7 +367,7 @@ gen_ui_out_table_header_info (const std::vector<bound_probe> &probes,
>    std::vector<struct info_probe_column> headings
>      = spops->gen_info_probes_table_header ();
>  
> -  for (const struct info_probe_column &column : headings)
> +  for (const info_probe_column &column : headings)
>      {
>        size_t size_max = strlen (column.print_name);
>  
> @@ -410,7 +410,7 @@ print_ui_out_not_applicables (const static_probe_ops *spops)
>     std::vector<struct info_probe_column> headings
>       = spops->gen_info_probes_table_header ();
>  
> -  for (const struct info_probe_column &column : headings)
> +  for (const info_probe_column &column : headings)
>      current_uiout->field_string (column.field_name, _("n/a"));
>  }
>  
> -- 
> 2.13.5
  
Philipp Rudo Nov. 24, 2017, 10:05 a.m. UTC | #2
Oops, should have thought about the ChangeLog. The updated patch is
appended.

I'll ask Andreas to push once he is here. I still don't have the proper
rights to do it myself...

Thanks
Philipp
  

Patch

diff --git a/gdb/dtrace-probe.c b/gdb/dtrace-probe.c
index ace3d306a1..1c88f89054 100644
--- a/gdb/dtrace-probe.c
+++ b/gdb/dtrace-probe.c
@@ -624,7 +624,7 @@  dtrace_probe::build_arg_exprs (struct gdbarch *gdbarch)
   /* Iterate over the arguments in the probe and build the
      corresponding GDB internal expression that will generate the
      value of the argument when executed at the PC of the probe.  */
-  for (struct dtrace_probe_arg &arg : m_args)
+  for (dtrace_probe_arg &arg : m_args)
     {
       struct cleanup *back_to;
       struct parser_state pstate;
@@ -684,7 +684,7 @@  dtrace_probe::is_enabled () const
 {
   struct gdbarch *gdbarch = this->get_gdbarch ();
 
-  for (const struct dtrace_probe_enabler &enabler : m_enablers)
+  for (const dtrace_probe_enabler &enabler : m_enablers)
     if (!gdbarch_dtrace_probe_is_enabled (gdbarch, enabler.address))
       return false;
 
@@ -796,7 +796,7 @@  dtrace_probe::enable ()
 
   /* Iterate over all defined enabler in the given probe and enable
      them all using the corresponding gdbarch hook.  */
-  for (const struct dtrace_probe_enabler &enabler : m_enablers)
+  for (const dtrace_probe_enabler &enabler : m_enablers)
     if (gdbarch_dtrace_enable_probe_p (gdbarch))
       gdbarch_dtrace_enable_probe (gdbarch, enabler.address);
 }
@@ -826,7 +826,7 @@  dtrace_probe::disable ()
 
   /* Iterate over all defined enabler in the given probe and disable
      them all using the corresponding gdbarch hook.  */
-  for (struct dtrace_probe_enabler &enabler : m_enablers)
+  for (dtrace_probe_enabler &enabler : m_enablers)
     if (gdbarch_dtrace_disable_probe_p (gdbarch))
       gdbarch_dtrace_disable_probe (gdbarch, enabler.address);
 }
diff --git a/gdb/probe.c b/gdb/probe.c
index 1be8faad35..e20bf31630 100644
--- a/gdb/probe.c
+++ b/gdb/probe.c
@@ -367,7 +367,7 @@  gen_ui_out_table_header_info (const std::vector<bound_probe> &probes,
   std::vector<struct info_probe_column> headings
     = spops->gen_info_probes_table_header ();
 
-  for (const struct info_probe_column &column : headings)
+  for (const info_probe_column &column : headings)
     {
       size_t size_max = strlen (column.print_name);
 
@@ -410,7 +410,7 @@  print_ui_out_not_applicables (const static_probe_ops *spops)
    std::vector<struct info_probe_column> headings
      = spops->gen_info_probes_table_header ();
 
-  for (const struct info_probe_column &column : headings)
+  for (const info_probe_column &column : headings)
     current_uiout->field_string (column.field_name, _("n/a"));
 }