diff options
author | Mark Mitchell <mark@markmitchell.com> | 1998-10-25 23:15:00 +0000 |
---|---|---|
committer | Mark Mitchell <mmitchel@gcc.gnu.org> | 1998-10-25 23:15:00 +0000 |
commit | cc804e5114f42fe86de5e1cd453f4c6328a2aa7f (patch) | |
tree | ad6d92529fe2e2a86c887964a7e30b45989efcab | |
parent | 224301c1b9108db2bfaf18875c4e072cfa7edef9 (diff) | |
download | gcc-cc804e5114f42fe86de5e1cd453f4c6328a2aa7f.zip gcc-cc804e5114f42fe86de5e1cd453f4c6328a2aa7f.tar.gz gcc-cc804e5114f42fe86de5e1cd453f4c6328a2aa7f.tar.bz2 |
decl.c (grokdeclarator): Set DECL_NONCONVERTING_P for all non-converting constructors.
* decl.c (grokdeclarator): Set DECL_NONCONVERTING_P for all
non-converting constructors.
From-SVN: r23325
-rw-r--r-- | gcc/cp/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/cp/decl.c | 29 |
2 files changed, 34 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 8bd7c7b..69287e3 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +1998-10-25 Mark Mitchell <mark@markmitchell.com> + + * decl.c (grokdeclarator): Set DECL_NONCONVERTING_P for all + non-converting constructors. + 1998-10-24 Martin von Löwis <loewis@informatik.hu-berlin.de> * gxxint.texi: Correct documentation for n, N, Q, and B. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 448290b..5769a88 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -10508,8 +10508,37 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist) 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) { |