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]

[PATCH INSTALLED]: const typedefs part 6/N


A few more constifications.

Tested on sparc-sun-solaris2.10, no regressions.  Installed.

		--Kaveh


2007-07-24  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>

	* cselib.c (entry_and_rtx_equal_p): Constify.
	* gengtype.c (output_mangled_typename, write_types, write_local):
	Likewise.
	* gengtype.h (const_type_p): New.
	* see.c (eq_descriptor_extension, hash_descriptor_extension):
	Constify.
	* tlink.c (scan_linker_output): De-constify.
	* tree-ssa-loop-im.c (memref_eq): Constify.
	* tree-ssa-structalias.c (const_shared_bitmap_info_t): New.
	(shared_bitmap_hash, shared_bitmap_eq): Constify.

cp:
	* parser.c (cp_parser_string_literal, cp_parser_sizeof_operand):
	Constify.

diff -rup orig/egcc-SVN20070721/gcc/cp/parser.c egcc-SVN20070721/gcc/cp/parser.c
--- orig/egcc-SVN20070721/gcc/cp/parser.c	2007-07-13 12:23:18.000000000 -0400
+++ egcc-SVN20070721/gcc/cp/parser.c	2007-07-24 19:55:10.357909872 -0400
@@ -2896,7 +2896,7 @@ cp_parser_string_literal (cp_parser *par
 	{
 	  cp_lexer_consume_token (parser->lexer);
 	  count++;
-	  str.text = (unsigned char *)TREE_STRING_POINTER (tok->u.value);
+	  str.text = (const unsigned char *)TREE_STRING_POINTER (tok->u.value);
 	  str.len = TREE_STRING_LENGTH (tok->u.value);
 	  if (tok->type == CPP_WSTRING)
 	    wide = true;
@@ -17111,6 +17111,7 @@ cp_parser_sizeof_operand (cp_parser* par
   static const char *format;
   tree expr = NULL_TREE;
   const char *saved_message;
+  char *tmp;
   bool saved_integral_constant_expression_p;
   bool saved_non_integral_constant_expression_p;
   bool pack_expansion_p = false;
@@ -17123,12 +17124,11 @@ cp_parser_sizeof_operand (cp_parser* par
      old message.  */
   saved_message = parser->type_definition_forbidden_message;
   /* And create the new one.  */
-  parser->type_definition_forbidden_message
-    = XNEWVEC (const char, strlen (format)
+  parser->type_definition_forbidden_message = tmp
+    = XNEWVEC (char, strlen (format)
 	       + strlen (IDENTIFIER_POINTER (ridpointers[keyword]))
 	       + 1 /* `\0' */);
-  sprintf ((char *) parser->type_definition_forbidden_message,
-	   format, IDENTIFIER_POINTER (ridpointers[keyword]));
+  sprintf (tmp, format, IDENTIFIER_POINTER (ridpointers[keyword]));

   /* The restrictions on constant-expressions do not apply inside
      sizeof expressions.  */
@@ -17204,7 +17204,7 @@ cp_parser_sizeof_operand (cp_parser* par
   --skip_evaluation;

   /* Free the message we created.  */
-  free ((char *) parser->type_definition_forbidden_message);
+  free (tmp);
   /* And restore the old one.  */
   parser->type_definition_forbidden_message = saved_message;
   parser->integral_constant_expression_p
diff -rup orig/egcc-SVN20070721/gcc/cselib.c egcc-SVN20070721/gcc/cselib.c
--- orig/egcc-SVN20070721/gcc/cselib.c	2007-07-07 23:02:55.000000000 -0400
+++ egcc-SVN20070721/gcc/cselib.c	2007-07-24 21:31:06.845474548 -0400
@@ -234,7 +234,7 @@ static int
 entry_and_rtx_equal_p (const void *entry, const void *x_arg)
 {
   struct elt_loc_list *l;
-  const cselib_val *v = (const cselib_val *) entry;
+  const cselib_val *const v = (const cselib_val *) entry;
   rtx x = (rtx) x_arg;
   enum machine_mode mode = GET_MODE (x);

diff -rup orig/egcc-SVN20070721/gcc/gengtype.c egcc-SVN20070721/gcc/gengtype.c
--- orig/egcc-SVN20070721/gcc/gengtype.c	2007-06-11 23:02:50.000000000 -0400
+++ egcc-SVN20070721/gcc/gengtype.c	2007-07-24 20:17:25.546892903 -0400
@@ -1751,7 +1751,7 @@ struct write_types_data

 static void output_escaped_param (struct walk_type_data *d,
 				  const char *, const char *);
-static void output_mangled_typename (outf_p, type_p);
+static void output_mangled_typename (outf_p, const_type_p);
 static void walk_type (type_p t, struct walk_type_data *d);
 static void write_func_for_structure
      (type_p orig_s, type_p s, type_p * param,
@@ -1804,7 +1804,7 @@ struct walk_type_data
 /* Print a mangled name representing T to OF.  */

 static void
-output_mangled_typename (outf_p of, type_p t)
+output_mangled_typename (outf_p of, const_type_p t)
 {
   if (t == NULL)
     oprintf (of, "Z");
@@ -2580,7 +2580,7 @@ write_types (type_p structures, type_p p
 	for (opt = s->u.s.opt; opt; opt = opt->next)
 	  if (strcmp (opt->name, "ptr_alias") == 0)
 	    {
-	      type_p t = (type_p) opt->info;
+	      const_type_p const t = (const_type_p) opt->info;
 	      if (t->kind == TYPE_STRUCT
 		  || t->kind == TYPE_UNION
 		  || t->kind == TYPE_LANG_STRUCT)
@@ -2759,7 +2759,7 @@ write_local (type_p structures, type_p p
 	for (opt = s->u.s.opt; opt; opt = opt->next)
 	  if (strcmp (opt->name, "ptr_alias") == 0)
 	    {
-	      type_p t = (type_p) opt->info;
+	      const_type_p const t = (const_type_p) opt->info;
 	      if (t->kind == TYPE_STRUCT
 		  || t->kind == TYPE_UNION
 		  || t->kind == TYPE_LANG_STRUCT)
diff -rup orig/egcc-SVN20070721/gcc/gengtype.h egcc-SVN20070721/gcc/gengtype.h
--- orig/egcc-SVN20070721/gcc/gengtype.h	2007-03-26 20:02:42.000000000 -0500
+++ egcc-SVN20070721/gcc/gengtype.h	2007-07-24 20:11:46.659002815 -0400
@@ -31,6 +31,7 @@ struct fileloc {
 /* Data types handed around within, but opaque to, the lexer and parser.  */
 typedef struct pair *pair_p;
 typedef struct type *type_p;
+typedef const struct type *const_type_p;
 typedef struct options *options_p;

 /* Variables used to communicate between the lexer and the parser.  */
diff -rup orig/egcc-SVN20070721/gcc/see.c egcc-SVN20070721/gcc/see.c
--- orig/egcc-SVN20070721/gcc/see.c	2007-07-13 12:23:44.000000000 -0400
+++ egcc-SVN20070721/gcc/see.c	2007-07-24 19:58:01.574322697 -0400
@@ -933,12 +933,12 @@ hash_del_properties (void *p)
 static int
 eq_descriptor_extension (const void *p1, const void *p2)
 {
-  const rtx insn = (rtx) p1;
-  const rtx element = (rtx) p2;
+  const_rtx const insn = (const_rtx) p1;
+  const_rtx const element = (const_rtx) p2;
   rtx set1 = single_set (insn);
   rtx dest_reg1;
   rtx set2 = NULL;
-  rtx dest_reg2 = NULL;
+  const_rtx dest_reg2 = NULL;

   gcc_assert (set1 && element && (REG_P (element) || INSN_P (element)));

@@ -962,7 +962,7 @@ eq_descriptor_extension (const void *p1,
 static hashval_t
 hash_descriptor_extension (const void *p)
 {
-  const rtx r = (rtx) p;
+  const_rtx const r = (const_rtx) p;
   rtx set, lhs;

   if (r && REG_P (r))
diff -rup orig/egcc-SVN20070721/gcc/tlink.c egcc-SVN20070721/gcc/tlink.c
--- orig/egcc-SVN20070721/gcc/tlink.c	2007-02-24 13:39:02.000000000 -0500
+++ egcc-SVN20070721/gcc/tlink.c	2007-07-24 19:08:07.803815311 -0400
@@ -658,7 +658,7 @@ scan_linker_output (const char *fname)
       if (! sym && ! end)
 	/* Try a mangled name in quotes.  */
 	{
-	  const char *oldq = q + 1;
+	  char *oldq = q + 1;
 	  demangled *dem = 0;
 	  q = 0;

diff -rup orig/egcc-SVN20070721/gcc/tree-ssa-loop-im.c egcc-SVN20070721/gcc/tree-ssa-loop-im.c
--- orig/egcc-SVN20070721/gcc/tree-ssa-loop-im.c	2007-06-12 23:02:02.000000000 -0400
+++ egcc-SVN20070721/gcc/tree-ssa-loop-im.c	2007-07-24 21:32:11.634587002 -0400
@@ -1294,7 +1294,7 @@ memref_hash (const void *obj)
 static int
 memref_eq (const void *obj1, const void *obj2)
 {
-  const struct mem_ref *mem1 = (const struct mem_ref *) obj1;
+  const struct mem_ref *const mem1 = (const struct mem_ref *) obj1;

   return operand_equal_p (mem1->mem, (tree) obj2, 0);
 }
diff -rup orig/egcc-SVN20070721/gcc/tree-ssa-structalias.c egcc-SVN20070721/gcc/tree-ssa-structalias.c
--- orig/egcc-SVN20070721/gcc/tree-ssa-structalias.c	2007-06-20 23:02:37.000000000 -0400
+++ egcc-SVN20070721/gcc/tree-ssa-structalias.c	2007-07-24 20:24:19.885948375 -0400
@@ -4266,6 +4266,7 @@ typedef struct shared_bitmap_info
   bitmap pt_vars;
   hashval_t hashcode;
 } *shared_bitmap_info_t;
+typedef const struct shared_bitmap_info *const_shared_bitmap_info_t;

 static htab_t shared_bitmap_table;

@@ -4274,7 +4275,7 @@ static htab_t shared_bitmap_table;
 static hashval_t
 shared_bitmap_hash (const void *p)
 {
-  const shared_bitmap_info_t bi = (shared_bitmap_info_t) p;
+  const_shared_bitmap_info_t const bi = (const_shared_bitmap_info_t) p;
   return bi->hashcode;
 }

@@ -4283,8 +4284,8 @@ shared_bitmap_hash (const void *p)
 static int
 shared_bitmap_eq (const void *p1, const void *p2)
 {
-  const shared_bitmap_info_t sbi1 = (shared_bitmap_info_t) p1;
-  const shared_bitmap_info_t sbi2 = (shared_bitmap_info_t) p2;
+  const_shared_bitmap_info_t const sbi1 = (const_shared_bitmap_info_t) p1;
+  const_shared_bitmap_info_t const sbi2 = (const_shared_bitmap_info_t) p2;
   return bitmap_equal_p (sbi1->pt_vars, sbi2->pt_vars);
 }


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