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]
Other format: [Raw text]

[C++ PATCH]: Make non-dependent exprs more friendly


I got annoyed by the way non-dependent exprs were reported in
error messages. Fixed thusly,

booted & tested on i686-pc-linux-gnu, installed as obvious

nathan
--
Nathan Sidwell    ::   http://www.codesourcery.com   ::     CodeSourcery LLC
         The voices in my head said this was stupid too
nathan@codesourcery.com    ::     http://www.planetfall.pwp.blueyonder.co.uk

2003-08-15  Nathan Sidwell  <nathan@codesourcery.com>

	* cp-tree.def (NON_DEPENDENT_EXPR): Add operand.
	* decl2.c (build_offset_ref_call_from_tree): Use
	build_non_dependent_expr.
	* error.c (dump_expr) <NON_DEPENDENT_EXPR case>: Dump the operand.
	* pt.c (build_non_dependent_expr): Set operand.
	
Index: cp/cp-tree.def
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/cp-tree.def,v
retrieving revision 1.79
diff -c -3 -p -r1.79 cp-tree.def
*** cp/cp-tree.def	10 Aug 2003 15:10:34 -0000	1.79
--- cp/cp-tree.def	15 Aug 2003 10:02:55 -0000
*************** DEFTREECODE (PSEUDO_DTOR_EXPR, "pseudo_d
*** 240,247 ****
     modify the original expression, which would change the mangling of
     that expression if it appeared in a template argument list.  In
     that situation, we create a NON_DEPENDENT_EXPR to take the place of
!    the original expression.  */
! DEFTREECODE (NON_DEPENDENT_EXPR, "non_dependent_expr", 'e', 0)
  
  /* CTOR_INITIALIZER is a placeholder in template code for a call to
     setup_vtbl_pointer (and appears in all functions, not just ctors).  */
--- 240,248 ----
     modify the original expression, which would change the mangling of
     that expression if it appeared in a template argument list.  In
     that situation, we create a NON_DEPENDENT_EXPR to take the place of
!    the original expression.  The expression is the only operand -- it
!    is only needed for diagnostics.   */
! DEFTREECODE (NON_DEPENDENT_EXPR, "non_dependent_expr", 'e', 1)
  
  /* CTOR_INITIALIZER is a placeholder in template code for a call to
     setup_vtbl_pointer (and appears in all functions, not just ctors).  */
Index: cp/decl2.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/decl2.c,v
retrieving revision 1.658
diff -c -3 -p -r1.658 decl2.c
*** cp/decl2.c	10 Aug 2003 15:10:34 -0000	1.658
--- cp/decl2.c	15 Aug 2003 10:03:36 -0000
*************** finish_file ()
*** 2943,2969 ****
    input_location = locus;
  }
  
