This is the mail archive of the gcc@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: Question on -Werror usage in Makefiles...


Andreas Jaeger <aj@suse.de> writes:

> "Zack Weinberg" <zack@codesourcery.com> writes:
>
>> Andreas Jaeger <aj@suse.de> writes:
>>
>>> /cvs/gcc/gcc/crtstuff.c: In function `__do_global_dtors_aux':
>>>
>>> /cvs/gcc/gcc/crtstuff.c:282: warning: passing arg 1 of `__deregister_frame_info' discards qualifiers from pointer target type
>>> /cvs/gcc/gcc/crtstuff.c: In function `frame_dummy':
>>>
>>> /cvs/gcc/gcc/crtstuff.c:310: warning: passing arg 1 of `__register_frame_info' discards qualifiers from pointer target type
>>> make[2]: *** [crtbeginT.o] Error 1
>>>
>>> Is the following the right fix?   
>>>
>>> I'm bootstrapping/regtesting on x86_64-linux-gnu now,
>>>
>>> Andreas
>>>
>>> 2003-10-26  Andreas Jaeger  <aj@suse.de>
>>>
>>> 	* crtstuff.c (frame_dummy): Cast __EH_FRAME_BEGIN__ properly.
>>> 	(__do_global_dtors_aux): Likewise.
>>
>> __EH_FRAME_BEGIN__ points into a read-only section, so better to
>> change the prototypes of __deregister_frame_info{,_bases},
>> __register_frame_info{,_bases}, if at all possible.
>
> It should be possible - but is a major surgery of unwind-dw2-fde.*
> since that variable is passed around again...
>
> So, let's ask the experts first whether there's any objection for
> changing it before I try it...

Nobody answered - so I tried it...

Below is just the first part of the diff.  It shows that major surgery
is needed if the const is put through everything and no cast is done.
I finally failed with:
static inline void
fde_insert (struct fde_accumulator *accu, fde *this_fde)
{
  if (accu->linear)
    accu->linear->array[accu->linear->count++] = this_fde;
}

I had to change the second parameter to const and then the assignment
didn't work anymore :-(

So, we should go with my previous patch that casts crtstuff.c IMO.

What do others think?

Andreas

============================================================
Index: gcc/crtstuff.c
--- gcc/crtstuff.c	28 Oct 2003 03:47:36 -0000	1.63
+++ gcc/crtstuff.c	29 Oct 2003 20:40:39 -0000
@@ -120,14 +120,14 @@ call_ ## FUNC (void)					\
    
 /* References to __register_frame_info and __deregister_frame_info should
    be weak in this file if at all possible.  */
-extern void __register_frame_info (void *, struct object *)
+extern void __register_frame_info (const void *, struct object *)
 				  TARGET_ATTRIBUTE_WEAK;
