aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@google.com>2009-05-14 21:29:48 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2009-05-14 21:29:48 +0000
commit09639a839744ebc53f6b221a8a3b57dbb9993f64 (patch)
tree3f13a6a041d6d3c9f9c6dd243c2fffd5baa391b8
parentc04a56bffe53119ac0745f1c86df0c488e447989 (diff)
downloadgcc-09639a839744ebc53f6b221a8a3b57dbb9993f64.zip
gcc-09639a839744ebc53f6b221a8a3b57dbb9993f64.tar.gz
gcc-09639a839744ebc53f6b221a8a3b57dbb9993f64.tar.bz2
passes.c (finish_optimization_passes): Change i to int.
./: * passes.c (finish_optimization_passes): Change i to int. * plugin.c (plugins_active_p): Change event to int. (dump_active_plugins): Likewise. * reginfo.c (invalid_mode_change_p): Change to to unsigned int. Add cast. * tree.c (tree_range_check_failed): Change c to unsigned int. (omp_clause_range_check_failed): Likewise. (build_common_builtin_nodes): Change mode to int. Add cast. * config/ia64/ia64.c (is_emitted): Change r to unsigned int. (ia64_hard_regno_rename_ok, ia64_eh_uses): Likewise. * c-typeck.c (build_unary_op): If -Wc++-compat, warn about using ++ or -- with a variable of enum type. cp/: * class.c (layout_class_type): Change itk to unsigned int. * decl.c (finish_enum): Change itk to unsigned int. * parser.c (cp_parser_check_decl_spec): Change ds to int. Remove casts. fortran/: * decl.c (match_attr_spec): Change d to unsigned int. * dump-parse-tree.c (show_namespace): Change op to int. Add cast. * interface.c (gfc_check_interfaces): Change i to int. Add casts. * module.c (read_module): Change i to int. Add cast. (write_module): Change i to int. * symbol.c (gfc_get_namespace): Change in to int. (gfc_free_namespace): Change i to int. * trans-io.c (gfc_build_io_library_fndecls): Change ptype to unsigned int. Add cast. * trans-types.c (gfc_init_kinds): Change mode to unsigned int. Add casts. testsuite/: * gcc.dg/Wcxx-compat-9.c: New testcase. From-SVN: r147544
-rw-r--r--gcc/ChangeLog16
-rw-r--r--gcc/c-typeck.c10
-rw-r--r--gcc/config/ia64/ia64.c6
-rw-r--r--gcc/cp/ChangeLog7
-rw-r--r--gcc/cp/class.c2
-rw-r--r--gcc/cp/decl.c2
-rw-r--r--gcc/cp/parser.c6
-rw-r--r--gcc/fortran/ChangeLog14
-rw-r--r--gcc/fortran/decl.c2
-rw-r--r--gcc/fortran/dump-parse-tree.c6
-rw-r--r--gcc/fortran/interface.c6
-rw-r--r--gcc/fortran/module.c6
-rw-r--r--gcc/fortran/symbol.c5
-rw-r--r--gcc/fortran/trans-io.c4
-rw-r--r--gcc/fortran/trans-types.c9
-rw-r--r--gcc/passes.c2
-rw-r--r--gcc/plugin.c4
-rw-r--r--gcc/reginfo.c4
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.dg/Wcxx-compat-9.c21
-rw-r--r--gcc/tree.c8
21 files changed, 108 insertions, 36 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 1bcf207..ac58e2b 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,19 @@
+2009-05-14 Ian Lance Taylor <iant@google.com>
+
+ * passes.c (finish_optimization_passes): Change i to int.
+ * plugin.c (plugins_active_p): Change event to int.
+ (dump_active_plugins): Likewise.
+ * reginfo.c (invalid_mode_change_p): Change to to unsigned int.
+ Add cast.
+ * tree.c (tree_range_check_failed): Change c to unsigned int.
+ (omp_clause_range_check_failed): Likewise.
+ (build_common_builtin_nodes): Change mode to int. Add cast.
+ * config/ia64/ia64.c (is_emitted): Change r to unsigned int.
+ (ia64_hard_regno_rename_ok, ia64_eh_uses): Likewise.
+
+ * c-typeck.c (build_unary_op): If -Wc++-compat, warn about using
+ ++ or -- with a variable of enum type.
+
2009-05-14 Steven Bosscher <steven@gcc.gnu.org>
PR driver/40144
diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c
index f1dc7a3..13cd3e3 100644
--- a/gcc/c-typeck.c
+++ b/gcc/c-typeck.c
@@ -3267,6 +3267,16 @@ build_unary_op (location_t location,
: lv_decrement)))
return error_mark_node;
+ if (warn_cxx_compat && TREE_CODE (TREE_TYPE (arg)) == ENUMERAL_TYPE)
+ {
+ if (code == PREINCREMENT_EXPR || code == POSTINCREMENT_EXPR)
+ warning_at (location, OPT_Wc___compat,
+ "increment of enumeration value is invalid in C++");
+ else
+ warning_at (location, OPT_Wc___compat,
+ "decrement of enumeration value is invalid in C++");
+ }
+
/* Ensure the argument is fully folded inside any SAVE_EXPR. */
arg = c_fully_fold (arg, false, NULL);
diff --git a/gcc/config/ia64/ia64.c b/gcc/config/ia64/ia64.c
index 1f433a6..b44f530 100644
--- a/gcc/config/ia64/ia64.c
+++ b/gcc/config/ia64/ia64.c
@@ -1943,7 +1943,7 @@ get_reg (enum ia64_frame_regs r)
static bool
is_emitted (int regno)
{
- enum ia64_frame_regs r;
+ unsigned int r;
for (r = reg_fp; r < number_of_ia64_frame_regs; r++)
if (emitted_frame_related_regs[r] == regno)
@@ -3657,7 +3657,7 @@ int
ia64_hard_regno_rename_ok (int from, int to)
{
/* Don't clobber any of the registers we reserved for the prologue. */
- enum ia64_frame_regs r;
+ unsigned int r;
for (r = reg_fp; r <= reg_save_ar_lc; r++)
if (to == current_frame_info.r[r]
@@ -9317,7 +9317,7 @@ ia64_epilogue_uses (int regno)
int
ia64_eh_uses (int regno)
{
- enum ia64_frame_regs r;
+ unsigned int r;
if (! reload_completed)
return 0;
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 4b0bbee..1c6d583 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,10 @@
+2009-05-14 Ian Lance Taylor <iant@google.com>
+
+ * class.c (layout_class_type): Change itk to unsigned int.
+ * decl.c (finish_enum): Change itk to unsigned int.
+ * parser.c (cp_parser_check_decl_spec): Change ds to int. Remove
+ casts.
+
2009-05-13 David Mandelin <dmandelin@mozilla.com>:
* decl.c (duplicate_decls): Preserve parameter attributes.
diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index 6ad9415..ad50a4e 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -4864,7 +4864,7 @@ layout_class_type (tree t, tree *virtuals_p)
if (DECL_C_BIT_FIELD (field)
&& INT_CST_LT (TYPE_SIZE (type), DECL_SIZE (field)))
{
- integer_type_kind itk;
+ unsigned int itk;
tree integer_type;
bool was_unnamed_p = false;
/* We must allocate the bits as if suitably aligned for the
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index dab3e5c..ed76dc3 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -11033,7 +11033,7 @@ finish_enum (tree enumtype)
int lowprec;
int highprec;
int precision;
- integer_type_kind itk;
+ unsigned int itk;
tree underlying_type = NULL_TREE;
bool fixed_underlying_type_p
= ENUM_UNDERLYING_TYPE (enumtype) != NULL_TREE;
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 1fc9469..0b73472 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -2149,11 +2149,11 @@ static void
cp_parser_check_decl_spec (cp_decl_specifier_seq *decl_specs,
location_t location)
{
- cp_decl_spec ds;
+ int ds;
for (ds = ds_first; ds != ds_last; ++ds)
{
- unsigned count = decl_specs->specs[(int)ds];
+ unsigned count = decl_specs->specs[ds];
if (count < 2)
continue;
/* The "long" specifier is a special case because of "long long". */
@@ -2183,7 +2183,7 @@ cp_parser_check_decl_spec (cp_decl_specifier_seq *decl_specs,
"__complex",
"__thread"
};
- error ("%Hduplicate %qs", &location, decl_spec_names[(int)ds]);
+ error ("%Hduplicate %qs", &location, decl_spec_names[ds]);
}
}
}
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 864b095..5871239 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,17 @@
+2009-05-14 Ian Lance Taylor <iant@google.com>
+
+ * decl.c (match_attr_spec): Change d to unsigned int.
+ * dump-parse-tree.c (show_namespace): Change op to int. Add cast.
+ * interface.c (gfc_check_interfaces): Change i to int. Add casts.
+ * module.c (read_module): Change i to int. Add cast.
+ (write_module): Change i to int.
+ * symbol.c (gfc_get_namespace): Change in to int.
+ (gfc_free_namespace): Change i to int.
+ * trans-io.c (gfc_build_io_library_fndecls): Change ptype to
+ unsigned int. Add cast.
+ * trans-types.c (gfc_init_kinds): Change mode to unsigned int.
+ Add casts.
+
2009-05-14 Daniel Kraft <d@domob.eu>
PR fortran/40045
diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c
index 6c6fa45..a5261b8 100644
--- a/gcc/fortran/decl.c
+++ b/gcc/fortran/decl.c
@@ -2815,7 +2815,7 @@ match_attr_spec (void)
locus start, seen_at[NUM_DECL];
int seen[NUM_DECL];
- decl_types d;
+ unsigned int d;
const char *attr;
match m;
gfc_try t;
diff --git a/gcc/fortran/dump-parse-tree.c b/gcc/fortran/dump-parse-tree.c
index e595e7f..26a8e08 100644
--- a/gcc/fortran/dump-parse-tree.c
+++ b/gcc/fortran/dump-parse-tree.c
@@ -1,5 +1,5 @@
/* Parse tree dumper
- Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008
+ Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009
Free Software Foundation, Inc.
Contributed by Steven Bosscher
@@ -1971,7 +1971,7 @@ show_namespace (gfc_namespace *ns)
{
gfc_interface *intr;
gfc_namespace *save;
- gfc_intrinsic_op op;
+ int op;
gfc_equiv *eq;
int i;
@@ -2021,7 +2021,7 @@ show_namespace (gfc_namespace *ns)
show_indent ();
fprintf (dumpfile, "Operator interfaces for %s:",
- gfc_op2string (op));
+ gfc_op2string ((gfc_intrinsic_op) op));
for (; intr; intr = intr->next)
fprintf (dumpfile, " %s", intr->sym->name);
diff --git a/gcc/fortran/interface.c b/gcc/fortran/interface.c
index ee1f528..f2d1465 100644
--- a/gcc/fortran/interface.c
+++ b/gcc/fortran/interface.c
@@ -1175,7 +1175,7 @@ gfc_check_interfaces (gfc_namespace *ns)
{
gfc_namespace *old_ns, *ns2;
char interface_name[100];
- gfc_intrinsic_op i;
+ int i;
old_ns = gfc_current_ns;
gfc_current_ns = ns;
@@ -1193,12 +1193,12 @@ gfc_check_interfaces (gfc_namespace *ns)
strcpy (interface_name, "intrinsic assignment operator");
else
sprintf (interface_name, "intrinsic '%s' operator",
- gfc_op2string (i));
+ gfc_op2string ((gfc_intrinsic_op) i));
if (check_interface0 (ns->op[i], interface_name))
continue;
- check_operator_interface (ns->op[i], i);
+ check_operator_interface (ns->op[i], (gfc_intrinsic_op) i);
for (ns2 = ns; ns2; ns2 = ns2->parent)
{
diff --git a/gcc/fortran/module.c b/gcc/fortran/module.c
index 4221c04..2a48f88 100644
--- a/gcc/fortran/module.c
+++ b/gcc/fortran/module.c
@@ -4017,7 +4017,7 @@ read_module (void)
module_locus operator_interfaces, user_operators;
const char *p;
char name[GFC_MAX_SYMBOL_LEN + 1];
- gfc_intrinsic_op i;
+ int i;
int ambiguous, j, nuse, symbol;
pointer_info *info, *q;
gfc_use_rename *u;
@@ -4225,7 +4225,7 @@ read_module (void)
if (only_flag)
{
- u = find_use_operator (i);
+ u = find_use_operator ((gfc_intrinsic_op) i);
if (u == NULL)
{
@@ -4677,7 +4677,7 @@ write_symtree (gfc_symtree *st)
static void
write_module (void)
{
- gfc_intrinsic_op i;
+ int i;
/* Write the operator interfaces. */
mio_lparen ();
diff --git a/gcc/fortran/symbol.c b/gcc/fortran/symbol.c
index 67240ad..81473a4 100644
--- a/gcc/fortran/symbol.c
+++ b/gcc/fortran/symbol.c
@@ -2197,7 +2197,7 @@ gfc_get_namespace (gfc_namespace *parent, int parent_types)
{
gfc_namespace *ns;
gfc_typespec *ts;
- gfc_intrinsic_op in;
+ int in;
int i;
ns = XCNEW (gfc_namespace);
@@ -3088,7 +3088,7 @@ void
gfc_free_namespace (gfc_namespace *ns)
{
gfc_namespace *p, *q;
- gfc_intrinsic_op i;
+ int i;
if (ns == NULL)
return;
@@ -4494,4 +4494,3 @@ gfc_get_tbp_symtree (gfc_symtree **root, const char *name)
return result;
}
-
diff --git a/gcc/fortran/trans-io.c b/gcc/fortran/trans-io.c
index 24f156e..0acf632 100644
--- a/gcc/fortran/trans-io.c
+++ b/gcc/fortran/trans-io.c
@@ -279,7 +279,7 @@ gfc_build_io_library_fndecls (void)
tree gfc_intio_type_node;
tree parm_type, dt_parm_type;
HOST_WIDE_INT pad_size;
- enum ioparam_type ptype;
+ unsigned int ptype;
types[IOPARM_type_int4] = gfc_int4_type_node = gfc_get_int_type (4);
types[IOPARM_type_intio] = gfc_intio_type_node
@@ -302,7 +302,7 @@ gfc_build_io_library_fndecls (void)
TYPE_ALIGN (gfc_get_int_type (gfc_intio_kind)));
for (ptype = IOPARM_ptype_common; ptype < IOPARM_ptype_num; ptype++)
- gfc_build_st_parameter (ptype, types);
+ gfc_build_st_parameter ((enum ioparam_type) ptype, types);
/* Define the transfer functions. */
diff --git a/gcc/fortran/trans-types.c b/gcc/fortran/trans-types.c
index 694d0e2..ae72e8d 100644
--- a/gcc/fortran/trans-types.c
+++ b/gcc/fortran/trans-types.c
@@ -252,7 +252,7 @@ void init_c_interop_kinds (void)
void
gfc_init_kinds (void)
{
- enum machine_mode mode;
+ unsigned int mode;
int i_index, r_index, kind;
bool saw_i4 = false, saw_i8 = false;
bool saw_r4 = false, saw_r8 = false, saw_r16 = false;
@@ -261,7 +261,7 @@ gfc_init_kinds (void)
{
int kind, bitsize;
- if (!targetm.scalar_mode_supported_p (mode))
+ if (!targetm.scalar_mode_supported_p ((enum machine_mode) mode))
continue;
/* The middle end doesn't support constants larger than 2*HWI.
@@ -309,12 +309,13 @@ gfc_init_kinds (void)
for (r_index = 0, mode = MIN_MODE_FLOAT; mode <= MAX_MODE_FLOAT; mode++)
{
- const struct real_format *fmt = REAL_MODE_FORMAT (mode);
+ const struct real_format *fmt =
+ REAL_MODE_FORMAT ((enum machine_mode) mode);
int kind;
if (fmt == NULL)
continue;
- if (!targetm.scalar_mode_supported_p (mode))
+ if (!targetm.scalar_mode_supported_p ((enum machine_mode) mode))
continue;
/* Only let float/double/long double go through because the fortran
diff --git a/gcc/passes.c b/gcc/passes.c
index b66ed1d..945cf5c 100644
--- a/gcc/passes.c
+++ b/gcc/passes.c
@@ -239,7 +239,7 @@ rest_of_type_compilation (tree type, int toplev)
void
finish_optimization_passes (void)
{
- enum tree_dump_index i;
+ int i;
struct dump_file_info *dfi;
char *name;
diff --git a/gcc/plugin.c b/gcc/plugin.c
index 923f0ad..9362e6a 100644
--- a/gcc/plugin.c
+++ b/gcc/plugin.c
@@ -767,7 +767,7 @@ print_plugins_help (FILE *file, const char *indent)
bool
plugins_active_p (void)
{
- enum plugin_event event;
+ int event;
for (event = PLUGIN_PASS_MANAGER_SETUP; event < PLUGIN_EVENT_LAST; event++)
if (plugin_callbacks[event])
@@ -783,7 +783,7 @@ plugins_active_p (void)
void
dump_active_plugins (FILE *file)
{
- enum plugin_event event;
+ int event;
if (!plugins_active_p ())
return;
diff --git a/gcc/reginfo.c b/gcc/reginfo.c
index 5ab67ef..1f8684f 100644
--- a/gcc/reginfo.c
+++ b/gcc/reginfo.c
@@ -1322,7 +1322,7 @@ invalid_mode_change_p (unsigned int regno,
enum machine_mode from)
{
struct subregs_of_mode_node dummy, *node;
- enum machine_mode to;
+ unsigned int to;
unsigned char mask;
gcc_assert (subregs_of_mode);
@@ -1335,7 +1335,7 @@ invalid_mode_change_p (unsigned int regno,
mask = 1 << (regno & 7);
for (to = VOIDmode; to < NUM_MACHINE_MODES; to++)
if (node->modes[to] & mask)
- if (CANNOT_CHANGE_MODE_CLASS (from, to, rclass))
+ if (CANNOT_CHANGE_MODE_CLASS (from, (enum machine_mode) to, rclass))
return true;
return false;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index f22bcce..2733cb5 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2009-05-14 Ian Lance Taylor <iant@google.com>
+
+ * gcc.dg/Wcxx-compat-9.c: New testcase.
+
2009-05-14 Janus Weil <janus@gcc.gnu.org>
PR fortran/39996
diff --git a/gcc/testsuite/gcc.dg/Wcxx-compat-9.c b/gcc/testsuite/gcc.dg/Wcxx-compat-9.c
new file mode 100644
index 0000000..8a3867c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Wcxx-compat-9.c
@@ -0,0 +1,21 @@
+/* { dg-do compile } */
+/* { dg-options "-Wc++-compat" } */
+
+enum e { FIRST, LAST };
+
+extern void f2 (enum e);
+
+void
+f1 ()
+{
+ enum e v;
+
+ for (v = FIRST; v < LAST; ++v) /* { dg-warning "invalid in C\[+\]\[+\]" } */
+ f2 (v);
+ for (v = FIRST; v < LAST; v++) /* { dg-warning "invalid in C\[+\]\[+\]" } */
+ f2 (v);
+ for (v = LAST; v > FIRST; --v) /* { dg-warning "invalid in C\[+\]\[+\]" } */
+ f2 (v);
+ for (v = LAST; v > FIRST; v--) /* { dg-warning "invalid in C\[+\]\[+\]" } */
+ f2 (v);
+}
diff --git a/gcc/tree.c b/gcc/tree.c
index 876f43a..5ed55c1 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -7147,7 +7147,7 @@ tree_range_check_failed (const_tree node, const char *file, int line,
{
char *buffer;
unsigned length = 0;
- enum tree_code c;
+ unsigned int c;
for (c = c1; c <= c2; ++c)
length += 4 + strlen (tree_code_name[c]);
@@ -7208,7 +7208,7 @@ omp_clause_range_check_failed (const_tree node, const char *file, int line,
{
char *buffer;
unsigned length = 0;
- enum omp_clause_code c;
+ unsigned int c;
for (c = c1; c <= c2; ++c)
length += 4 + strlen (omp_clause_code_name[c]);
@@ -7811,7 +7811,7 @@ build_common_builtin_nodes (void)
complex. Further, we can do slightly better with folding these
beasties if the real and complex parts of the arguments are separate. */
{
- enum machine_mode mode;
+ int mode;
for (mode = MIN_MODE_COMPLEX_FLOAT; mode <= MAX_MODE_COMPLEX_FLOAT; ++mode)
{
@@ -7820,7 +7820,7 @@ build_common_builtin_nodes (void)
enum built_in_function mcode, dcode;
tree type, inner_type;
- type = lang_hooks.types.type_for_mode (mode, 0);
+ type = lang_hooks.types.type_for_mode ((enum machine_mode) mode, 0);
if (type == NULL)
continue;
inner_type = TREE_TYPE (type);