! /* FN is an OFFSET_REF indicating the function to call in parse-tree
!    form; it has not yet been semantically analyzed.  ARGS are the
!    arguments to the function.  They have already been semantically
!    analzyed.  */
  
  tree
  build_offset_ref_call_from_tree (tree fn, tree args)
  {
-   tree object_addr;
    tree orig_fn;
    tree orig_args;
    tree expr;
  
    orig_fn = fn;
    orig_args = args;
  
    if (processing_template_decl)
      {
-       tree object;
-       tree object_type;
- 
        my_friendly_assert (TREE_CODE (fn) == DOTSTAR_EXPR
  			  || TREE_CODE (fn) == MEMBER_REF,
  			  20030708);
--- 2943,2967 ----
    input_location = locus;
  }
  
! /* FN is an OFFSET_REF, DOTSTAR_EXPR or MEMBER_REF indicating the
!    function to call in parse-tree form; it has not yet been
!    semantically analyzed.  ARGS are the arguments to the function.
!    They have already been semantically analyzed.  */
  
  tree
  build_offset_ref_call_from_tree (tree fn, tree args)
  {
    tree orig_fn;
    tree orig_args;
    tree expr;
+   tree object;
  
    orig_fn = fn;
    orig_args = args;
+   object = TREE_OPERAND (fn, 0);
  
    if (processing_template_decl)
      {
        my_friendly_assert (TREE_CODE (fn) == DOTSTAR_EXPR
  			  || TREE_CODE (fn) == MEMBER_REF,
  			  20030708);
*************** build_offset_ref_call_from_tree (tree fn
*** 2975,2984 ****
  	 parameter.  That must be done before the FN is transformed
  	 because we depend on the form of FN.  */
        args = build_non_dependent_args (args);
-       object_type = TREE_TYPE (TREE_OPERAND (fn, 0));
        if (TREE_CODE (fn) == DOTSTAR_EXPR)
! 	object_type = build_pointer_type (non_reference (object_type));
!       object = build (NON_DEPENDENT_EXPR, object_type);
        args = tree_cons (NULL_TREE, object, args);
        /* Now that the arguments are done, transform FN.  */
        fn = build_non_dependent_expr (fn);
--- 2973,2981 ----
  	 parameter.  That must be done before the FN is transformed
  	 because we depend on the form of FN.  */
        args = build_non_dependent_args (args);
        if (TREE_CODE (fn) == DOTSTAR_EXPR)
! 	object = build_unary_op (ADDR_EXPR, object, 0);
!       object = build_non_dependent_expr (object);
        args = tree_cons (NULL_TREE, object, args);
        /* Now that the arguments are done, transform FN.  */
        fn = build_non_dependent_expr (fn);
*************** build_offset_ref_call_from_tree (tree fn
*** 2992,2998 ****
  	void B::g() { (this->*p)(); }  */
    if (TREE_CODE (fn) == OFFSET_REF)
      {
!       object_addr = build_unary_op (ADDR_EXPR, TREE_OPERAND (fn, 0), 0);
        fn = TREE_OPERAND (fn, 1);
        fn = get_member_function_from_ptrfunc (&object_addr, fn);
        args = tree_cons (NULL_TREE, object_addr, args);
--- 2989,2995 ----
  	void B::g() { (this->*p)(); }  */
    if (TREE_CODE (fn) == OFFSET_REF)
      {
!       tree object_addr = build_unary_op (ADDR_EXPR, object, 0);
        fn = TREE_OPERAND (fn, 1);
        fn = get_member_function_from_ptrfunc (&object_addr, fn);
        args = tree_cons (NULL_TREE, object_addr, args);
Index: cp/error.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/error.c,v
retrieving revision 1.230
diff -c -3 -p -r1.230 error.c
*** cp/error.c	10 Aug 2003 15:10:34 -0000	1.230
--- cp/error.c	15 Aug 2003 10:03:41 -0000
*************** dump_expr (tree t, int flags)
*** 1909,1917 ****
        break;
  
      case NON_DEPENDENT_EXPR:
!       pp_string (cxx_pp, "<expression of type ");
!       dump_type (TREE_TYPE (t), flags);
!       pp_greater (cxx_pp);
        break;
  
        /*  This list is incomplete, but should suffice for now.
--- 1909,1915 ----
        break;
  
      case NON_DEPENDENT_EXPR:
!       dump_expr (TREE_OPERAND (t, 0), flags);
        break;
  
        /*  This list is incomplete, but should suffice for now.
Index: cp/pt.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/pt.c,v
retrieving revision 1.754
diff -c -3 -p -r1.754 pt.c
*** cp/pt.c	10 Aug 2003 15:10:34 -0000	1.754
--- cp/pt.c	15 Aug 2003 10:04:12 -0000
*************** build_non_dependent_expr (tree expr)
*** 11809,11815 ****
       the expression so that mangling (say) "f<g>" inside the body of
       "f" works out correctly.  Therefore, the REFERENCE_TYPE is
       stripped here.  */
!   return build (NON_DEPENDENT_EXPR, non_reference (TREE_TYPE (expr)));
  }
  
  /* ARGS is a TREE_LIST of expressions as arguments to a function call.
--- 11814,11820 ----
       the expression so that mangling (say) "f<g>" inside the body of
       "f" works out correctly.  Therefore, the REFERENCE_TYPE is
       stripped here.  */
!   return build1 (NON_DEPENDENT_EXPR, non_reference (TREE_TYPE (expr)), expr);
  }
  
  /* ARGS is a TREE_LIST of expressions as arguments to a function call.

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