diff mbox

Kill TYPE_METHODS 0/9

Message ID 20170724092514.GN2123@tucnak
State New
Headers show

Commit Message

Jakub Jelinek July 24, 2017, 9:25 a.m. UTC
On Fri, Jul 14, 2017 at 12:44:08PM -0400, Nathan Sidwell wrote:
> This is a series of patches that remove the TYPE_METHODS field used in
> records & unions.  Currently TYPE_METHODS hods a the member functions (be
> they static or non-static), and TYPE_FIELDS holds everything else (be they
> FIELD_DECLS or whatever).  This distinction is unnecessary, and the patches
> move everything to TYPE_FIELDS.  (I do not mess with name lookup, which is
> handled differently).
> 
> I do not repurpose TYPE_METHODS, that's later.
> 
> While the changes are pretty mechanical, some are rather too large outside
> of the C++ FE to comfortably apply the obvious rule.
> 
> 1 method-debug.diff - dbxout & dwarf2out.  Review please.
> 2 method-ipa.diff - lto-devirt.  Review please.
> 3 method-rtl.diff - most odd occurrence.  Comment please.
> 
> 4 method-ada.diff - ada-spec generation.  Obvious.
> 5 method-cp.diff - C++ FE changes, self reviewed
> 6 method-libcc1.diff - libcp1plugin.  Obvious.
> 7 method-misc.diff - random tree.c.  Obvious.
> 8 method-objc.diff - objc.  Obvious
> 
> 9 method-ectomy.diff - delete the macro.  Obvious

