This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH]: clean up -Wc++-compat warnings from gcc files used in libgcc


On Fri, Jul 4, 2008 at 9:25 PM, Kaveh R. GHAZI <ghazi@caip.rutgers.edu> wrote:
> Although compiling libgcc doesn't use -Werror and doesn't hard stop, it
> still gets a bunch of new warnings from files in the gcc directory that
> use the gcc directory's warning flags.  This patch cleans up most the
> noise eminating from my recent warning flag additions.
>
> Bootstrapped on x86_64-unknown-linux-gnu, no regressions.
>
> Okay for mainline?

Why not add -Wno-c++-compat to the CFLAGS of these files instead?

Richard.

>                Thanks,
>                --Kaveh
>
>
> 2008-07-04  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
>
>        * config/i386/linux-unwind.h (x86_64_fallback_frame_state,
>        x86_fallback_frame_state): Fix -Wc++-compat warnings.
>        * emutls.c (emutls_destroy, __emutls_get_address): Likewise.
>        * unwind-dw2-fde.c (__register_frame_info_bases, __register_frame,
>        __register_frame_info_table_bases, __register_frame_table,
>        start_fde_sort): Likewise.
>        * unwind-dw2-fde.h (get_cie): Likewise.
>        * unwind-dw2.c (read_pointer, read_2u, read_2s, read_4u, read_4s,
>        read_8u, read_8s, execute_cfa_program): Likewise.
>
> diff -rup orig/egcc-SVN20080629/gcc/config/i386/linux-unwind.h egcc-SVN20080629/gcc/config/i386/linux-unwind.h
> --- orig/egcc-SVN20080629/gcc/config/i386/linux-unwind.h        2008-01-03 23:37:25.000000000 +0100
> +++ egcc-SVN20080629/gcc/config/i386/linux-unwind.h     2008-06-29 08:28:27.000000000 +0200
> @@ -43,7 +43,7 @@ static _Unwind_Reason_Code
>  x86_64_fallback_frame_state (struct _Unwind_Context *context,
>                             _Unwind_FrameState *fs)
>  {
> -  unsigned char *pc = context->ra;
> +  unsigned char *pc = (unsigned char *) context->ra;
>   struct sigcontext *sc;
>   long new_cfa;
>
> @@ -51,7 +51,7 @@ x86_64_fallback_frame_state (struct _Unw
>   if (*(unsigned char *)(pc+0) == 0x48
>       && *(unsigned long *)(pc+1) == 0x050f0000000fc0c7)
>     {
> -      struct ucontext *uc_ = context->cfa;
> +      struct ucontext *uc_ = (struct ucontext *) context->cfa;
>       /* The void * cast is necessary to avoid an aliasing warning.
>          The aliasing warning is correct, but should not be a problem
>          because it does not alias anything.  */
> @@ -121,7 +121,7 @@ static _Unwind_Reason_Code
>  x86_fallback_frame_state (struct _Unwind_Context *context,
>                          _Unwind_FrameState *fs)
>  {
> -  unsigned char *pc = context->ra;
> +  unsigned char *pc = (unsigned char *) context->ra;
>   struct sigcontext *sc;
>   long new_cfa;
>
> @@ -129,7 +129,7 @@ x86_fallback_frame_state (struct _Unwind
>   if (*(unsigned short *)(pc+0) == 0xb858
>       && *(unsigned int *)(pc+2) == 119
>       && *(unsigned short *)(pc+6) == 0x80cd)
> -    sc = context->cfa + 4;
> +    sc = (struct sigcontext *) (context->cfa + 4);
>   /* movl $__NR_rt_sigreturn,%eax ; int $0x80  */
>   else if (*(unsigned char *)(pc+0) == 0xb8
>           && *(unsigned int *)(pc+1) == 173
> @@ -141,7 +141,7 @@ x86_fallback_frame_state (struct _Unwind
>        void *puc;
>        struct siginfo info;
>        struct ucontext uc;
> -      } *rt_ = context->cfa;
> +      } *rt_ = (struct rt_sigframe *) context->cfa;
>       /* The void * cast is necessary to avoid an aliasing warning.
>          The aliasing warning is correct, but should not be a problem
>          because it does not alias anything.  */
> diff -rup orig/egcc-SVN20080629/gcc/emutls.c egcc-SVN20080629/gcc/emutls.c
> --- orig/egcc-SVN20080629/gcc/emutls.c  2008-01-03 23:37:34.000000000 +0100
> +++ egcc-SVN20080629/gcc/emutls.c       2008-06-29 08:19:25.000000000 +0200
> @@ -66,7 +66,7 @@ static pointer emutls_size;
>  static void
>  emutls_destroy (void *ptr)
>  {
> -  struct __emutls_array *arr = ptr;
> +  struct __emutls_array *arr = (struct __emutls_array *) ptr;
>   pointer size = arr->size;
>   pointer i;
>
> @@ -149,11 +149,12 @@ __emutls_get_address (struct __emutls_ob
>       __gthread_mutex_unlock (&emutls_mutex);
>     }
>
> -  struct __emutls_array *arr = __gthread_getspecific (emutls_key);
> +  struct __emutls_array *arr =
> +    (struct __emutls_array *) __gthread_getspecific (emutls_key);
>   if (__builtin_expect (arr == NULL, 0))
>     {
>       pointer size = offset + 32;
> -      arr = calloc (size, sizeof (void *));
> +      arr = (struct __emutls_array *) calloc (size, sizeof (void *));
>       if (arr == NULL)
>        abort ();
>       arr->size = size;
> @@ -165,7 +166,7 @@ __emutls_get_address (struct __emutls_ob
>       pointer size = orig_size * 2;
>       if (offset >= size)
>        size = offset + 32;
> -      arr = realloc (arr, size * sizeof (void *));
> +      arr = (struct __emutls_array *) realloc (arr, size * sizeof (void *));
>       if (arr == NULL)
>        abort ();
>       arr->size = size;
> @@ -178,7 +179,7 @@ __emutls_get_address (struct __emutls_ob
>   if (__builtin_expect (ret == NULL, 0))
>     {
>       ret = emutls_alloc (obj);
> -      arr->data[offset - 1] = ret;
> +      arr->data[offset - 1] = (void **) ret;
>     }
>   return ret;
>  #endif
> diff -rup orig/egcc-SVN20080629/gcc/unwind-dw2-fde.c egcc-SVN20080629/gcc/unwind-dw2-fde.c
> --- orig/egcc-SVN20080629/gcc/unwind-dw2-fde.c  2008-06-07 02:00:45.000000000 +0200
> +++ egcc-SVN20080629/gcc/unwind-dw2-fde.c       2008-06-29 08:31:26.000000000 +0200
> @@ -85,7 +85,7 @@ __register_frame_info_bases (const void
>   ob->pc_begin = (void *)-1;
>   ob->tbase = tbase;
>   ob->dbase = dbase;
> -  ob->u.single = begin;
> +  ob->u.single = (const struct dwarf_fde *) begin;
>   ob->s.i = 0;
>   ob->s.b.encoding = DW_EH_PE_omit;
>  #ifdef DWARF2_OBJECT_END_PTR_EXTENSION
> @@ -116,7 +116,7 @@ __register_frame (void *begin)
>   if (*(uword *) begin == 0)
>     return;
>
> -  ob = malloc (sizeof (struct object));
> +  ob = (struct object *) malloc (sizeof (struct object));
>   __register_frame_info (begin, ob);
>  }
>
> @@ -131,7 +131,7 @@ __register_frame_info_table_bases (void
>   ob->pc_begin = (void *)-1;
>   ob->tbase = tbase;
>   ob->dbase = dbase;
> -  ob->u.array = begin;
> +  ob->u.array = (struct dwarf_fde **) begin;
>   ob->s.i = 0;
>   ob->s.b.from_array = 1;
>   ob->s.b.encoding = DW_EH_PE_omit;
> @@ -154,7 +154,7 @@ __register_frame_info_table (void *begin
>  void
>  __register_frame_table (void *begin)
>  {
> -  struct object *ob = malloc (sizeof (struct object));
> +  struct object *ob = (struct object *) malloc (sizeof (struct object));
>   __register_frame_info_table (begin, ob);
>  }
>
> @@ -398,10 +398,10 @@ start_fde_sort (struct fde_accumulator *
>     return 0;
>
>   size = sizeof (struct fde_vector) + sizeof (const fde *) * count;
> -  if ((accu->linear = malloc (size)))
> +  if ((accu->linear = (struct fde_vector *) malloc (size)))
>     {
>       accu->linear->count = 0;
> -      if ((accu->erratic = malloc (size)))
> +      if ((accu->erratic = (struct fde_vector *) malloc (size)))
>        accu->erratic->count = 0;
>       return 1;
>     }
> diff -rup orig/egcc-SVN20080629/gcc/unwind-dw2-fde.h egcc-SVN20080629/gcc/unwind-dw2-fde.h
> --- orig/egcc-SVN20080629/gcc/unwind-dw2-fde.h  2008-01-03 23:37:34.000000000 +0100
> +++ egcc-SVN20080629/gcc/unwind-dw2-fde.h       2008-06-29 08:15:54.000000000 +0200
> @@ -160,7 +160,7 @@ typedef struct dwarf_fde fde;
>  static inline const struct dwarf_cie *
>  get_cie (const struct dwarf_fde *f)
>  {
> -  return (const void *)&f->CIE_delta - f->CIE_delta;
> +  return (const struct dwarf_cie *)((const void *)&f->CIE_delta - f->CIE_delta);
>  }
>
>  static inline const fde *
> diff -rup orig/egcc-SVN20080629/gcc/unwind-dw2.c egcc-SVN20080629/gcc/unwind-dw2.c
> --- orig/egcc-SVN20080629/gcc/unwind-dw2.c      2008-01-03 23:37:34.000000000 +0100
> +++ egcc-SVN20080629/gcc/unwind-dw2.c   2008-06-29 08:24:59.000000000 +0200
> @@ -104,7 +104,7 @@ static _Unwind_Reason_Code uw_frame_stat
>                                               _Unwind_FrameState *);
>
>  static inline void *
> -read_pointer (const void *p) { const union unaligned *up = p; return up->p; }
> +read_pointer (const void *p) { return ((const union unaligned *) p)->p; }
>
>  static inline int
>  read_1u (const void *p) { return *(const unsigned char *) p; }
> @@ -113,22 +113,22 @@ static inline int
>  read_1s (const void *p) { return *(const signed char *) p; }
>
>  static inline int
> -read_2u (const void *p) { const union unaligned *up = p; return up->u2; }
> +read_2u (const void *p) { return ((const union unaligned *) p)->u2; }
>
>  static inline int
> -read_2s (const void *p) { const union unaligned *up = p; return up->s2; }
> +read_2s (const void *p) { return ((const union unaligned *) p)->s2; }
>
>  static inline unsigned int
> -read_4u (const void *p) { const union unaligned *up = p; return up->u4; }
> +read_4u (const void *p) { return ((const union unaligned *) p)->u4; }
>
>  static inline int
> -read_4s (const void *p) { const union unaligned *up = p; return up->s4; }
> +read_4s (const void *p) { return ((const union unaligned *) p)->s4; }
>
>  static inline unsigned long
> -read_8u (const void *p) { const union unaligned *up = p; return up->u8; }
> +read_8u (const void *p) { return ((const union unaligned *) p)->u8; }
>
>  static inline unsigned long
> -read_8s (const void *p) { const union unaligned *up = p; return up->s8; }
> +read_8s (const void *p) { return ((const union unaligned *) p)->s8; }
>
>  static inline _Unwind_Word
>  _Unwind_IsSignalFrame (struct _Unwind_Context *context)
> @@ -964,7 +964,8 @@ execute_cfa_program (const unsigned char
>                unused_rs = unused_rs->prev;
>              }
>            else
> -             new_rs = alloca (sizeof (struct frame_state_reg_info));
> +             new_rs = (struct frame_state_reg_info *)
> +               alloca (sizeof (struct frame_state_reg_info));
>
>            *new_rs = fs->regs;
>            fs->regs.prev = new_rs;
>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]