-extern void __register_frame_info_bases (void *, struct object *,
+extern void __register_frame_info_bases (const void *, struct object *,
 					 void *, void *)
 				  TARGET_ATTRIBUTE_WEAK;
-extern void *__deregister_frame_info (void *)
+extern void *__deregister_frame_info (const void *)
 				     TARGET_ATTRIBUTE_WEAK;
-extern void *__deregister_frame_info_bases (void *)
+extern void *__deregister_frame_info_bases (const void *)
 				     TARGET_ATTRIBUTE_WEAK;
 extern void __do_global_ctors_1 (void);
 
============================================================
Index: gcc/unwind-dw2-fde.c
--- gcc/unwind-dw2-fde.c	19 Jul 2003 14:47:14 -0000	1.25
+++ gcc/unwind-dw2-fde.c	29 Oct 2003 20:40:39 -0000
@@ -1,5 +1,5 @@
 /* Subroutines needed for unwinding stack frames for exception handling.  */
-/* Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
    Contributed by Jason Merrill <jason@cygnus.com>.
 
 This file is part of GCC.
@@ -74,7 +74,7 @@ init_object_mutex_once (void)
 /* Called from crtbegin.o to register the unwind info for an object.  */
 
 void
-__register_frame_info_bases (void *begin, struct object *ob,
+__register_frame_info_bases (const void *begin, struct object *ob,
 			     void *tbase, void *dbase)
 {
   /* If .eh_frame is empty, don't register at all.  */
@@ -101,7 +101,7 @@ __register_frame_info_bases (void *begin
 }
 
 void
-__register_frame_info (void *begin, struct object *ob)
+__register_frame_info (const void *begin, struct object *ob)
 {
   __register_frame_info_bases (begin, ob, 0, 0);
 }
@@ -170,7 +170,7 @@ __register_frame_table (void *begin)
    implements __register_frame_info_bases.  */
 
 void *
-__deregister_frame_info_bases (void *begin)
+__deregister_frame_info_bases (const void *begin)
 {
   struct object **p;
   struct object *ob = 0;
@@ -220,7 +220,7 @@ __deregister_frame_info_bases (void *beg
 }
 
 void *
-__deregister_frame_info (void *begin)
+__deregister_frame_info (const void *begin)
 {
   return __deregister_frame_info_bases (begin);
 }
@@ -407,7 +407,7 @@ start_fde_sort (struct fde_accumulator *
 }
 
 static inline void
-fde_insert (struct fde_accumulator *accu, fde *this_fde)
+fde_insert (struct fde_accumulator *accu, const fde *this_fde)
 {
   if (accu->linear)
     accu->linear->array[accu->linear->count++] = this_fde;
@@ -595,7 +595,7 @@ end_fde_sort (struct object *ob, struct 
    encountered along the way.  */
 
 static size_t
-classify_object_over_fdes (struct object *ob, fde *this_fde)
+classify_object_over_fdes (struct object *ob, const fde *this_fde)
 {
   struct dwarf_cie *last_cie = 0;
   size_t count = 0;
@@ -650,7 +650,7 @@ classify_object_over_fdes (struct object
 }
 
 static void
-add_fdes (struct object *ob, struct fde_accumulator *accu, fde *this_fde)
+add_fdes (struct object *ob, struct fde_accumulator *accu, const fde *this_fde)
 {
   struct dwarf_cie *last_cie = 0;
   int encoding = ob->s.b.encoding;
============================================================
Index: gcc/unwind-dw2-fde.h
--- gcc/unwind-dw2-fde.h	24 Jan 2003 01:46:50 -0000	1.11
+++ gcc/unwind-dw2-fde.h	29 Oct 2003 20:40:39 -0000
@@ -1,5 +1,5 @@
 /* Subroutines needed for unwinding stack frames for exception handling.  */
-/* Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002
+/* Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003
    Free Software Foundation, Inc.
    Contributed by Jason Merrill <jason@cygnus.com>.
 
@@ -43,7 +43,7 @@ struct object
   void *tbase;
   void *dbase;
   union {
-    struct dwarf_fde *single;
+    const struct dwarf_fde *single;
     struct dwarf_fde **array;
     struct fde_vector *sort;
   } u;
@@ -90,16 +90,16 @@ struct dwarf_eh_bases
 };
 
 
-extern void __register_frame_info_bases (void *, struct object *,
+extern void __register_frame_info_bases (const void *, struct object *,
 					 void *, void *);
-extern void __register_frame_info (void *, struct object *);
+extern void __register_frame_info (const void *, struct object *);
 extern void __register_frame (void *);
 extern void __register_frame_info_table_bases (void *, struct object *,
 					       void *, void *);
 extern void __register_frame_info_table (void *, struct object *);
 extern void __register_frame_table (void *);
-extern void *__deregister_frame_info (void *);
-extern void *__deregister_frame_info_bases (void *);
+extern void *__deregister_frame_info (const void *);
+extern void *__deregister_frame_info_bases (const void *);
 extern void __deregister_frame (void *);
 

@@ -152,13 +152,13 @@ typedef struct dwarf_fde fde;
 /* Locate the CIE for a given FDE.  */
 
 static inline struct dwarf_cie *
-get_cie (struct dwarf_fde *f)
+get_cie (const struct dwarf_fde *f)
 {
   return (void *)&f->CIE_delta - f->CIE_delta;
 }
 
 static inline fde *
-next_fde (fde *f)
+next_fde (const fde *f)
 {
   return (fde *) ((char *) f + f->length + sizeof (f->length));
 }
@@ -166,7 +166,7 @@ next_fde (fde *f)
 extern fde * _Unwind_Find_FDE (void *, struct dwarf_eh_bases *);
 
 static inline int
-last_fde (struct object *obj __attribute__ ((__unused__)), fde *f)
+last_fde (struct object *obj __attribute__ ((__unused__)), const fde *f)
 {
 #ifdef DWARF2_OBJECT_END_PTR_EXTENSION
   return (char *)f == obj->fde_end || f->length == 0;

-- 
 Andreas Jaeger, aj@suse.de, http://www.suse.de/~aj
  SuSE Linux AG, Deutschherrnstr. 15-19, 90429 Nürnberg, Germany
   GPG fingerprint = 93A3 365E CE47 B889 DF7F  FED1 389A 563C C272 A126

Attachment: pgp00000.pgp
Description: PGP signature


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