OSDN Git Service

* decl.c (cplus_expand_expr_stmt): Always complain about unresolved
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 18 Nov 1998 12:27:30 +0000 (12:27 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 18 Nov 1998 12:27:30 +0000 (12:27 +0000)
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

gcc/cp/ChangeLog
gcc/cp/call.c
gcc/cp/cvt.c
gcc/cp/decl.c
gcc/cp/search.c
gcc/cp/tree.c
gcc/cp/typeck.c
gcc/cp/typeck2.c

index 0066bd7..7f2dd89 100644 (file)
@@ -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.
index a502a76..3800330 100644 (file)
@@ -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))
          {
index 981cf7b..781f015 100644 (file)
@@ -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
index dd7fba9..9feae32 100644 (file)
@@ -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
     {
index 1f70579..f9ec9dc 100644 (file)
@@ -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;
 }
 
index deaa20c..efbf6b2 100644 (file)
@@ -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;
 
index 8f7e329..e944eee 100644 (file)
@@ -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);
 
index 78eebf6..ed655cd 100644 (file)
@@ -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));