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++) remove write_virtuals


1999-07-09  Michael Tiemann  <tiemann@happy.cygnus.com>

	* decl2.c (write_virtuals): Deleted declaration.
	* cp-tree.h (write_virtuals): Deleted extern declaration.
	* class.c (finish_struct_1): Removed #if 0'd code that mentions
	write_virtuals.
	* semantics.c (begin_class_definition): Rewrite code to not depend
	on write_virtuals.

	* lex.c (cp_pragma_interface): New function.
	(cp_pragma_implementation): Likewise.
	(handle_cp_pragma): Call them.

Index: class.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/class.c,v
retrieving revision 1.163
diff -c -p -r1.163 class.c
*** class.c	1999/07/09 11:05:05	1.163
--- class.c	1999/07/09 19:39:37
*************** finish_struct_1 (t, warn_anon)
*** 3212,3227 ****
        no_const_asn_ref = 0;
      }
  
- #if 0
-   /* Both of these should be done before now.  */
-   if (write_virtuals == 3 && CLASSTYPE_INTERFACE_KNOWN (t)
-       && ! IS_SIGNATURE (t))
-     {
-       my_friendly_assert (CLASSTYPE_INTERFACE_ONLY (t) == interface_only, 999);
-       my_friendly_assert (CLASSTYPE_VTABLE_NEEDS_WRITING (t) == ! interface_only, 999);
-     }
- #endif
- 
    /* The three of these are approximations which may later be
       modified.  Needed at this point to make add_virtual_function
       and modify_vtable_entries work.  */
--- 3212,3217 ----
Index: cp-tree.h
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/cp-tree.h,v
retrieving revision 1.240
diff -c -p -r1.240 cp-tree.h
*** cp-tree.h	1999/07/05 14:04:43	1.240
--- cp-tree.h	1999/07/09 19:39:38
*************** extern int warn_old_style_cast;
*** 490,507 ****
  
  extern int flag_signed_bitfields;
  
- /* 3 means write out only virtuals function tables `defined'
-    in this implementation file.
-    2 means write out only specific virtual function tables
-    and give them (C) public access.
-    1 means write out virtual function tables and give them
-    (C) public access.
-    0 means write out virtual function tables and give them
-    (C) static access (default).
-    -1 means declare virtual function tables extern.  */
- 
- extern int write_virtuals;
- 
  /* True for more efficient but incompatible (not fully tested)
     vtable implementation (using thunks).
     0 is old behavior; 1 is new behavior.  */
--- 490,495 ----
Index: decl2.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/decl2.c,v
retrieving revision 1.222
diff -c -p -r1.222 decl2.c
*** decl2.c	1999/07/07 00:32:23	1.222
--- decl2.c	1999/07/09 19:39:38
*************** int flag_detailed_statistics;
*** 375,387 ****
  
  int flag_this_is_variable;
  
- /* 3 means write out only virtuals function tables `defined'
-    in this implementation file.
-    0 means write out virtual function tables and give them
-    (C) static access (default).  */
- 
- int write_virtuals;
- 
  /* Nonzero means we should attempt to elide constructors when possible.  */
  
  int flag_elide_constructors = 1;
--- 375,380 ----
Index: lex.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/lex.c,v
retrieving revision 1.118
diff -c -p -r1.118 lex.c
*** lex.c	1999/07/06 10:08:25	1.118
--- lex.c	1999/07/09 19:39:38
*************** static int set_vardecl_interface_info PR
*** 71,76 ****
--- 71,78 ----
  static void store_pending_inline PROTO((tree, struct pending_inline *));
  static void reinit_parse_for_expr PROTO((struct obstack *));
  static int *init_cpp_parse PROTO((void));
+ static void cp_pragma_interface PROTO((char *));
+ static void cp_pragma_implementation PROTO ((char *));
  static int handle_cp_pragma PROTO((const char *));
  #ifdef HANDLE_GENERIC_PRAGMAS
  static int handle_generic_pragma PROTO((int));
*************** interface_strcmp (s)
*** 1136,1141 ****
--- 1138,1230 ----
    return 1;
  }
  
+ static void
+ cp_pragma_interface (main_filename)
+      char *main_filename;
+ {
+   tree fileinfo 
+     = TIME_IDENTIFIER_FILEINFO (get_time_identifier (input_filename));
+ 
+   if (impl_file_chain == 0)
+     {
+       /* If this is zero at this point, then we are
+ 	 auto-implementing.  */
+       if (main_input_filename == 0)
+ 	main_input_filename = input_filename;
+ 
+ #ifdef AUTO_IMPLEMENT
+       filename = file_name_nondirectory (main_input_filename);
+       fi = get_time_identifier (filename);
+       fi = TIME_IDENTIFIER_FILEINFO (fi);
+       TREE_INT_CST_LOW (fi) = 0;
+       TREE_INT_CST_HIGH (fi) = 1;
+       /* Get default.  */
+       impl_file_chain = (struct impl_files *)permalloc (sizeof (struct impl_files));
+       impl_file_chain->filename = filename;
+       impl_file_chain->next = 0;
+ #endif
+     }
+ 
+   interface_only = interface_strcmp (main_filename);
+ #ifdef MULTIPLE_SYMBOL_SPACES
+   if (! interface_only)
+     interface_unknown = 0;
+ #else /* MULTIPLE_SYMBOL_SPACES */
+   interface_unknown = 0;
+ #endif /* MULTIPLE_SYMBOL_SPACES */
+   TREE_INT_CST_LOW (fileinfo) = interface_only;
+   TREE_INT_CST_HIGH (fileinfo) = interface_unknown;
+ }
+ 
+ static void
+ cp_pragma_implementation (main_filename)
+      char *main_filename;
+ {
+   tree fileinfo 
+     = TIME_IDENTIFIER_FILEINFO (get_time_identifier (input_filename));
+ 
+   if (impl_file_chain)
+     {
+       struct impl_files *ifiles = impl_file_chain;
+       while (ifiles)
+ 	{
+ 	  if (! strcmp (ifiles->filename, main_filename))
+ 	    break;
+ 	  ifiles = ifiles->next;
+ 	}
+       if (ifiles == 0)
+ 	{
+ 	  ifiles = (struct impl_files*) permalloc (sizeof (struct impl_files));
+ 	  ifiles->filename = main_filename;
+ 	  ifiles->next = impl_file_chain;
+ 	  impl_file_chain = ifiles;
+ 	}
+     }
+   else if ((main_input_filename != 0
+ 	    && ! strcmp (main_input_filename, input_filename))
+ 	   || ! strcmp (main_filename, input_filename))
+     {
+       impl_file_chain = (struct impl_files*) permalloc (sizeof (struct impl_files));
+       impl_file_chain->filename = main_filename;
+       impl_file_chain->next = 0;
+     }
+   else
+     error ("`#pragma implementation' can only appear at top-level");
+   interface_only = 0;
+ #if 1
+   /* We make this non-zero so that we infer decl linkage
+      in the impl file only for variables first declared
+      in the interface file.  */
+   interface_unknown = 1;
+ #else
+   /* We make this zero so that templates in the impl
+      file will be emitted properly.  */
+   interface_unknown = 0;
+ #endif
+   TREE_INT_CST_LOW (fileinfo) = interface_only;
+   TREE_INT_CST_HIGH (fileinfo) = interface_unknown;
+ }
+ 
  static int
  set_typedecl_interface_info (t, data)
       tree *t;
*************** linenum:
*** 2465,2479 ****
  	    }
  
  	  main_input_filename = input_filename;
- 	  if (write_virtuals == 3)
- 	    {
- 	      walk_globals (vtable_decl_p,
- 			    set_vardecl_interface_info,
- 			    /*data=*/0);
- 	      walk_globals (vtype_decl_p,
- 			    set_typedecl_interface_info,
- 			    /*data=*/0);
- 	    }
  	}
  
        extract_interface_info ();
--- 2554,2559 ----
*************** handle_cp_pragma (pname)
*** 4804,4814 ****
  	  return -1;
  	}
  
