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]

(C) local externs patch


The paradigm in the C frontend appears to have been that local externs
were only important in as far as they declared something in an outer
scope, so we weren't emitting debugging information for them.  But
this is wrong; they affect lookup just like any other local
declaration, and therefore should go into the debugging information.
This patch is a followup to the earlier DECL_ABSTRACT_ORIGIN changes.

2000-08-27  Jason Merrill  <jason@redhat.com>

	* c-decl.c (duplicate_decls): Don't set TREE_STATIC or clear
	DECL_EXTERNAL on a local extern.  Don't set DECL_IGNORED_P or
	TREE_ASM_WRITTEN, either.
	(finish_decl): Adjust.

Index: c-decl.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/c-decl.c,v
retrieving revision 1.146
diff -c -p -r1.146 c-decl.c
*** c-decl.c	2000/08/25 00:58:25	1.146
--- c-decl.c	2000/08/28 01:28:57
*************** duplicate_decls (newdecl, olddecl, diffe
*** 1947,1954 ****
      }
    if (DECL_EXTERNAL (newdecl))
      {
!       TREE_STATIC (newdecl) = TREE_STATIC (olddecl);
!       DECL_EXTERNAL (newdecl) = DECL_EXTERNAL (olddecl);
        /* An extern decl does not override previous storage class.  */
        TREE_PUBLIC (newdecl) = TREE_PUBLIC (olddecl);
        if (! DECL_EXTERNAL (newdecl))
--- 1947,1957 ----
      }
    if (DECL_EXTERNAL (newdecl))
      {
!       if (! different_binding_level)
! 	{
! 	  TREE_STATIC (newdecl) = TREE_STATIC (olddecl);
! 	  DECL_EXTERNAL (newdecl) = DECL_EXTERNAL (olddecl);
! 	}
        /* An extern decl does not override previous storage class.  */
        TREE_PUBLIC (newdecl) = TREE_PUBLIC (olddecl);
        if (! DECL_EXTERNAL (newdecl))
*************** duplicate_decls (newdecl, olddecl, diffe
*** 2007,2025 ****
  	}
      }
    if (different_binding_level)
!     {
!       /* Don't output a duplicate symbol or debugging information for this
! 	 declaration.
! 
! 	 Do not set TREE_ASM_WRITTEN for a FUNCTION_DECL since we may actually
! 	 just have two declarations without a definition.  VAR_DECLs may need
! 	 the same treatment, I'm not sure.  */
!       if (TREE_CODE (newdecl) == FUNCTION_DECL)
! 	DECL_IGNORED_P (newdecl) = 1;
!       else
! 	TREE_ASM_WRITTEN (newdecl) = DECL_IGNORED_P (newdecl) = 1;
!       return 0;
!     }
  
    /* Copy most of the decl-specific fields of NEWDECL into OLDDECL.
       But preserve OLDDECL's DECL_UID.  */
--- 2010,2016 ----
  	}
      }
    if (different_binding_level)
!     return 0;
  
    /* Copy most of the decl-specific fields of NEWDECL into OLDDECL.
       But preserve OLDDECL's DECL_UID.  */
*************** finish_decl (decl, init, asmspec_tree)
*** 3652,3658 ****
  		 declaration into a file scope one.  This can be detected
  		 by TREE_ASM_WRITTEN being set.  */
  		(DECL_INITIAL (decl) != 0
! 		 || (DECL_CONTEXT (decl) != 0 && ! TREE_ASM_WRITTEN (decl)))
  	      :
  		/* An automatic variable with an incomplete type
  		   is an error.  */
--- 3644,3650 ----
  		 declaration into a file scope one.  This can be detected
  		 by TREE_ASM_WRITTEN being set.  */
  		(DECL_INITIAL (decl) != 0
! 		 || DECL_CONTEXT (decl) != 0)
  	      :
  		/* An automatic variable with an incomplete type
  		   is an error.  */

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