From patchwork Mon Feb 9 23:20:24 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 5012 Received: (qmail 8351 invoked by alias); 9 Feb 2015 23:51:43 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 8331 invoked by uid 89); 9 Feb 2015 23:51:42 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL, BAYES_00, SPF_HELO_PASS, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Mon, 09 Feb 2015 23:51:41 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t19NL4nA006893 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Mon, 9 Feb 2015 18:21:05 -0500 Received: from brno.lan (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t19NKkud026307 for ; Mon, 9 Feb 2015 18:21:04 -0500 From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH 14/36] Do not do arithmetic on enum types Date: Mon, 9 Feb 2015 23:20:24 +0000 Message-Id: <1423524046-20605-15-git-send-email-palves@redhat.com> In-Reply-To: <1423524046-20605-1-git-send-email-palves@redhat.com> References: <1423524046-20605-1-git-send-email-palves@redhat.com> MIME-Version: 1.0 From: Tom Tromey In C++, we can't do arithmetic on enums. This patch fixes build errors like: src/gdb/i386-tdep.c: In function ‘int i386_stap_parse_special_token(gdbarch*, stap_parse_info*)’: src/gdb/i386-tdep.c:4309:7: error: no match for ‘operator++’ (operand type is ‘i386_stap_parse_special_token(gdbarch*, stap_parse_info*)::’) ++current_state; ^ ... src/gdb/rs6000-tdep.c:4265:18: error: no match for ‘operator++’ (operand type is ‘powerpc_vector_abi’) src/gdb/arm-tdep.c:9428:71: error: no match for ‘operator++’ (operand type is ‘arm_float_model’) src/gdb/arm-tdep.c:9465:64: error: no match for ‘operator++’ (operand type is ‘arm_abi_kind’) ... gdb/ChangeLog: 2015-02-09 Tom Tromey Pedro Alves * arm-tdep.c (set_fp_model_sfunc, arm_set_abi): Use 'int' for local used to iterate over enums. * completer.c (signal_completer): Likewise. * i386-tdep.c (i386_stap_parse_special_token): Likewise. * rs6000-tdep.c (powerpc_set_vector_abi): Likewise. * tui/tui-data.c (tui_next_win, tui_prev_win): Likewise. * tui/tui-layout.c (next_layout, prev_layout): Likewise. * tui/tui-win.c (tui_refresh_all_win, tui_rehighlight_all) (tui_resize_all, tui_set_focus_command, tui_all_windows_info): Likewise. * tui-wingeneral.c (tui_refresh_all): Likewise. --- gdb/arm-tdep.c | 4 ++-- gdb/completer.c | 4 ++-- gdb/i386-tdep.c | 3 ++- gdb/rs6000-tdep.c | 2 +- gdb/tui/tui-data.c | 4 ++-- gdb/tui/tui-layout.c | 8 ++++---- gdb/tui/tui-win.c | 8 ++++---- gdb/tui/tui-wingeneral.c | 2 +- 8 files changed, 18 insertions(+), 17 deletions(-) diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c index 8e9552a..49b4c07 100644 --- a/gdb/arm-tdep.c +++ b/gdb/arm-tdep.c @@ -9388,7 +9388,7 @@ static void set_fp_model_sfunc (char *args, int from_tty, struct cmd_list_element *c) { - enum arm_float_model fp_model; + int fp_model; for (fp_model = ARM_FLOAT_AUTO; fp_model != ARM_FLOAT_LAST; fp_model++) if (strcmp (current_fp_model, fp_model_strings[fp_model]) == 0) @@ -9425,7 +9425,7 @@ static void arm_set_abi (char *args, int from_tty, struct cmd_list_element *c) { - enum arm_abi_kind arm_abi; + int arm_abi; for (arm_abi = ARM_ABI_AUTO; arm_abi != ARM_ABI_LAST; arm_abi++) if (strcmp (arm_abi_string, arm_abi_strings[arm_abi]) == 0) diff --git a/gdb/completer.c b/gdb/completer.c index 774fb31..2a0dca9 100644 --- a/gdb/completer.c +++ b/gdb/completer.c @@ -951,7 +951,7 @@ signal_completer (struct cmd_list_element *ignore, { VEC (char_ptr) *return_val = NULL; size_t len = strlen (word); - enum gdb_signal signum; + int signum; const char *signame; for (signum = GDB_SIGNAL_FIRST; signum != GDB_SIGNAL_LAST; ++signum) @@ -960,7 +960,7 @@ signal_completer (struct cmd_list_element *ignore, if (signum == GDB_SIGNAL_0) continue; - signame = gdb_signal_to_name (signum); + signame = gdb_signal_to_name ((enum gdb_signal) signum); /* Ignore the unknown signal case. */ if (!signame || strcmp (signame, "?") == 0) diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c index 1c8842c..8c08f8b 100644 --- a/gdb/i386-tdep.c +++ b/gdb/i386-tdep.c @@ -4270,7 +4270,8 @@ i386_stap_parse_special_token (struct gdbarch *gdbarch, TRIPLET, THREE_ARG_DISPLACEMENT, DONE - } current_state; + }; + int current_state; current_state = TRIPLET; diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c index ef94bba..46f6e41 100644 --- a/gdb/rs6000-tdep.c +++ b/gdb/rs6000-tdep.c @@ -6049,7 +6049,7 @@ powerpc_set_vector_abi (char *args, int from_tty, struct cmd_list_element *c) { struct gdbarch_info info; - enum powerpc_vector_abi vector_abi; + int vector_abi; for (vector_abi = POWERPC_VEC_AUTO; vector_abi != POWERPC_VEC_LAST; diff --git a/gdb/tui/tui-data.c b/gdb/tui/tui-data.c index 3c5bce1..3eff9fd 100644 --- a/gdb/tui/tui-data.c +++ b/gdb/tui/tui-data.c @@ -319,7 +319,7 @@ tui_set_current_layout_to (enum tui_layout_type new_layout) struct tui_win_info * tui_next_win (struct tui_win_info *cur_win) { - enum tui_win_type type = cur_win->generic.type; + int type = cur_win->generic.type; struct tui_win_info *next_win = (struct tui_win_info *) NULL; if (cur_win->generic.type == CMD_WIN) @@ -349,7 +349,7 @@ tui_next_win (struct tui_win_info *cur_win) struct tui_win_info * tui_prev_win (struct tui_win_info *cur_win) { - enum tui_win_type type = cur_win->generic.type; + int type = cur_win->generic.type; struct tui_win_info *prev = (struct tui_win_info *) NULL; if (cur_win->generic.type == SRC_WIN) diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c index 56cc026..6547404 100644 --- a/gdb/tui/tui-layout.c +++ b/gdb/tui/tui-layout.c @@ -616,7 +616,7 @@ tui_layout_command (char *arg, int from_tty) static enum tui_layout_type next_layout (void) { - enum tui_layout_type new_layout; + int new_layout; new_layout = tui_current_layout (); if (new_layout == UNDEFINED_LAYOUT) @@ -628,7 +628,7 @@ next_layout (void) new_layout = SRC_COMMAND; } - return new_layout; + return (enum tui_layout_type) new_layout; } @@ -636,7 +636,7 @@ next_layout (void) static enum tui_layout_type prev_layout (void) { - enum tui_layout_type new_layout; + int new_layout; new_layout = tui_current_layout (); if (new_layout == SRC_COMMAND) @@ -648,7 +648,7 @@ prev_layout (void) new_layout = DISASSEM_DATA_COMMAND; } - return new_layout; + return (enum tui_layout_type) new_layout; } diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c index 1a12cc6..6a36d48 100644 --- a/gdb/tui/tui-win.c +++ b/gdb/tui/tui-win.c @@ -626,7 +626,7 @@ tui_scroll (enum tui_scroll_direction direction, void tui_refresh_all_win (void) { - enum tui_win_type type; + int type; clearok (curscr, TRUE); tui_refresh_all (tui_win_list); @@ -658,7 +658,7 @@ tui_refresh_all_win (void) void tui_rehighlight_all (void) { - enum tui_win_type type; + int type; for (type = SRC_WIN; type < MAX_MAJOR_WINDOWS; type++) tui_check_and_display_highlight_if_needed (tui_win_list[type]); @@ -682,7 +682,7 @@ tui_resize_all (void) struct tui_win_info *first_win; struct tui_win_info *second_win; struct tui_gen_win_info *locator = tui_locator_win_info_ptr (); - enum tui_win_type win_type; + int win_type; int new_height, split_diff, cmd_split_diff, num_wins_displayed = 2; #ifdef HAVE_RESIZE_TERM @@ -978,7 +978,7 @@ tui_set_focus_command (char *arg, int from_tty) static void tui_all_windows_info (char *arg, int from_tty) { - enum tui_win_type type; + int type; struct tui_win_info *win_with_focus = tui_win_with_focus (); for (type = SRC_WIN; (type < MAX_MAJOR_WINDOWS); type++) diff --git a/gdb/tui/tui-wingeneral.c b/gdb/tui/tui-wingeneral.c index 72d8cd9..b95da49 100644 --- a/gdb/tui/tui-wingeneral.c +++ b/gdb/tui/tui-wingeneral.c @@ -252,7 +252,7 @@ tui_make_all_invisible (void) void tui_refresh_all (struct tui_win_info **list) { - enum tui_win_type type; + int type; struct tui_gen_win_info *locator = tui_locator_win_info_ptr (); for (type = SRC_WIN; (type < MAX_MAJOR_WINDOWS); type++)