C++ PATCH: More tiny cleanups

Mark Mitchell mark@codesourcery.com
Mon Jul 8 02:16:00 GMT 2002


This patch eliminates the unneeded used_extern_spec variable and
places the declaration for have_extern_spec where it belongs.

Tested on i686-pc-linux-gnu, applied on the mainline.

--
Mark Mitchell                   mark@codesourcery.com
CodeSourcery, LLC               http://www.codesourcery.com

2002-07-08  Mark Mitchell  <mark@codesourcery.com>

	* cp-tree.h (have_extern_spec): Declare it
	* decl.c (have_extern_spec): Define it.
	(start_decl): Eliminate use of used_extern_spec.
	(start_function): Likewise.
	* parse.y (have_extern_spec): Remove declaration.
	(used_extern_spec): Likewise.
	(frob_specs): Eliminate use of used_extern_spec.
	(.hush_warning): Likewise.

Index: cp-tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/cp-tree.h,v
retrieving revision 1.726
diff -c -p -r1.726 cp-tree.h
*** cp-tree.h	8 Jul 2002 02:25:17 -0000	1.726
--- cp-tree.h	8 Jul 2002 07:47:23 -0000
*************** extern tree declare_global_var          
*** 3904,3909 ****
--- 3904,3910 ----
  extern void register_dtor_fn                    PARAMS ((tree));
  extern tmpl_spec_kind current_tmpl_spec_kind    PARAMS ((int));
  extern tree cp_fname_init			PARAMS ((const char *));
+ extern bool have_extern_spec;
  
  /* in decl2.c */
  extern int check_java_method			PARAMS ((tree));
Index: decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/decl.c,v
retrieving revision 1.916
diff -c -p -r1.916 decl.c
*** decl.c	1 Jul 2002 23:07:12 -0000	1.916
--- decl.c	8 Jul 2002 07:47:26 -0000
*************** static enum deprecated_states deprecated
*** 306,311 ****
--- 306,316 ----
     being flagged as deprecated or reported as using deprecated
     types.  */
  int adding_implicit_members = 0;
+ 
+ /* True if a declaration with an `extern' linkage specifier is being
+    processed.  */
+ bool have_extern_spec;
+ 
  
  /* For each binding contour we allocate a binding_level structure
     which records the names defined in that contour.
*************** start_decl (declarator, declspecs, initi
*** 7193,7200 ****
    tree decl;
    register tree type, tem;
    tree context;
-   extern int have_extern_spec;
-   extern int used_extern_spec;
  
  #if 0
    /* See code below that used this.  */
--- 7198,7203 ----
*************** start_decl (declarator, declspecs, initi
*** 7202,7212 ****
  #endif
  
    /* This should only be done once on the top most decl.  */
!   if (have_extern_spec && !used_extern_spec)
      {
        declspecs = tree_cons (NULL_TREE, get_identifier ("extern"),
  			     declspecs);
!       used_extern_spec = 1;
      }
  
    /* An object declared as __attribute__((deprecated)) suppresses
--- 7205,7215 ----
  #endif
  
    /* This should only be done once on the top most decl.  */
!   if (have_extern_spec)
      {
        declspecs = tree_cons (NULL_TREE, get_identifier ("extern"),
  			     declspecs);
!       have_extern_spec = false;
      }
  
    /* An object declared as __attribute__((deprecated)) suppresses
*************** start_function (declspecs, declarator, a
*** 13501,13508 ****
    tree ctype = NULL_TREE;
    tree fntype;
    tree restype;
-   extern int have_extern_spec;
-   extern int used_extern_spec;
    int doing_friend = 0;
    struct cp_binding_level *bl;
    tree current_function_parms;
--- 13504,13509 ----
*************** start_function (declspecs, declarator, a
*** 13512,13521 ****
    my_friendly_assert (TREE_CHAIN (void_list_node) == NULL_TREE, 161);
  
    /* This should only be done once on the top most decl.  */
!   if (have_extern_spec && !used_extern_spec)
      {
        declspecs = tree_cons (NULL_TREE, get_identifier ("extern"), declspecs);
!       used_extern_spec = 1;
      }
  
    if (flags & SF_PRE_PARSED)
--- 13513,13522 ----
    my_friendly_assert (TREE_CHAIN (void_list_node) == NULL_TREE, 161);
  
    /* This should only be done once on the top most decl.  */
!   if (have_extern_spec)
      {
        declspecs = tree_cons (NULL_TREE, get_identifier ("extern"), declspecs);
!       have_extern_spec = false;
      }
  
    if (flags & SF_PRE_PARSED)
Index: parse.y
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/parse.y,v
retrieving revision 1.268
diff -c -p -r1.268 parse.y
*** parse.y	8 Jul 2002 02:25:18 -0000	1.268
--- parse.y	8 Jul 2002 07:47:27 -0000
*************** do {									\
*** 98,107 ****
     error message if the user supplies an empty conditional expression.  */
  static const char *cond_stmt_keyword;
  
- /* Nonzero if we have an `extern "C"' acting as an extern specifier.  */
- int have_extern_spec;
- int used_extern_spec;
- 
  /* List of types and structure classes of the current declaration.  */
  static GTY(()) tree current_declspecs;
  
--- 98,103 ----
*************** frob_specs (specs_attrs, lookups)
*** 163,169 ****
    if (current_declspecs
        && TREE_CODE (current_declspecs) != TREE_LIST)
      current_declspecs = build_tree_list (NULL_TREE, current_declspecs);
!   if (have_extern_spec && !used_extern_spec)
      {
        /* We have to indicate that there is an "extern", but that it
           was part of a language specifier.  For instance,
--- 159,165 ----
    if (current_declspecs
        && TREE_CODE (current_declspecs) != TREE_LIST)
      current_declspecs = build_tree_list (NULL_TREE, current_declspecs);
!   if (have_extern_spec)
      {
        /* We have to indicate that there is an "extern", but that it
           was part of a language specifier.  For instance,
*************** frob_specs (specs_attrs, lookups)
*** 174,180 ****
        current_declspecs = tree_cons (error_mark_node,
  				     get_identifier ("extern"),
  				     current_declspecs);
!       used_extern_spec = 1;
      }
  }
  
--- 170,176 ----
        current_declspecs = tree_cons (error_mark_node,
  				     get_identifier ("extern"),
  				     current_declspecs);
!       have_extern_spec = false;
      }
  }
  
*************** extdefs_opt:
*** 510,521 ****
  	;
  
  .hush_warning:
! 		{ have_extern_spec = 1;
! 		  used_extern_spec = 0;
  		  $<ttype>$ = NULL_TREE; }
  	;
  .warning_ok:
! 		{ have_extern_spec = 0; }
  	;
  
  extension:
--- 506,516 ----
  	;
  
  .hush_warning:
! 		{ have_extern_spec = true;
  		  $<ttype>$ = NULL_TREE; }
  	;
  .warning_ok:
! 		{ have_extern_spec = false; }
  	;
  
  extension:



More information about the Gcc-patches mailing list