This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
C++ PATCH for DECL_NONCONVERTING_P
- To: egcs-patches at cygnus dot com
- Subject: C++ PATCH for DECL_NONCONVERTING_P
- From: Mark Mitchell <mark at markmitchell dot com>
- Date: Sun, 25 Oct 1998 23:14:24 -0800
- Cc: Jason Merrill <jason at cygnus dot com>
- Reply-to: mark at markmitchell dot com
This patch makes DECL_NONCONVERTING_P hold for all non-converting
constructors (instead of just those marked with `explicit').
Besides making the tree structure a bit more intuitive this patch
should also speed up overload resolution slightly for classes with
lots of non-converting constructors.
--
Mark Mitchell mark@markmitchell.com
Mark Mitchell Consulting http://www.markmitchell.com
1998-10-25 Mark Mitchell <mark@markmitchell.com>
* decl.c (grokdeclarator): Set DECL_NONCONVERTING_P for all
non-converting constructors.
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/decl.c,v
retrieving revision 1.243
diff -c -p -r1.243 decl.c
*** decl.c 1998/10/23 14:52:59 1.243
--- decl.c 1998/10/26 05:02:33
*************** grokdeclarator (declarator, declspecs, d
*** 10508,10515 ****
--- 10508,10544 ----
decl = build_decl_attribute_variant (decl, decl_machine_attr);
#endif
+ /* [class.conv.ctor]
+
+ A constructor declared without the function-specifier
+ explicit that can be called with a single parameter
+ specifies a conversion from the type of its first
+ parameter to the type of its class. Such a constructor
+ is called a converting constructor. */
if (explicitp == 2)
DECL_NONCONVERTING_P (decl) = 1;
+ else if (DECL_CONSTRUCTOR_P (decl))
+ {
+ /* The constructor can be called with exactly one
+ parameter if there is at least one parameter, and
+ any subsequent parameters have default arguments.
+ We don't look at the first parameter, which is
+ really just the `this' parameter for the new
+ object. */
+ tree arg_types =
+ TREE_CHAIN (TYPE_ARG_TYPES (TREE_TYPE (decl)));
+
+ /* Skip the `in_chrg' argument too, if present. */
+ if (TYPE_USES_VIRTUAL_BASECLASSES (DECL_CONTEXT (decl)))
+ arg_types = TREE_CHAIN (arg_types);
+
+ if (arg_types == void_list_node
+ || (arg_types
+ && TREE_CHAIN (arg_types)
+ && TREE_CHAIN (arg_types) != void_list_node
+ && !TREE_PURPOSE (TREE_CHAIN (arg_types))))
+ DECL_NONCONVERTING_P (decl) = 1;
+ }
}
else if (TREE_CODE (type) == METHOD_TYPE)
{