This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
PATCH: Allow Tru64 UNIX bootstrap with -Wc++-compat -Wcast-qual
- From: Rainer Orth <ro at techfak dot uni-bielefeld dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Tue, 9 Sep 2008 15:55:42 +0200 (MEST)
- Subject: PATCH: Allow Tru64 UNIX bootstrap with -Wc++-compat -Wcast-qual
Current mainline doesn't bootstrap on alpha-dec-osf5.1b due to a couple of
warnings in mips-tfile.c and mips-tdump.c:
/vol/gcc/src/gcc-dist/gcc/mips-tfile.c: In function 'parse_def':
/vol/gcc/src/gcc-dist/gcc/mips-tfile.c:2857: error: cast discards qualifiers from pointer target type
/vol/gcc/src/gcc-dist/gcc/mips-tfile.c:2913: error: cast discards qualifiers from pointer target type
/vol/gcc/src/gcc-dist/gcc/mips-tfile.c:2987: error: cast discards qualifiers from pointer target type
/vol/gcc/src/gcc-dist/gcc/mips-tfile.c: In function 'copy_object':
/vol/gcc/src/gcc-dist/gcc/mips-tfile.c:4472: error: request for implicit conversion from 'void *' to 'int *' not permitted in C++
/vol/gcc/src/gcc-dist/gcc/mips-tdump.c: In function 'print_symbol':
/vol/gcc/src/gcc-dist/gcc/mips-tdump.c:886: error: request for implicit conversion from 'void *' to 'struct scope_t *' not permitted in C++
/vol/gcc/src/gcc-dist/gcc/mips-tdump.c:940: error: request for implicit conversion from 'void *' to 'struct scope_t *' not permitted in C++
/vol/gcc/src/gcc-dist/gcc/mips-tdump.c:983: error: identifier 'class' conflicts with C++ keyword
/vol/gcc/src/gcc-dist/gcc/mips-tdump.c:985: error: identifier 'class' conflicts with C++ keyword
/vol/gcc/src/gcc-dist/gcc/mips-tdump.c:987: error: identifier 'class' conflicts with C++ keyword
/vol/gcc/src/gcc-dist/gcc/mips-tdump.c:989: error: identifier 'class' conflicts with C++ keyword
/vol/gcc/src/gcc-dist/gcc/mips-tdump.c:991: error: identifier 'class' conflicts with C++ keyword
/vol/gcc/src/gcc-dist/gcc/mips-tdump.c:993: error: identifier 'class' conflicts with C++ keyword
/vol/gcc/src/gcc-dist/gcc/mips-tdump.c:995: error: identifier 'class' conflicts with C++ keyword
/vol/gcc/src/gcc-dist/gcc/mips-tdump.c: In function 'read_tfile':
/vol/gcc/src/gcc-dist/gcc/mips-tdump.c:1349: error: request for implicit conversion from 'void *' to 'LINER *' not permitted in C++
/vol/gcc/src/gcc-dist/gcc/mips-tdump.c:1352: error: request for implicit conversion from 'void *' to 'struct DNR *' not permitted in C++
/vol/gcc/src/gcc-dist/gcc/mips-tdump.c:1355: error: request for implicit conversion from 'void *' to 'struct PDR *' not permitted in C++
/vol/gcc/src/gcc-dist/gcc/mips-tdump.c:1358: error: request for implicit conversion from 'void *' to 'struct SYMR *' not permitted in C++
/vol/gcc/src/gcc-dist/gcc/mips-tdump.c:1361: error: request for implicit conversion from 'void *' to 'OPTR *' not permitted in C++
/vol/gcc/src/gcc-dist/gcc/mips-tdump.c:1364: error: request for implicit conversion from 'void *' to 'union AUXU *' not permitted in C++
/vol/gcc/src/gcc-dist/gcc/mips-tdump.c:1367: error: request for implicit conversion from 'void *' to 'char *' not permitted in C++
/vol/gcc/src/gcc-dist/gcc/mips-tdump.c:1370: error: request for implicit conversion from 'void *' to 'char *' not permitted in C++
/vol/gcc/src/gcc-dist/gcc/mips-tdump.c:1373: error: request for implicit conversion from 'void *' to 'char *' not permitted in C++
/vol/gcc/src/gcc-dist/gcc/mips-tdump.c:1376: error: request for implicit conversion from 'void *' to 'struct FDR *' not permitted in C++
/vol/gcc/src/gcc-dist/gcc/mips-tdump.c:1379: error: request for implicit conversion from 'void *' to 'long unsigned int *' not permitted in C++
/vol/gcc/src/gcc-dist/gcc/mips-tdump.c:1382: error: request for implicit conversion from 'void *' to 'struct EXTR *' not permitted in C++
The following patch fixes this and allows the bootstrap to continue into
stage3.
Besides, I had to apply the patch from PR rtl-optimization/37333, which
seems to fix PR bootstrap/37426.
I've chosen to set -Wno-error for mips-tfile.c since the -Wcast-qual
warnings for the second strtol argument are hard to get rid of: if I remove
the const from all affected pointers and the parse_def argument, parse_def
doesn't match the func member signature in pseudo_ops_t.
Ok for mainline?
Rainer
-----------------------------------------------------------------------------
Rainer Orth, Faculty of Technology, Bielefeld University
Tue Sep 9 12:32:08 2008 Rainer Orth <ro@TechFak.Uni-Bielefeld.DE>
* Makefile.in (mips-tfile.o-warn): Don't error out on mips-tfile.c
warnings.
* mips-tfile.c (copy_object): Cast alloca result to int *.
* mips-tdump.c (print_symbol): Cast xmalloc return values to
proper types.
Rename class to sclass.
(read_tfile): Cast read_seek return values to proper types.
Cast xcalloc return value to proper type.
Index: Makefile.in
===================================================================
--- Makefile.in (revision 140108)
+++ Makefile.in (working copy)
@@ -185,6 +185,8 @@ bitmap.o-warn = -Wno-error
dominance.o-warn = -Wno-error
# graphite.c contains code calling cloog that has problems.
graphite.o-warn = -Wno-error
+# mips-tfile.c contains -Wcast-qual warnings.
+mips-tfile.o-warn = -Wno-error
# All warnings have to be shut off in stage1 if the compiler used then
# isn't gcc; configure determines that. WARN_CFLAGS will be either
Index: mips-tdump.c
===================================================================
--- mips-tdump.c (revision 140108)
+++ mips-tdump.c (working copy)
@@ -883,7 +883,7 @@ print_symbol (SYMR *sym_ptr, int number,
if (want_scope)
{
if (free_scope == (scope_t *) 0)
- scope_ptr = xmalloc (sizeof (scope_t));
+ scope_ptr = (scope_t *) xmalloc (sizeof (scope_t));
else
{
scope_ptr = free_scope;
@@ -937,7 +937,7 @@ print_symbol (SYMR *sym_ptr, int number,
if (want_scope)
{
if (free_scope == (scope_t *) 0)
- scope_ptr = xmalloc (sizeof (scope_t));
+ scope_ptr = (scope_t *) xmalloc (sizeof (scope_t));
else
{
scope_ptr = free_scope;
@@ -980,19 +980,19 @@ print_symbol (SYMR *sym_ptr, int number,
scope_ptr != (scope_t *) 0;
scope_ptr = scope_ptr->prev)
{
- const char *class;
+ const char *sclass;
if (scope_ptr->st == st_Proc || scope_ptr->st == st_StaticProc)
- class = "func.";
+ sclass = "func.";
else if (scope_ptr->st == st_File)
- class = "file";
+ sclass = "file";
else if (scope_ptr->st == st_Block && scope_ptr->sc == sc_Text)
- class = "block";
+ sclass = "block";
else if (scope_ptr->st == st_Block && scope_ptr->sc == sc_Info)
- class = "type";
+ sclass = "type";
else
- class = "???";
+ sclass = "???";
- printf (" %ld [%s]", scope_ptr->open_sym, class);
+ printf (" %ld [%s]", scope_ptr->open_sym, sclass);
}
printf ("\n");
}
@@ -1345,41 +1345,44 @@ read_tfile (void)
print_sym_hdr (&sym_hdr);
- lines = read_seek (NULL, sym_hdr.cbLine, sym_hdr.cbLineOffset,
- "Line numbers");
+ lines = (LINER *) read_seek (NULL, sym_hdr.cbLine, sym_hdr.cbLineOffset,
+ "Line numbers");
- dense_nums = read_seek (NULL, sym_hdr.idnMax * sizeof (DNR),
- sym_hdr.cbDnOffset, "Dense numbers");
+ dense_nums = (DNR *) read_seek (NULL, sym_hdr.idnMax * sizeof (DNR),
+ sym_hdr.cbDnOffset, "Dense numbers");
- proc_desc = read_seek (NULL, sym_hdr.ipdMax * sizeof (PDR),
- sym_hdr.cbPdOffset, "Procedure tables");
+ proc_desc = (PDR *) read_seek (NULL, sym_hdr.ipdMax * sizeof (PDR),
+ sym_hdr.cbPdOffset, "Procedure tables");
- l_symbols = read_seek (NULL, sym_hdr.isymMax * sizeof (SYMR),
- sym_hdr.cbSymOffset, "Local symbols");
+ l_symbols = (SYMR *) read_seek (NULL, sym_hdr.isymMax * sizeof (SYMR),
+ sym_hdr.cbSymOffset, "Local symbols");
- opt_symbols = read_seek (NULL, sym_hdr.ioptMax * sizeof (OPTR),
- sym_hdr.cbOptOffset, "Optimization symbols");
+ opt_symbols = (OPTR *) read_seek (NULL, sym_hdr.ioptMax * sizeof (OPTR),
+ sym_hdr.cbOptOffset,
+ "Optimization symbols");
- aux_symbols = read_seek (NULL, sym_hdr.iauxMax * sizeof (AUXU),
- sym_hdr.cbAuxOffset, "Auxiliary symbols");
+ aux_symbols = (AUXU *) read_seek (NULL, sym_hdr.iauxMax * sizeof (AUXU),
+ sym_hdr.cbAuxOffset, "Auxiliary symbols");
if (sym_hdr.iauxMax > 0)
- aux_used = xcalloc (sym_hdr.iauxMax, 1);
+ aux_used = (char *) xcalloc (sym_hdr.iauxMax, 1);
- l_strings = read_seek (NULL, sym_hdr.issMax,
- sym_hdr.cbSsOffset, "Local string table");
+ l_strings = (char *) read_seek (NULL, sym_hdr.issMax,
+ sym_hdr.cbSsOffset, "Local string table");
- e_strings = read_seek (NULL, sym_hdr.issExtMax,
- sym_hdr.cbSsExtOffset, "External string table");
+ e_strings = (char *) read_seek (NULL, sym_hdr.issExtMax,
+ sym_hdr.cbSsExtOffset,
+ "External string table");
- file_desc = read_seek (NULL, sym_hdr.ifdMax * sizeof (FDR),
- sym_hdr.cbFdOffset, "File tables");
+ file_desc = (FDR *) read_seek (NULL, sym_hdr.ifdMax * sizeof (FDR),
+ sym_hdr.cbFdOffset, "File tables");
- rfile_desc = read_seek (NULL, sym_hdr.crfd * sizeof (ulong),
- sym_hdr.cbRfdOffset, "Relative file tables");
+ rfile_desc = (ulong *) read_seek (NULL, sym_hdr.crfd * sizeof (ulong),
+ sym_hdr.cbRfdOffset,
+ "Relative file tables");
- e_symbols = read_seek (NULL, sym_hdr.iextMax * sizeof (EXTR),
- sym_hdr.cbExtOffset, "External symbols");
+ e_symbols = (EXTR *) read_seek (NULL, sym_hdr.iextMax * sizeof (EXTR),
+ sym_hdr.cbExtOffset, "External symbols");
}
Index: mips-tfile.c
===================================================================
--- mips-tfile.c (revision 140108)
+++ mips-tfile.c (working copy)
@@ -4469,7 +4469,7 @@ copy_object (void)
(in case there are duplicate filenames, we collapse them into one
file section, the MIPS assembler may or may not collapse them). */
- remap_file_number = alloca (sizeof (int) * orig_sym_hdr.ifdMax);
+ remap_file_number = (int *) alloca (sizeof (int) * orig_sym_hdr.ifdMax);
for (fd = delete_ifd; fd < orig_sym_hdr.ifdMax; fd++)
{