type.
Fixes Sec13/4/E13417.C
* tree.c (lvalue_p_1): An INDIRECT_REF to a function is an lvalue.
* call.c (build_object_call): Also support references to functions.
* typeck.c (convert_for_initialization): Don't decay a function
if the target is a reference to function.
Fixes Sec13/2_1_1_2/P13120.C
* search.c (add_conversions): Get all the overloads from a class.
Fixes Sec13/2/P13101.C
* decl.c (grok_ctor_properties): Complain about any constructor
that will take a single arg of the class type by value.
Fixes Sec12/8/S12072.C
* typeck2.c (build_functional_cast): Can't create objects of
abstract classes this way.
* cvt.c (ocp_convert): Likewise.
Fixes Sec10/4/S10018.C
* decl.c (grokfndecl): Member functions of local classes are not
public.
Fixes Sec10/3/P10092.C
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@23695
138bc75d-0d04-0410-961f-
82ee72b054a4
+1998-11-18 Jason Merrill <jason@yorick.cygnus.com>
+
+ * decl.c (cplus_expand_expr_stmt): Always complain about unresolved
+ type.
+
+ * tree.c (lvalue_p_1): An INDIRECT_REF to a function is an lvalue.
+ * call.c (build_object_call): Also support references to functions.
+ * typeck.c (convert_for_initialization): Don't decay a function
+ if the target is a reference to function.
+
+ * search.c (add_conversions): Get all the overloads from a class.
+
+ * decl.c (grok_ctor_properties): Complain about any constructor
+ that will take a single arg of the class type by value.
+
+ * typeck2.c (build_functional_cast): Can't create objects of
+ abstract classes this way.
+ * cvt.c (ocp_convert): Likewise.
+
+ * decl.c (grokfndecl): Member functions of local classes are not
+ public.
+
1998-11-18 Mark Mitchell <mark@markmitchell.com>
* Make-lang.in (cc1plus): Add dependency on hash.o.
tree fns = TREE_VALUE (convs);
tree totype = TREE_TYPE (TREE_TYPE (OVL_CURRENT (fns)));
- if (TREE_CODE (totype) == POINTER_TYPE
+ if ((TREE_CODE (totype) == POINTER_TYPE
+ || TREE_CODE (totype) == REFERENCE_TYPE)
&& TREE_CODE (TREE_TYPE (totype)) == FUNCTION_TYPE)
for (; fns; fns = OVL_NEXT (fns))
{
ctor = e;
+ if (IS_AGGR_TYPE (type) && CLASSTYPE_ABSTRACT_VIRTUALS (type))
+ {
+ abstract_virtuals_error (NULL_TREE, type);
+ return error_mark_node;
+ }
+
if ((flags & LOOKUP_ONLYCONVERTING)
&& ! (IS_AGGR_TYPE (dtype) && DERIVED_FROM_P (type, dtype)))
/* For copy-initialization, first we create a temp of the proper type
publicp = 1;
}
- /* Members of anonymous types have no linkage; make them internal. */
- if (ctype && ANON_AGGRNAME_P (TYPE_IDENTIFIER (ctype)))
+ /* Members of anonymous types and local classes have no linkage; make
+ them internal. */
+ if (ctype && (ANON_AGGRNAME_P (TYPE_IDENTIFIER (ctype))
+ || hack_decl_function_context (TYPE_MAIN_DECL (ctype))))
publicp = 0;
if (publicp)
TYPE_HAS_CONST_INIT_REF (ctype) = 1;
}
else if (TYPE_MAIN_VARIANT (parmtype) == ctype
- && TREE_CHAIN (parmtypes) != NULL_TREE
- && TREE_CHAIN (parmtypes) == void_list_node)
+ && (TREE_CHAIN (parmtypes) == NULL_TREE
+ || TREE_CHAIN (parmtypes) == void_list_node
+ || TREE_PURPOSE (TREE_CHAIN (parmtypes))))
{
cp_error ("invalid constructor; you probably meant `%T (const %T&)'",
ctype, ctype);
if (TREE_TYPE (exp) == unknown_type_node)
{
- if (TREE_CODE (exp) == ADDR_EXPR || TREE_CODE (exp) == TREE_LIST)
- error ("address of overloaded function with no contextual type information");
- else if (TREE_CODE (exp) == COMPONENT_REF)
+ if (TREE_CODE (exp) == COMPONENT_REF)
error ("invalid reference to a member function name, did you forget the ()?");
+ else
+ error ("address of overloaded function with no contextual type information");
}
else
{
{
int i;
tree method_vec = CLASSTYPE_METHOD_VEC (BINFO_TYPE (binfo));
+ tree name = NULL_TREE;
for (i = 2; i < TREE_VEC_LENGTH (method_vec); ++i)
{
if (!tmp || ! DECL_CONV_FN_P (OVL_CURRENT (tmp)))
break;
+ /* We don't want to mark 'name' until we've seen all the overloads
+ in this class; we could be overloading on the quals of 'this'. */
+ if (name && name != DECL_NAME (tmp))
+ {
+ IDENTIFIER_MARKED (name) = 1;
+ name = NULL_TREE;
+ }
+
/* Make sure we don't already have this conversion. */
if (! IDENTIFIER_MARKED (DECL_NAME (tmp)))
{
conversions = scratch_tree_cons (binfo, tmp, conversions);
- IDENTIFIER_MARKED (DECL_NAME (tmp)) = 1;
+ name = DECL_NAME (tmp);
}
}
+
+ if (name)
+ IDENTIFIER_MARKED (name) = 1;
+
return NULL_TREE;
}
case ARRAY_REF:
case PARM_DECL:
case RESULT_DECL:
- if (TREE_CODE (TREE_TYPE (ref)) != FUNCTION_TYPE
- && TREE_CODE (TREE_TYPE (ref)) != METHOD_TYPE)
+ if (TREE_CODE (TREE_TYPE (ref)) != METHOD_TYPE)
return 1;
break;
&& TREE_CODE (type) != ARRAY_TYPE
&& (TREE_CODE (type) != REFERENCE_TYPE
|| TREE_CODE (TREE_TYPE (type)) != ARRAY_TYPE))
- || TREE_CODE (TREE_TYPE (rhs)) == FUNCTION_TYPE
+ || (TREE_CODE (TREE_TYPE (rhs)) == FUNCTION_TYPE
+ && (TREE_CODE (type) != REFERENCE_TYPE
+ || TREE_CODE (TREE_TYPE (type)) != FUNCTION_TYPE))
|| TREE_CODE (TREE_TYPE (rhs)) == METHOD_TYPE)
rhs = default_conversion (rhs);
cp_error ("type `%T' is not yet defined", type);
return error_mark_node;
}
+ if (IS_AGGR_TYPE (type) && CLASSTYPE_ABSTRACT_VIRTUALS (type))
+ {
+ abstract_virtuals_error (NULL_TREE, type);
+ return error_mark_node;
+ }
if (parms && TREE_CHAIN (parms) == NULL_TREE)
return build_c_cast (type, TREE_VALUE (parms));