[pushed] Fix gdb build with -std=gnu++11

Message ID 20190613082520.7359-1-palves@redhat.com
State New, archived
Headers

Commit Message

Pedro Alves June 13, 2019, 8:25 a.m. UTC
  The options framework series broken the build with gcc 4.8, or any
other compiler were we end up forcing -std=gnu++11, causing errors
like these:

 ../../binutils-gdb/gdb/compile/compile.c: In function gdb::option::option_def_group make_compile_options_def_group(compile_options*):
 ../../binutils-gdb/gdb/compile/compile.c:266:44: error: could not convert (const gdb::option::option_def*)(& compile_command_option_defs) from const gdb::option::option_def* to gdb::array_view<const gdb::option::option_def>
    return {compile_command_option_defs, opts};
					     ^
   CXX    copying.o
 ../../binutils-gdb/gdb/compile/compile.c:267:1: error: control reaches end of non-void function [-Werror=return-type]
  }
  ^

This is a C++11 vs C++14 difference -- C++14 relaxed the rules for
eliding braces.

This commit fixes it by adding the missing (in C++11) braces.  Tested
with g++ 4.8.

gdb/ChangeLog:
2019-06-13  Pedro Alves  <palves@redhat.com>

	* compile/compile.c (make_compile_options_def_group): Add braces
	around array_view initializer.
	* thread.c (make_thread_apply_all_options_def_group)
	(make_thread_apply_all_options_def_group): Likewise.
---
 gdb/ChangeLog         | 7 +++++++
 gdb/compile/compile.c | 2 +-
 gdb/thread.c          | 6 +++---
 3 files changed, 11 insertions(+), 4 deletions(-)
  

Patch

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 307a84ddae1..029acd14dc9 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,10 @@ 
+2019-06-13  Pedro Alves  <palves@redhat.com>
+
+	* compile/compile.c (make_compile_options_def_group): Add braces
+	around array_view initializer.
+	* thread.c (make_thread_apply_all_options_def_group)
+	(make_thread_apply_all_options_def_group): Likewise.
+
 2019-06-13  Pedro Alves  <palves@redhat.com>
 
 	* NEWS (New commands): Mention "maint test-options
diff --git a/gdb/compile/compile.c b/gdb/compile/compile.c
index b467254fe83..25d0bfe6022 100644
--- a/gdb/compile/compile.c
+++ b/gdb/compile/compile.c
@@ -263,7 +263,7 @@  static const gdb::option::option_def compile_command_option_defs[] = {
 static gdb::option::option_def_group
 make_compile_options_def_group (compile_options *opts)
 {
-  return {compile_command_option_defs, opts};
+  return {{compile_command_option_defs}, opts};
 }
 
 /* Handle the input from the 'compile file' command.  The "compile
diff --git a/gdb/thread.c b/gdb/thread.c
index 947427aa046..695572f3fb9 100644
--- a/gdb/thread.c
+++ b/gdb/thread.c
@@ -1531,8 +1531,8 @@  make_thread_apply_all_options_def_group (int *ascending,
 					 qcs_flags *flags)
 {
   return {{
-    { ascending_option_def.def (), ascending},
-    { thr_qcs_flags_option_defs, flags },
+    { {ascending_option_def.def ()}, ascending},
+    { {thr_qcs_flags_option_defs}, flags },
   }};
 }
 
@@ -1542,7 +1542,7 @@  make_thread_apply_all_options_def_group (int *ascending,
 static inline gdb::option::option_def_group
 make_thread_apply_options_def_group (qcs_flags *flags)
 {
-  return {thr_qcs_flags_option_defs, flags};
+  return {{thr_qcs_flags_option_defs}, flags};
 }
 
 /* Apply a GDB command to a list of threads.  List syntax is a whitespace