diff options
author | Jason Merrill <jason@yorick.cygnus.com> | 1998-11-18 12:27:30 +0000 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 1998-11-18 07:27:30 -0500 |
commit | 59e76fc6ba25be94f98194ec5e4accdac8a50315 (patch) | |
tree | f8d198f498d62e38807a0fd49db30db8a820e0ce | |
parent | ab1878854a909d581de35aaabe6b0e668781068c (diff) | |
download | gcc-59e76fc6ba25be94f98194ec5e4accdac8a50315.zip gcc-59e76fc6ba25be94f98194ec5e4accdac8a50315.tar.gz gcc-59e76fc6ba25be94f98194ec5e4accdac8a50315.tar.bz2 |
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
-rw-r--r-- | gcc/cp/ChangeLog | 22 | ||||
-rw-r--r-- | gcc/cp/call.c | 3 | ||||
-rw-r--r-- | gcc/cp/cvt.c | 6 | ||||
-rw-r--r-- | gcc/cp/decl.c | 17 | ||||
-rw-r--r-- | gcc/cp/search.c | 15 | ||||
-rw-r--r-- | gcc/cp/tree.c | 3 | ||||
-rw-r--r-- | gcc/cp/typeck.c | 4 | ||||
-rw-r--r-- | gcc/cp/typeck2.c | 5 |
8 files changed, 63 insertions, 12 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 0066bd7..7f2dd89 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,25 @@ +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. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index a502a76..3800330 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -2421,7 +2421,8 @@ build_object_call (obj, args) 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)) { diff --git a/gcc/cp/cvt.c b/gcc/cp/cvt.c index 981cf7b..781f015 100644 --- a/gcc/cp/cvt.c +++ b/gcc/cp/cvt.c @@ -814,6 +814,12 @@ ocp_convert (type, expr, convtype, flags) 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 diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index dd7fba9..9feae32 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -8139,8 +8139,10 @@ grokfndecl (ctype, type, declarator, orig_declarator, virtualp, flags, quals, 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) @@ -11377,8 +11379,9 @@ grok_ctor_properties (ctype, decl) 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); @@ -13967,10 +13970,10 @@ cplus_expand_expr_stmt (exp) 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 { diff --git a/gcc/cp/search.c b/gcc/cp/search.c index 1f70579..f9ec9dc 100644 --- a/gcc/cp/search.c +++ b/gcc/cp/search.c @@ -3297,6 +3297,7 @@ add_conversions (binfo) { 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) { @@ -3305,13 +3306,25 @@ add_conversions (binfo) 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; } diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index deaa20c..efbf6b2 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -87,8 +87,7 @@ lvalue_p_1 (ref, treat_class_rvalues_as_lvalues) 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; diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 8f7e329..e944eee 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -6931,7 +6931,9 @@ convert_for_initialization (exp, type, rhs, flags, errtype, fndecl, parmnum) && 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); diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c index 78eebf6..ed655cd 100644 --- a/gcc/cp/typeck2.c +++ b/gcc/cp/typeck2.c @@ -1438,6 +1438,11 @@ build_functional_cast (exp, parms) 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)); |