Seems TYPE_METHODS have been left in a couple of spots.  For winnt-cxx.c
it apparently causes bootstrap failure (I have no way to test it for that
target, but given that the bootstrap is certainly broken right now, it
can't make things worse) and documentation has not been updated.

Ok for trunk?

2017-07-24  Jakub Jelinek  <jakub@redhat.com>

	PR bootstrap/81521
	* tree.def: Remove TYPE_METHODS documentation, adjust TYPE_FIELDS
	documentation.
	* doc/generic.texi: Likewise.
	* config/i386/winnt-cxx.c (i386_pe_adjust_class_at_definition): Look
	for FUNCTION_DECLs in TYPE_FIELDS rather than TYPE_METHODS.


	Jakub

Comments

Nathan Sidwell July 24, 2017, 11:59 a.m. UTC | #1
On 07/24/2017 05:25 AM, Jakub Jelinek wrote:
> On Fri, Jul 14, 2017 at 12:44:08PM -0400, Nathan Sidwell wrote:

> Seems TYPE_METHODS have been left in a couple of spots.  For winnt-cxx.c
> it apparently causes bootstrap failure (I have no way to test it for that
> target, but given that the bootstrap is certainly broken right now, it
> can't make things worse) and documentation has not been updated.

Thanks for addressing what I overlooked.  Your diff looks good to me.

nathan
diff mbox

Patch

--- gcc/tree.def.jj	2017-01-01 12:45:36.000000000 +0100
+++ gcc/tree.def	2017-07-24 11:10:11.782877862 +0200
@@ -112,10 +112,7 @@  DEFTREECODE (BLOCK, "block", tcc_excepti
     itself or have named members doesn't really have a "scope" per se.
   The TYPE_STUB_DECL field is used as a forward-references to names for
     ENUMERAL_TYPE, RECORD_TYPE, UNION_TYPE, and QUAL_UNION_TYPE nodes;
-    see below.
-  The TYPE_METHODS points to list of all methods associated with the type.
-    It is non-NULL only at main variant of the type and after free_lang_data
-    it may be set to error_mark_node instead of actual list to save memory. */
+    see below.  */
 
 /* The ordering of the following codes is optimized for the checking
    macros in tree.h.  Changing the order will degrade the speed of the
@@ -213,8 +210,9 @@  DEFTREECODE (ARRAY_TYPE, "array_type", t
 /* Struct in C, or record in Pascal.  */
 /* Special fields:
    TYPE_FIELDS  chain of FIELD_DECLs for the fields of the struct,
-     and VAR_DECLs, TYPE_DECLs and CONST_DECLs for record-scope variables,
-     types and enumerators.
+     VAR_DECLs, TYPE_DECLs and CONST_DECLs for record-scope variables,
+     types and enumerators and FUNCTION_DECLs for methods associated
+     with the type.
    A few may need to be added for Pascal.  */
 /* See the comment above, before ENUMERAL_TYPE, for how
    forward references to struct tags are handled in C.  */
--- gcc/doc/generic.texi.jj	2017-01-01 12:45:47.000000000 +0100
+++ gcc/doc/generic.texi	2017-07-24 11:07:37.331728909 +0200
@@ -2820,7 +2820,6 @@  This function cannot be used with namesp
 @findex BINFO_TYPE
 @findex TYPE_FIELDS
 @findex TYPE_VFIELD
-@findex TYPE_METHODS
 
 Besides namespaces, the other high-level scoping construct in C++ is the
 class.  (Throughout this manual the term @dfn{class} is used to mean the
@@ -2837,7 +2836,7 @@  macro to discern whether or not a partic
 opposed to a @code{struct}.  This macro will be true only for classes
 declared with the @code{class} tag.
 
-Almost all non-function members are available on the @code{TYPE_FIELDS}
+Almost all members are available on the @code{TYPE_FIELDS}
 list.  Given one member, the next can be found by following the
 @code{TREE_CHAIN}.  You should not depend in any way on the order in
 which fields appear on this list.  All nodes on this list will be
@@ -2849,7 +2848,11 @@  list, if the enumeration type was declar
 the @code{TYPE_DECL} for the enumeration type will appear here as well.)
 There are no entries for base classes on this list.  In particular,
 there is no @code{FIELD_DECL} for the ``base-class portion'' of an
-object.
+object.  If a function member is overloaded, each of the overloaded
+functions appears; no @code{OVERLOAD} nodes appear on the @code{TYPE_FIELDS}
+list.  Implicitly declared functions (including default constructors,
+copy constructors, assignment operators, and destructors) will appear on
+this list as well.
 
 The @code{TYPE_VFIELD} is a compiler-generated field used to point to
 virtual function tables.  It may or may not appear on the
@@ -2857,14 +2860,6 @@  virtual function tables.  It may or may
 @code{TYPE_VFIELD} just like all the entries on the @code{TYPE_FIELDS}
 list.
 
-The function members are available on the @code{TYPE_METHODS} list.
-Again, subsequent members are found by following the @code{TREE_CHAIN}
-field.  If a function is overloaded, each of the overloaded functions
-appears; no @code{OVERLOAD} nodes appear on the @code{TYPE_METHODS}
-list.  Implicitly declared functions (including default constructors,
-copy constructors, assignment operators, and destructors) will appear on
-this list as well.
-
 Every class has an associated @dfn{binfo}, which can be obtained with
 @code{TYPE_BINFO}.  Binfos are used to represent base-classes.  The
 binfo given by @code{TYPE_BINFO} is the degenerate case, whereby every
--- gcc/config/i386/winnt-cxx.c.jj	2017-01-01 12:45:42.000000000 +0100
+++ gcc/config/i386/winnt-cxx.c	2017-07-24 11:12:23.723296309 +0200
@@ -114,14 +114,11 @@  i386_pe_adjust_class_at_definition (tree
 	  decl_attributes (&ti_decl, na, 0);
 	}
 
-      /* Check static VAR_DECL's.  */
+      /* Check FUNCTION_DECL's and static VAR_DECL's.  */
       for (member = TYPE_FIELDS (t); member; member = DECL_CHAIN (member))
 	if (TREE_CODE (member) == VAR_DECL)     
 	  maybe_add_dllexport (member);
-    
-      /* Check FUNCTION_DECL's.  */
-      for (member = TYPE_METHODS (t); member;  member = DECL_CHAIN (member))
-	if (TREE_CODE (member) == FUNCTION_DECL)
+	else if (TREE_CODE (member) == FUNCTION_DECL)
 	  {
 	    tree thunk;
 	    maybe_add_dllexport (member);
@@ -132,7 +129,8 @@  i386_pe_adjust_class_at_definition (tree
 	      maybe_add_dllexport (thunk);
 	}
       /* Check vtables  */
-      for (member = CLASSTYPE_VTABLES (t); member;  member = DECL_CHAIN (member))
+      for (member = CLASSTYPE_VTABLES (t);
+	   member; member = DECL_CHAIN (member))
 	if (TREE_CODE (member) == VAR_DECL) 
 	  maybe_add_dllexport (member);
     }