This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Patch to remove promoting integer type bool as a parameter
- To: gcc-patches at gcc dot gnu dot org
- Subject: Patch to remove promoting integer type bool as a parameter
- From: "Kaveh R. Ghazi" <ghazi at caip dot rutgers dot edu>
- Date: Wed, 2 May 2001 17:42:49 -0400 (EDT)
- Cc: rth at redhat dot com
The recent patch to treat `bool' as a promoting integer type exposed
some new -pedantic warnings which I believe reveal a legitimate issue.
> hash.c:93: warning: promoted argument `create' doesn't match prototype
> config/i386/i386.c:2262: warning: promoted argument `maybe_eh_return' doesn't match prototype
> config/i386/i386.c:2567: warning: promoted argument `maybe_eh_return' doesn't match prototype
> tlink.c:133: warning: promoted argument `create' doesn't match prototype
> tlink.c:205: warning: promoted argument `create' doesn't match prototype
The problem here is that a parameter of e.g. type `char' cannot appear
in a prototype along with an old style function definition. Doing so
is a GNUC extension. Now that bool is promoted the same warning (and
underlying issue) that affects a char is also relevant for a bool.
Furthermore, char is the fallback for bool for stage1 compilers that
don't support booleans. The consequence is that some strict ISO C89
compilers will not build stage1 as of now.
AFAIK, using bool is okay for variables and function return-types,
just not as parameters in the C frontend and the backend. Using bool
as a parameter (like any GNUC extension) is okay for the other
language frontends, so I left alone any of those uses.
The following patch eliminates the warnings. The same issue affects
the branch as well as the trunk, (except the bits in i386.c.) Ok to
install on both?
Thanks,
--Kaveh
2001-05-02 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* i386.c (ix86_emit_restore_regs_using_mov, ix86_save_reg): Change
`bool' parameter to `int'.
* hash.c (hash_lookup): Likewise.
* hash.h (hash_lookup): Likewise.
* tlink.c (symbol_hash_lookup, demangled_hash_lookup): Likewise.
diff -rup orig/egcs-CVS20010501/gcc/config/i386/i386.c egcs-CVS20010501/gcc/config/i386/i386.c
--- orig/egcs-CVS20010501/gcc/config/i386/i386.c Thu Apr 26 16:30:30 2001
+++ egcs-CVS20010501/gcc/config/i386/i386.c Wed May 2 17:06:12 2001
@@ -566,7 +566,7 @@ static int ix86_split_to_parts PARAMS ((
static int ix86_safe_length_prefix PARAMS ((rtx));
static int ix86_nsaved_regs PARAMS((void));
static void ix86_emit_save_regs PARAMS((void));
-static void ix86_emit_restore_regs_using_mov PARAMS ((rtx, int, bool));
+static void ix86_emit_restore_regs_using_mov PARAMS ((rtx, int, int));
static void ix86_emit_epilogue_esp_adjustment PARAMS((int));
static void ix86_set_move_mem_attrs_1 PARAMS ((rtx, rtx, rtx, rtx, rtx));
static void ix86_sched_reorder_pentium PARAMS((rtx *, rtx *));
@@ -606,7 +606,7 @@ static int ix86_fp_comparison_arithmetic
static int ix86_fp_comparison_fcomi_cost PARAMS ((enum rtx_code code));
static int ix86_fp_comparison_sahf_cost PARAMS ((enum rtx_code code));
static int ix86_fp_comparison_cost PARAMS ((enum rtx_code code));
-static int ix86_save_reg PARAMS ((int, bool));
+static int ix86_save_reg PARAMS ((int, int));
static void ix86_compute_frame_layout PARAMS ((struct ix86_frame *));
/* Sometimes certain combinations of command options do not make
@@ -2258,7 +2258,7 @@ gen_push (arg)
static int
ix86_save_reg (regno, maybe_eh_return)
int regno;
- bool maybe_eh_return;
+ int maybe_eh_return;
{
if (flag_pic
&& ! TARGET_64BIT
@@ -2563,7 +2563,7 @@ static void
ix86_emit_restore_regs_using_mov (pointer, offset, maybe_eh_return)
rtx pointer;
int offset;
- bool maybe_eh_return;
+ int maybe_eh_return;
{
int regno;
diff -rup orig/egcs-CVS20010501/gcc/hash.c egcs-CVS20010501/gcc/hash.c
--- orig/egcs-CVS20010501/gcc/hash.c Thu Mar 1 20:50:49 2001
+++ egcs-CVS20010501/gcc/hash.c Wed May 2 12:54:38 2001
@@ -87,7 +87,7 @@ struct hash_entry *
hash_lookup (table, key, create, copy)
struct hash_table *table;
hash_table_key key;
- bool create;
+ int create;
hash_table_key (*copy) PARAMS ((struct obstack* memory,
hash_table_key key));
{
diff -rup orig/egcs-CVS20010501/gcc/hash.h egcs-CVS20010501/gcc/hash.h
--- orig/egcs-CVS20010501/gcc/hash.h Thu Mar 1 20:50:49 2001
+++ egcs-CVS20010501/gcc/hash.h Wed May 2 12:54:50 2001
@@ -96,7 +96,7 @@ extern void hash_table_free PARAMS ((str
COPY is non-NULL, it is used to copy the KEY before storing it in
the hash table. */
extern struct hash_entry *hash_lookup
- PARAMS ((struct hash_table *, hash_table_key key, bool create,
+ PARAMS ((struct hash_table *, hash_table_key key, int create,
hash_table_key (*copy)(struct obstack*, hash_table_key)));
/* Base method for creating a hash table entry. */
diff -rup orig/egcs-CVS20010501/gcc/tlink.c egcs-CVS20010501/gcc/tlink.c
--- orig/egcs-CVS20010501/gcc/tlink.c Thu Mar 1 20:50:49 2001
+++ egcs-CVS20010501/gcc/tlink.c Wed May 2 17:05:11 2001
@@ -72,7 +72,7 @@ static struct hash_entry * symbol_hash_n
struct hash_table *,
hash_table_key));
static struct symbol_hash_entry * symbol_hash_lookup PARAMS ((const char *,
- bool));
+ int));
static struct hash_entry * file_hash_newfunc PARAMS ((struct hash_entry *,
struct hash_table *,
hash_table_key));
@@ -81,7 +81,7 @@ static struct hash_entry * demangled_has
struct hash_table *,
hash_table_key));
static struct demangled_hash_entry *
- demangled_hash_lookup PARAMS ((const char *, bool));
+ demangled_hash_lookup PARAMS ((const char *, int));
static void symbol_push PARAMS ((symbol *));
static symbol * symbol_pop PARAMS ((void));
static void file_push PARAMS ((file *));
@@ -129,7 +129,7 @@ symbol_hash_newfunc (entry, table, strin
static struct symbol_hash_entry *
symbol_hash_lookup (string, create)
const char *string;
- bool create;
+ int create;
{
return ((struct symbol_hash_entry *)
hash_lookup (&symbol_table, (const hash_table_key) string,
@@ -201,7 +201,7 @@ demangled_hash_newfunc (entry, table, st
static struct demangled_hash_entry *
demangled_hash_lookup (string, create)
const char *string;
- bool create;
+ int create;
{
return ((struct demangled_hash_entry *)
hash_lookup (&demangled_table, (const hash_table_key) string,