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]

C patch to change some function parameters to bool


This patch changes some boolean parameters in the C front end from int
to bool, to get such changes out of the pending declarators cleanup
patch.

Bootstrapped with no regressions on i686-pc-linux-gnu.  Applied to
mainline.

-- 
Joseph S. Myers               http://www.srcf.ucam.org/~jsm28/gcc/
    jsm@polyomino.org.uk (personal mail)
    jsm28@gcc.gnu.org (Bugzilla assignments and CCs)

2004-08-21  Joseph S. Myers  <jsm@polyomino.org.uk>

	* c-decl.c (build_array_declarator, set_array_declarator_type,
	start_decl, grokdeclarator, grokparms): Change boolean parameters
	to type bool.
	* c-tree.h (build_array_declarator, set_array_declarator_type,
	start_decl): Update prototypes.
	* c-decl.c, c-parse.in: All callers changed.

diff -rupN GCC.orig/gcc/c-decl.c GCC/gcc/c-decl.c
--- GCC.orig/gcc/c-decl.c	2004-08-16 20:33:22.000000000 +0000
+++ GCC/gcc/c-decl.c	2004-08-21 10:18:46.000000000 +0000
@@ -383,8 +383,8 @@ static GTY(()) tree static_dtors;
 /* Forward declarations.  */
 static tree lookup_name_in_scope (tree, struct c_scope *);
 static tree c_make_fname_decl (tree, int);
-static tree grokdeclarator (tree, tree, enum decl_context, int, tree *);
-static tree grokparms (tree, int);
+static tree grokdeclarator (tree, tree, enum decl_context, bool, tree *);
+static tree grokparms (tree, bool);
 static void layout_array_type (tree);
 
 /* States indicating how grokdeclarator() should handle declspecs marked
@@ -2624,17 +2624,18 @@ shadow_tag_warned (tree declspecs, int w
 /* Construct an array declarator.  EXPR is the expression inside [], or
    NULL_TREE.  QUALS are the type qualifiers inside the [] (to be applied
    to the pointer to which a parameter array is converted).  STATIC_P is
-   nonzero if "static" is inside the [], zero otherwise.  VLA_UNSPEC_P
-   is nonzero is the array is [*], a VLA of unspecified length which is
+   true if "static" is inside the [], false otherwise.  VLA_UNSPEC_P
+   is true if the array is [*], a VLA of unspecified length which is
    nevertheless a complete type (not currently implemented by GCC),
-   zero otherwise.  The declarator is constructed as an ARRAY_REF
+   false otherwise.  The declarator is constructed as an ARRAY_REF
    (to be decoded by grokdeclarator), whose operand 0 is what's on the
    left of the [] (filled by in set_array_declarator_type) and operand 1
    is the expression inside; whose TREE_TYPE is the type qualifiers and
    which has TREE_STATIC set if "static" is used.  */
 
 tree
