Commit 59e76fc6 by Jason Merrill Committed by Jason Merrill

decl.c (cplus_expand_expr_stmt): Always complain about unresolved type.

	* decl.c (cplus_expand_expr_stmt): Always complain about unresolved
	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

From-SVN: r23695
parent ab187885
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> 1998-11-18 Mark Mitchell <mark@markmitchell.com>
* Make-lang.in (cc1plus): Add dependency on hash.o. * Make-lang.in (cc1plus): Add dependency on hash.o.
......
...@@ -2421,7 +2421,8 @@ build_object_call (obj, args) ...@@ -2421,7 +2421,8 @@ build_object_call (obj, args)
tree fns = TREE_VALUE (convs); tree fns = TREE_VALUE (convs);
tree totype = TREE_TYPE (TREE_TYPE (OVL_CURRENT (fns))); 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) && TREE_CODE (TREE_TYPE (totype)) == FUNCTION_TYPE)
for (; fns; fns = OVL_NEXT (fns)) for (; fns; fns = OVL_NEXT (fns))
{ {
......
...@@ -814,6 +814,12 @@ ocp_convert (type, expr, convtype, flags) ...@@ -814,6 +814,12 @@ ocp_convert (type, expr, convtype, flags)
ctor = e; 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) if ((flags & LOOKUP_ONLYCONVERTING)
&& ! (IS_AGGR_TYPE (dtype) && DERIVED_FROM_P (type, dtype))) && ! (IS_AGGR_TYPE (dtype) && DERIVED_FROM_P (type, dtype)))
/* For copy-initialization, first we create a temp of the proper type /* For copy-initialization, first we create a temp of the proper type
......
...@@ -8139,8 +8139,10 @@ grokfndecl (ctype, type, declarator, orig_declarator, virtualp, flags, quals, ...@@ -8139,8 +8139,10 @@ grokfndecl (ctype, type, declarator, orig_declarator, virtualp, flags, quals,
publicp = 1; publicp = 1;
} }
/* Members of anonymous types have no linkage; make them internal. */ /* Members of anonymous types and local classes have no linkage; make
if (ctype && ANON_AGGRNAME_P (TYPE_IDENTIFIER (ctype))) them internal. */
if (ctype && (ANON_AGGRNAME_P (TYPE_IDENTIFIER (ctype))
|| hack_decl_function_context (TYPE_MAIN_DECL (ctype))))
publicp = 0; publicp = 0;
if (publicp) if (publicp)
...@@ -11377,8 +11379,9 @@ grok_ctor_properties (ctype, decl) ...@@ -11377,8 +11379,9 @@ grok_ctor_properties (ctype, decl)
TYPE_HAS_CONST_INIT_REF (ctype) = 1; TYPE_HAS_CONST_INIT_REF (ctype) = 1;
} }
else if (TYPE_MAIN_VARIANT (parmtype) == ctype else if (TYPE_MAIN_VARIANT (parmtype) == ctype
&& TREE_CHAIN (parmtypes) != NULL_TREE && (TREE_CHAIN (parmtypes) == NULL_TREE
&& TREE_CHAIN (parmtypes) == void_list_node) || TREE_CHAIN (parmtypes) == void_list_node
|| TREE_PURPOSE (TREE_CHAIN (parmtypes))))
{ {
cp_error ("invalid constructor; you probably meant `%T (const %T&)'", cp_error ("invalid constructor; you probably meant `%T (const %T&)'",
ctype, ctype); ctype, ctype);
...@@ -13967,10 +13970,10 @@ cplus_expand_expr_stmt (exp) ...@@ -13967,10 +13970,10 @@ cplus_expand_expr_stmt (exp)
if (TREE_TYPE (exp) == unknown_type_node) if (TREE_TYPE (exp) == unknown_type_node)
{ {
if (TREE_CODE (exp) == ADDR_EXPR || TREE_CODE (exp) == TREE_LIST) if (TREE_CODE (exp) == COMPONENT_REF)
error ("address of overloaded function with no contextual type information");
else if (TREE_CODE (exp) == COMPONENT_REF)
error ("invalid reference to a member function name, did you forget the ()?"); error ("invalid reference to a member function name, did you forget the ()?");
else
error ("address of overloaded function with no contextual type information");
} }
else else
{ {
......
...@@ -3297,6 +3297,7 @@ add_conversions (binfo) ...@@ -3297,6 +3297,7 @@ add_conversions (binfo)
{ {
int i; int i;
tree method_vec = CLASSTYPE_METHOD_VEC (BINFO_TYPE (binfo)); tree method_vec = CLASSTYPE_METHOD_VEC (BINFO_TYPE (binfo));
tree name = NULL_TREE;
for (i = 2; i < TREE_VEC_LENGTH (method_vec); ++i) for (i = 2; i < TREE_VEC_LENGTH (method_vec); ++i)
{ {
...@@ -3305,13 +3306,25 @@ add_conversions (binfo) ...@@ -3305,13 +3306,25 @@ add_conversions (binfo)
if (!tmp || ! DECL_CONV_FN_P (OVL_CURRENT (tmp))) if (!tmp || ! DECL_CONV_FN_P (OVL_CURRENT (tmp)))
break; 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. */ /* Make sure we don't already have this conversion. */
if (! IDENTIFIER_MARKED (DECL_NAME (tmp))) if (! IDENTIFIER_MARKED (DECL_NAME (tmp)))
{ {
conversions = scratch_tree_cons (binfo, tmp, conversions); 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; return NULL_TREE;
} }
......
...@@ -87,8 +87,7 @@ lvalue_p_1 (ref, treat_class_rvalues_as_lvalues) ...@@ -87,8 +87,7 @@ lvalue_p_1 (ref, treat_class_rvalues_as_lvalues)
case ARRAY_REF: case ARRAY_REF:
case PARM_DECL: case PARM_DECL:
case RESULT_DECL: case RESULT_DECL:
if (TREE_CODE (TREE_TYPE (ref)) != FUNCTION_TYPE if (TREE_CODE (TREE_TYPE (ref)) != METHOD_TYPE)
&& TREE_CODE (TREE_TYPE (ref)) != METHOD_TYPE)
return 1; return 1;
break; break;
......
...@@ -6931,7 +6931,9 @@ convert_for_initialization (exp, type, rhs, flags, errtype, fndecl, parmnum) ...@@ -6931,7 +6931,9 @@ convert_for_initialization (exp, type, rhs, flags, errtype, fndecl, parmnum)
&& TREE_CODE (type) != ARRAY_TYPE && TREE_CODE (type) != ARRAY_TYPE
&& (TREE_CODE (type) != REFERENCE_TYPE && (TREE_CODE (type) != REFERENCE_TYPE
|| TREE_CODE (TREE_TYPE (type)) != ARRAY_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) || TREE_CODE (TREE_TYPE (rhs)) == METHOD_TYPE)
rhs = default_conversion (rhs); rhs = default_conversion (rhs);
......
...@@ -1438,6 +1438,11 @@ build_functional_cast (exp, parms) ...@@ -1438,6 +1438,11 @@ build_functional_cast (exp, parms)
cp_error ("type `%T' is not yet defined", type); cp_error ("type `%T' is not yet defined", type);
return error_mark_node; 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) if (parms && TREE_CHAIN (parms) == NULL_TREE)
return build_c_cast (type, TREE_VALUE (parms)); return build_c_cast (type, TREE_VALUE (parms));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment