This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[mips patch rfa] avoid -Wpadded warnings for eabi.
- From: cgd at broadcom dot com
- To: gcc-patches at gcc dot gnu dot org
- Cc: echristo at redhat dot com
- Date: 26 Jun 2003 22:06:10 -0700
- Subject: [mips patch rfa] avoid -Wpadded warnings for eabi.
for eabi targets (e.g. mipsisa64-elf), -Wpadded would warn for every
file due to implicit padding in the internally-defined va_list
structure.
solution: make padding explicit. (This is done by at least one other
port.) The twist here is that i use an array, rather than a single
element of type 'short' or something, because the amount of padding
needed depends on compiler flags (-mlong32/-mlong64). AFAIK that
should be OK.
tested using sources dated 2003-06-23, mipsisa64-elf on mips64 sim,
with -mips64 and -mips32 multilibs. only change in testsuite results
is the -Wpadded test, which goes from FAIL -> PASS.
(I've never done stuff w/ trees before, so i hope i didn't botch
their usage... 8-)
cgd
===================================================================
2003-06-26 Chris Demetriou <cgd@broadcom.com>
* config/mips/mips.c (mips_build_va_list): Make padding in
va_list structure explicit to avoid -Wpadded warnings.
Index: config/mips/mips.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/mips/mips.c,v
retrieving revision 1.283
diff -u -p -r1.283 mips.c
--- config/mips/mips.c 19 Jun 2003 21:47:16 -0000 1.283
+++ config/mips/mips.c 27 Jun 2003 05:00:24 -0000
@@ -4273,7 +4273,8 @@ mips_build_va_list ()
{
if (EABI_FLOAT_VARARGS_P)
{
- tree f_ovfl, f_gtop, f_ftop, f_goff, f_foff, record;
+ tree f_ovfl, f_gtop, f_ftop, f_goff, f_foff, f_res, record;
+ tree array, index;
record = make_node (RECORD_TYPE);
@@ -4287,19 +4288,26 @@ mips_build_va_list ()
unsigned_char_type_node);
f_foff = build_decl (FIELD_DECL, get_identifier ("__fpr_offset"),
unsigned_char_type_node);
-
+ /* Explicitly pad with 2 bytes (or 6, if TARGET_LONG64), so that
+ -Wpadded won't warn on every user file. */
+ index = build_int_2 (TARGET_LONG64 ? 5 : 1, 0);
+ array = build_array_type (unsigned_char_type_node,
+ build_index_type (index));
+ f_res = build_decl (FIELD_DECL, get_identifier ("__reserved"), array);
DECL_FIELD_CONTEXT (f_ovfl) = record;
DECL_FIELD_CONTEXT (f_gtop) = record;
DECL_FIELD_CONTEXT (f_ftop) = record;
DECL_FIELD_CONTEXT (f_goff) = record;
DECL_FIELD_CONTEXT (f_foff) = record;
+ DECL_FIELD_CONTEXT (f_res) = record;
TYPE_FIELDS (record) = f_ovfl;
TREE_CHAIN (f_ovfl) = f_gtop;
TREE_CHAIN (f_gtop) = f_ftop;
TREE_CHAIN (f_ftop) = f_goff;
TREE_CHAIN (f_goff) = f_foff;
+ TREE_CHAIN (f_foff) = f_res;
layout_type (record);
return record;