-build_array_declarator (tree expr, tree quals, int static_p, int vla_unspec_p)
+build_array_declarator (tree expr, tree quals, bool static_p,
+			bool vla_unspec_p)
 {
   tree decl;
   decl = build_nt (ARRAY_REF, NULL_TREE, expr, NULL_TREE, NULL_TREE);
@@ -2654,13 +2655,13 @@ build_array_declarator (tree expr, tree 
 
 /* Set the type of an array declarator.  DECL is the declarator, as
    constructed by build_array_declarator; TYPE is what appears on the left
-   of the [] and goes in operand 0.  ABSTRACT_P is nonzero if it is an
-   abstract declarator, zero otherwise; this is used to reject static and
+   of the [] and goes in operand 0.  ABSTRACT_P is true if it is an
+   abstract declarator, false otherwise; this is used to reject static and
    type qualifiers in abstract declarators, where they are not in the
    C99 grammar.  */
 
 tree
-set_array_declarator_type (tree decl, tree type, int abstract_p)
+set_array_declarator_type (tree decl, tree type, bool abstract_p)
 {
   TREE_OPERAND (decl, 0) = type;
   if (abstract_p && (TREE_TYPE (decl) != NULL_TREE || TREE_STATIC (decl)))
@@ -2680,7 +2681,7 @@ groktypename (tree type_name)
 
   split_specs_attrs (TREE_PURPOSE (type_name), &specs, &attrs);
 
-  type_name = grokdeclarator (TREE_VALUE (type_name), specs, TYPENAME, 0,
+  type_name = grokdeclarator (TREE_VALUE (type_name), specs, TYPENAME, false,
 			     NULL);
 
   /* Apply attributes.  */
@@ -2698,7 +2699,7 @@ groktypename_in_parm_context (tree type_
     return type_name;
   return grokdeclarator (TREE_VALUE (type_name),
 			 TREE_PURPOSE (type_name),
-			 PARM, 0, NULL);
+			 PARM, false, NULL);
 }
 
 /* Decode a declarator in an ordinary declaration or data definition.
@@ -2717,7 +2718,7 @@ groktypename_in_parm_context (tree type_
    grokfield and not through here.  */
 
 tree
-start_decl (tree declarator, tree declspecs, int initialized, tree attributes)
+start_decl (tree declarator, tree declspecs, bool initialized, tree attributes)
 {
   tree decl;
   tree tem;
@@ -3162,7 +3163,7 @@ push_parm_decl (tree parm)
 
   decl = grokdeclarator (TREE_VALUE (TREE_PURPOSE (parm)),
 			 TREE_PURPOSE (TREE_PURPOSE (parm)),
-			 PARM, 0, NULL);
+			 PARM, false, NULL);
   decl_attributes (&decl, TREE_VALUE (parm), 0);
 
   decl = pushdecl (decl);
@@ -3445,7 +3446,7 @@ check_bitfield_type_and_width (tree *typ
      TYPENAME if for a typename (in a cast or sizeof).
       Don't make a DECL node; just return the ..._TYPE node.
      FIELD for a struct or union field; make a FIELD_DECL.
-   INITIALIZED is 1 if the decl has an initializer.
+   INITIALIZED is true if the decl has an initializer.
    WIDTH is non-NULL for bit-fields, and is a pointer to an INTEGER_CST node
    representing the width of the bit-field.
 
@@ -3458,7 +3459,7 @@ check_bitfield_type_and_width (tree *typ
 
 static tree
 grokdeclarator (tree declarator, tree declspecs,
-		enum decl_context decl_context, int initialized, tree *width)
+		enum decl_context decl_context, bool initialized, tree *width)
 {
   int specbits = 0;
   tree spec;
@@ -4729,12 +4730,12 @@ grokdeclarator (tree declarator, tree de
 
    Return a list of arg types to use in the FUNCTION_TYPE for this function.
 
-   FUNCDEF_FLAG is nonzero for a function definition, 0 for
+   FUNCDEF_FLAG is true for a function definition, false for
    a mere declaration.  A nonempty identifier-list gets an error message
-   when FUNCDEF_FLAG is zero.  */
+   when FUNCDEF_FLAG is false.  */
 
 static tree
-grokparms (tree arg_info, int funcdef_flag)
+grokparms (tree arg_info, bool funcdef_flag)
 {
   tree arg_types = ARG_INFO_TYPES (arg_info);
 
@@ -5135,7 +5136,7 @@ grokfield (tree declarator, tree declspe
 	}
     }
 
-  value = grokdeclarator (declarator, declspecs, FIELD, 0,
+  value = grokdeclarator (declarator, declspecs, FIELD, false,
 			  width ? &width : NULL);
 
   finish_decl (value, NULL_TREE, NULL_TREE);
@@ -5726,7 +5727,7 @@ start_function (tree declspecs, tree dec
      error message in c_finish_bc_stmt.  */
   c_break_label = c_cont_label = size_zero_node;
 
-  decl1 = grokdeclarator (declarator, declspecs, FUNCDEF, 1, NULL);
+  decl1 = grokdeclarator (declarator, declspecs, FUNCDEF, true, NULL);
 
   /* If the declarator is not suitable for a function definition,
      cause a syntax error.  */
diff -rupN GCC.orig/gcc/c-parse.in GCC/gcc/c-parse.in
--- GCC.orig/gcc/c-parse.in	2004-08-16 09:32:37.000000000 +0000
+++ GCC/gcc/c-parse.in	2004-08-21 10:13:41.000000000 +0000
@@ -1389,7 +1389,7 @@ notype_initdecls:
 
 initdcl:
 	  declarator maybeasm maybe_attribute '='
-		{ $<ttype>$ = start_decl ($1, current_declspecs, 1,
+		{ $<ttype>$ = start_decl ($1, current_declspecs, true,
 					  chainon ($3, all_prefix_attributes));
 		  start_init ($<ttype>$, $2, global_bindings_p ()); }
 	  init
@@ -1398,7 +1398,7 @@ initdcl:
 		  maybe_warn_string_init (TREE_TYPE ($<ttype>5), $6);
 		  finish_decl ($<ttype>5, $6.value, $2); }
 	| declarator maybeasm maybe_attribute
-		{ tree d = start_decl ($1, current_declspecs, 0,
+		{ tree d = start_decl ($1, current_declspecs, false,
 				       chainon ($3, all_prefix_attributes));
 		  finish_decl (d, NULL_TREE, $2);
                 }
@@ -1406,7 +1406,7 @@ initdcl:
 
 notype_initdcl:
 	  notype_declarator maybeasm maybe_attribute '='
-		{ $<ttype>$ = start_decl ($1, current_declspecs, 1,
+		{ $<ttype>$ = start_decl ($1, current_declspecs, true,
 					  chainon ($3, all_prefix_attributes));
 		  start_init ($<ttype>$, $2, global_bindings_p ()); }
 	  init
@@ -1415,7 +1415,7 @@ notype_initdcl:
 		  maybe_warn_string_init (TREE_TYPE ($<ttype>5), $6);
 		  finish_decl ($<ttype>5, $6.value, $2); }
 	| notype_declarator maybeasm maybe_attribute
-		{ tree d = start_decl ($1, current_declspecs, 0,
+		{ tree d = start_decl ($1, current_declspecs, false,
 				       chainon ($3, all_prefix_attributes));
 		  finish_decl (d, NULL_TREE, $2); }
 	;
@@ -1624,7 +1624,7 @@ after_type_declarator:
 	| after_type_declarator '(' parmlist_or_identifiers  %prec '.'
 		{ $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
 	| after_type_declarator array_declarator  %prec '.'
-		{ $$ = set_array_declarator_type ($2, $1, 0); }
+		{ $$ = set_array_declarator_type ($2, $1, false); }
 	| '*' maybe_type_quals_attrs after_type_declarator  %prec UNARY
 		{ $$ = make_pointer_declarator ($2, $3); }
 	| TYPENAME
@@ -1646,7 +1646,7 @@ parm_declarator_starttypename:
 	  parm_declarator_starttypename '(' parmlist_or_identifiers  %prec '.'
 		{ $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
 	| parm_declarator_starttypename array_declarator  %prec '.'
-		{ $$ = set_array_declarator_type ($2, $1, 0); }
+		{ $$ = set_array_declarator_type ($2, $1, false); }
 	| TYPENAME
 @@ifobjc
 	| OBJECTNAME
@@ -1657,7 +1657,7 @@ parm_declarator_nostarttypename:
 	  parm_declarator_nostarttypename '(' parmlist_or_identifiers  %prec '.'
 		{ $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
 	| parm_declarator_nostarttypename array_declarator  %prec '.'
-		{ $$ = set_array_declarator_type ($2, $1, 0); }
+		{ $$ = set_array_declarator_type ($2, $1, false); }
 	| '*' maybe_type_quals_attrs parm_declarator_starttypename  %prec UNARY
 		{ $$ = make_pointer_declarator ($2, $3); }
 	| '*' maybe_type_quals_attrs parm_declarator_nostarttypename  %prec UNARY
@@ -1677,7 +1677,7 @@ notype_declarator:
 	| '*' maybe_type_quals_attrs notype_declarator  %prec UNARY
 		{ $$ = make_pointer_declarator ($2, $3); }
 	| notype_declarator array_declarator  %prec '.'
-		{ $$ = set_array_declarator_type ($2, $1, 0); }
+		{ $$ = set_array_declarator_type ($2, $1, false); }
 	| IDENTIFIER
 	;
 
@@ -1946,27 +1946,27 @@ direct_absdcl1:
 	| direct_absdcl1 '(' parmlist
 		{ $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
 	| direct_absdcl1 array_declarator
-		{ $$ = set_array_declarator_type ($2, $1, 1); }
+		{ $$ = set_array_declarator_type ($2, $1, true); }
 	| '(' parmlist
 		{ $$ = build_nt (CALL_EXPR, NULL_TREE, $2, NULL_TREE); }
 	| array_declarator
-		{ $$ = set_array_declarator_type ($1, NULL_TREE, 1); }
+		{ $$ = set_array_declarator_type ($1, NULL_TREE, true); }
 	;
 
 /* The [...] part of a declarator for an array type.  */
 
 array_declarator:
 	'[' maybe_type_quals_attrs expr_no_commas ']'
-		{ $$ = build_array_declarator ($3.value, $2, 0, 0); }
+		{ $$ = build_array_declarator ($3.value, $2, false, false); }
 	| '[' maybe_type_quals_attrs ']'
-		{ $$ = build_array_declarator (NULL_TREE, $2, 0, 0); }
+		{ $$ = build_array_declarator (NULL_TREE, $2, false, false); }
 	| '[' maybe_type_quals_attrs '*' ']'
-		{ $$ = build_array_declarator (NULL_TREE, $2, 0, 1); }
+		{ $$ = build_array_declarator (NULL_TREE, $2, false, true); }
 	| '[' STATIC maybe_type_quals_attrs expr_no_commas ']'
-		{ $$ = build_array_declarator ($4.value, $3, 1, 0); }
+		{ $$ = build_array_declarator ($4.value, $3, true, false); }
 	/* declspecs_nosc_nots is a synonym for type_quals_attrs.  */
 	| '[' declspecs_nosc_nots STATIC expr_no_commas ']'
-		{ $$ = build_array_declarator ($4.value, $2, 1, 0); }
+		{ $$ = build_array_declarator ($4.value, $2, true, false); }
 	;
 
 /* A nonempty series of declarations and statements (possibly followed by
diff -rupN GCC.orig/gcc/c-tree.h GCC/gcc/c-tree.h
--- GCC.orig/gcc/c-tree.h	2004-07-21 23:43:02.000000000 +0000
+++ GCC/gcc/c-tree.h	2004-08-21 10:13:13.000000000 +0000
@@ -163,7 +163,7 @@ extern void c_expand_body (tree);
 extern void c_init_decl_processing (void);
 extern void c_dup_lang_specific_decl (tree);
 extern void c_print_identifier (FILE *, tree, int);
-extern tree build_array_declarator (tree, tree, int, int);
+extern tree build_array_declarator (tree, tree, bool, bool);
 extern tree build_enumerator (tree, tree);
 extern void check_for_loop_decls (void);
 extern void mark_forward_parm_decls (void);
@@ -188,14 +188,14 @@ extern void c_push_function_context (str
 extern void c_pop_function_context (struct function *);
 extern void push_parm_decl (tree);
 extern tree pushdecl_top_level (tree);
-extern tree set_array_declarator_type (tree, tree, int);
+extern tree set_array_declarator_type (tree, tree, bool);
 extern tree builtin_function (const char *, tree, int, enum built_in_class,
 			      const char *, tree);
 extern void shadow_tag (tree);
 extern void shadow_tag_warned (tree, int);
 extern tree start_enum (tree);
 extern int  start_function (tree, tree, tree);
-extern tree start_decl (tree, tree, int, tree);
+extern tree start_decl (tree, tree, bool, tree);
 extern tree start_struct (enum tree_code, tree);
 extern void store_parm_decls (void);
 extern tree xref_tag (enum tree_code, tree);


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