This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

(C++) yet another batch of patches


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.

Index: call.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/call.c,v
retrieving revision 1.119
diff -c -p -r1.119 call.c
*** call.c	1998/11/16 05:05:12	1.119
--- call.c	1998/11/18 20:22:20
*************** build_object_call (obj, args)
*** 2421,2427 ****
        tree fns = TREE_VALUE (convs);
        tree totype = TREE_TYPE (TREE_TYPE (OVL_CURRENT (fns)));
  
!       if (TREE_CODE (totype) == POINTER_TYPE
  	  && TREE_CODE (TREE_TYPE (totype)) == FUNCTION_TYPE)
  	for (; fns; fns = OVL_NEXT (fns))
  	  {
--- 2421,2428 ----
        tree fns = TREE_VALUE (convs);
        tree totype = TREE_TYPE (TREE_TYPE (OVL_CURRENT (fns)));
  
!       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: cvt.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/cvt.c,v
retrieving revision 1.41
diff -c -p -r1.41 cvt.c
*** cvt.c	1998/11/16 05:05:13	1.41
--- cvt.c	1998/11/18 20:22:21
*************** ocp_convert (type, expr, convtype, flags
*** 814,819 ****
--- 814,825 ----
  
        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: decl.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/decl.c,v
retrieving revision 1.262
diff -c -p -r1.262 decl.c
*** decl.c	1998/11/18 02:21:47	1.262
--- decl.c	1998/11/18 20:22:22
*************** grokfndecl (ctype, type, declarator, ori
*** 8139,8146 ****
        publicp = 1;
      }
  
!   /* Members of anonymous types have no linkage; make them internal.  */
!   if (ctype && ANON_AGGRNAME_P (TYPE_IDENTIFIER (ctype)))
      publicp = 0;
  
    if (publicp)
--- 8139,8148 ----
        publicp = 1;
      }
  
!   /* 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)
*************** grok_ctor_properties (ctype, decl)
*** 11377,11384 ****
  	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)
      {
        cp_error ("invalid constructor; you probably meant `%T (const %T&)'",
  		ctype, ctype);
--- 11379,11387 ----
  	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_PURPOSE (TREE_CHAIN (parmtypes))))
      {
        cp_error ("invalid constructor; you probably meant `%T (const %T&)'",
  		ctype, ctype);
*************** cplus_expand_expr_stmt (exp)
*** 13967,13976 ****
  
    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)
  	error ("invalid reference to a member function name, did you forget the ()?");
      }
    else
      {
--- 13970,13979 ----
  
    if (TREE_TYPE (exp) == unknown_type_node)
      {
!       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: search.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/search.c,v
retrieving revision 1.68
diff -c -p -r1.68 search.c
*** search.c	1998/11/18 02:21:53	1.68
--- search.c	1998/11/18 20:22:22
*************** add_conversions (binfo)
*** 3297,3302 ****
--- 3297,3303 ----
  {
    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)
      {
*************** add_conversions (binfo)
*** 3305,3317 ****
        if (!tmp || ! DECL_CONV_FN_P (OVL_CURRENT (tmp)))
  	break;
  
        /* 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;
  	}
      }
    return NULL_TREE;
  }
  
--- 3306,3330 ----
        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);
! 	  name = DECL_NAME (tmp);
  	}
      }
+ 
+   if (name)
+      IDENTIFIER_MARKED (name) = 1;
+ 
    return NULL_TREE;
  }
  
Index: tree.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/tree.c,v
retrieving revision 1.78
diff -c -p -r1.78 tree.c
*** tree.c	1998/11/17 12:51:13	1.78
--- tree.c	1998/11/18 20:22:22
*************** lvalue_p_1 (ref, treat_class_rvalues_as_
*** 87,94 ****
      case ARRAY_REF:
      case PARM_DECL:
      case RESULT_DECL:
!       if (TREE_CODE (TREE_TYPE (ref)) != FUNCTION_TYPE
! 	  && TREE_CODE (TREE_TYPE (ref)) != METHOD_TYPE)
  	return 1;
        break;
  
--- 87,93 ----
      case ARRAY_REF:
      case PARM_DECL:
      case RESULT_DECL:
!       if (TREE_CODE (TREE_TYPE (ref)) != METHOD_TYPE)
  	return 1;
        break;
  
Index: typeck.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/typeck.c,v
retrieving revision 1.125
diff -c -p -r1.125 typeck.c
*** typeck.c	1998/11/17 12:51:16	1.125
--- typeck.c	1998/11/18 20:22:23
*************** convert_for_initialization (exp, type, r
*** 6931,6937 ****
         && 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)) == METHOD_TYPE)
      rhs = default_conversion (rhs);
  
--- 6931,6939 ----
         && 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 (type) != REFERENCE_TYPE
! 	      || TREE_CODE (TREE_TYPE (type)) != FUNCTION_TYPE))
        || TREE_CODE (TREE_TYPE (rhs)) == METHOD_TYPE)
      rhs = default_conversion (rhs);
  
Index: typeck2.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/typeck2.c,v
retrieving revision 1.42
diff -c -p -r1.42 typeck2.c
*** typeck2.c	1998/11/18 02:21:54	1.42
--- typeck2.c	1998/11/18 20:22:23
*************** build_functional_cast (exp, parms)
*** 1438,1443 ****
--- 1438,1448 ----
        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));


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]