-       if (write_virtuals != 2)
- 	{
- 	  warning ("use `+e2' option to enable #pragma vtable");
- 	  return -1;
- 	}
        pending_vtables
  	= perm_tree_cons (NULL_TREE,
  			  get_identifier (TREE_STRING_POINTER (yylval.ttype)),
--- 4884,4889 ----
*************** handle_cp_pragma (pname)
*** 4834,4841 ****
      }
    else if (! strcmp (pname, "interface"))
      {
-       tree fileinfo 
- 	= TIME_IDENTIFIER_FILEINFO (get_time_identifier (input_filename));
        char *main_filename = input_filename;
  
        main_filename = file_name_nondirectory (main_filename);
--- 4909,4914 ----
*************** handle_cp_pragma (pname)
*** 4857,4904 ****
        if (token != END_OF_LINE)
  	warning ("garbage after `#pragma interface' ignored");
  
!       write_virtuals = 3;
  
-       if (impl_file_chain == 0)
- 	{
- 	  /* If this is zero at this point, then we are
- 	     auto-implementing.  */
- 	  if (main_input_filename == 0)
- 	    main_input_filename = input_filename;
- 
- #ifdef AUTO_IMPLEMENT
- 	  filename = file_name_nondirectory (main_input_filename);
- 	  fi = get_time_identifier (filename);
- 	  fi = TIME_IDENTIFIER_FILEINFO (fi);
- 	  TREE_INT_CST_LOW (fi) = 0;
- 	  TREE_INT_CST_HIGH (fi) = 1;
- 	  /* Get default.  */
- 	  impl_file_chain = (struct impl_files *)permalloc (sizeof (struct impl_files));
- 	  impl_file_chain->filename = filename;
- 	  impl_file_chain->next = 0;
- #endif
- 	}
- 
-       interface_only = interface_strcmp (main_filename);
- #ifdef MULTIPLE_SYMBOL_SPACES
-       if (! interface_only)
- 	interface_unknown = 0;
- #else /* MULTIPLE_SYMBOL_SPACES */
-       interface_unknown = 0;
- #endif /* MULTIPLE_SYMBOL_SPACES */
-       TREE_INT_CST_LOW (fileinfo) = interface_only;
-       TREE_INT_CST_HIGH (fileinfo) = interface_unknown;
- 
        return 1;
      }
    else if (! strcmp (pname, "implementation"))
      {
-       tree fileinfo 
- 	= TIME_IDENTIFIER_FILEINFO (get_time_identifier (input_filename));
        char *main_filename = main_input_filename ? main_input_filename : input_filename;
  
        main_filename = file_name_nondirectory (main_filename);
        token = real_yylex ();
        if (token != END_OF_LINE)
  	{
  	  if (token != STRING
--- 4930,4947 ----
        if (token != END_OF_LINE)
  	warning ("garbage after `#pragma interface' ignored");
  
!       cp_pragma_interface (main_filename);
  
        return 1;
      }
    else if (! strcmp (pname, "implementation"))
      {
        char *main_filename = main_input_filename ? main_input_filename : input_filename;
  
        main_filename = file_name_nondirectory (main_filename);
+ 
        token = real_yylex ();
+ 
        if (token != END_OF_LINE)
  	{
  	  if (token != STRING
*************** handle_cp_pragma (pname)
*** 4914,4963 ****
        if (token != END_OF_LINE)
  	warning ("garbage after `#pragma implementation' ignored");
  
!       if (write_virtuals == 3)
! 	{
! 	  struct impl_files *ifiles = impl_file_chain;
! 	  while (ifiles)
! 	    {
! 	      if (! strcmp (ifiles->filename, main_filename))
! 		break;
! 	      ifiles = ifiles->next;
! 	    }
! 	  if (ifiles == 0)
! 	    {
! 	      ifiles = (struct impl_files*) permalloc (sizeof (struct impl_files));
! 	      ifiles->filename = main_filename;
! 	      ifiles->next = impl_file_chain;
! 	      impl_file_chain = ifiles;
! 	    }
! 	}
!       else if ((main_input_filename != 0
! 		&& ! strcmp (main_input_filename, input_filename))
! 	       || ! strcmp (input_filename, main_filename))
! 	{
! 	  write_virtuals = 3;
! 	  if (impl_file_chain == 0)
! 	    {
! 	      impl_file_chain = (struct impl_files*) permalloc (sizeof (struct impl_files));
! 	      impl_file_chain->filename = main_filename;
! 	      impl_file_chain->next = 0;
! 	    }
! 	}
!       else
! 	error ("`#pragma implementation' can only appear at top-level");
!       interface_only = 0;
! #if 1
!       /* We make this non-zero so that we infer decl linkage
! 	 in the impl file only for variables first declared
! 	 in the interface file.  */
!       interface_unknown = 1;
! #else
!       /* We make this zero so that templates in the impl
! 	 file will be emitted properly.  */
!       interface_unknown = 0;
! #endif
!       TREE_INT_CST_LOW (fileinfo) = interface_only;
!       TREE_INT_CST_HIGH (fileinfo) = interface_unknown;
  
        return 1;
      }
--- 4957,4963 ----
        if (token != END_OF_LINE)
  	warning ("garbage after `#pragma implementation' ignored");
  
!       cp_pragma_implementation (main_filename);
  
        return 1;
      }
Index: semantics.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/semantics.c,v
retrieving revision 1.52
diff -c -p -r1.52 semantics.c
*** semantics.c	1999/06/19 23:56:56	1.52
--- semantics.c	1999/07/09 19:39:38
*************** begin_class_definition (t)
*** 1329,1344 ****
  	  SET_CLASSTYPE_INTERFACE_UNKNOWN_X
  	    (t, interface_unknown);
  	}
!       
!       /* Record how to set the access of this class's
! 	 virtual functions.  If write_virtuals == 3, then
! 	 inline virtuals are ``extern inline''.  */
!       if (write_virtuals == 3)
! 	needs_writing = ! CLASSTYPE_INTERFACE_ONLY (t)
! 	  && CLASSTYPE_INTERFACE_KNOWN (t);
!       else
! 	needs_writing = 1;
!       CLASSTYPE_VTABLE_NEEDS_WRITING (t) = needs_writing;
      }
  #if 0
    tmp = TYPE_IDENTIFIER ($<ttype>0);
--- 1329,1340 ----
  	  SET_CLASSTYPE_INTERFACE_UNKNOWN_X
  	    (t, interface_unknown);
  	}
! 
!       /* Only leave this bit clear if we know this
! 	 class is part of an interface-only specification.  */
!       if (! CLASSTYPE_INTERFACE_KNOWN (t)
! 	  || ! CLASSTYPE_INTERFACE_ONLY (t))
! 	CLASSTYPE_VTABLE_NEEDS_WRITING (t) = 1;
      }
  #if 0
    tmp = TYPE_IDENTIFIER ($<ttype>0);


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