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 to start_function


The 'vector' attribute affects the return value of a function, so it's
important that the attributes be applied before DECL_RESULT is built.

Another DECL_RESULT issue I noticed while looking at this is that we were
trying to set it in two different places in start_function.  I've combinde
those.

Functionality tested on a cross compiler for Altivec
powerpc-unknown-linux-gnu, regression tested i686-pc-linux-gnu.

2002-02-04  Jason Merrill  <jason@redhat.com>

	* decl.c (start_function): Call cplus_decl_attributes immediately
	after grokdeclarator.

	* decl.c (start_function): Combine DECL_RESULT handling code.

*** decl.c.~1~	Mon Feb  4 13:15:13 2002
--- decl.c	Mon Feb  4 13:33:23 2002
*************** start_function (declspecs, declarator, a
*** 13481,13487 ****
        decl1 = grokdeclarator (declarator, declspecs, FUNCDEF, 1, NULL);
        /* If the declarator is not suitable for a function definition,
  	 cause a syntax error.  */
!       if (decl1 == NULL_TREE || TREE_CODE (decl1) != FUNCTION_DECL) return 0;
  
        fntype = TREE_TYPE (decl1);
  
--- 13481,13490 ----
        decl1 = grokdeclarator (declarator, declspecs, FUNCDEF, 1, NULL);
        /* If the declarator is not suitable for a function definition,
  	 cause a syntax error.  */
!       if (decl1 == NULL_TREE || TREE_CODE (decl1) != FUNCTION_DECL)
! 	return 0;
! 
!       cplus_decl_attributes (&decl1, attrs, 0);
  
        fntype = TREE_TYPE (decl1);
  
*************** start_function (declspecs, declarator, a
*** 13595,13613 ****
  
    /* Build the return declaration for the function.  */
    restype = TREE_TYPE (fntype);
!   if (!processing_template_decl)
      {
!       if (!DECL_RESULT (decl1))
! 	{
! 	  DECL_RESULT (decl1)
! 	    = build_decl (RESULT_DECL, 0, TYPE_MAIN_VARIANT (restype));
! 	  c_apply_type_quals_to_decl (cp_type_quals (restype),
! 				      DECL_RESULT (decl1));
! 	}
      }
-   else
-     /* Just use `void'.  Nobody will ever look at this anyhow.  */
-     DECL_RESULT (decl1) = build_decl (RESULT_DECL, 0, void_type_node);
  
    /* Initialize RTL machinery.  We cannot do this until
       CURRENT_FUNCTION_DECL and DECL_RESULT are set up.  We do this
--- 13598,13613 ----
  
    /* Build the return declaration for the function.  */
    restype = TREE_TYPE (fntype);
!   /* Promote the value to int before returning it.  */
!   if (c_promoting_integer_type_p (restype))
!     restype = type_promotes_to (restype);
!   if (DECL_RESULT (decl1) == NULL_TREE)
      {
!       DECL_RESULT (decl1)
! 	= build_decl (RESULT_DECL, 0, TYPE_MAIN_VARIANT (restype));
!       c_apply_type_quals_to_decl (cp_type_quals (restype),
! 				  DECL_RESULT (decl1));
      }
  
    /* Initialize RTL machinery.  We cannot do this until
       CURRENT_FUNCTION_DECL and DECL_RESULT are set up.  We do this
*************** start_function (declspecs, declarator, a
*** 13768,13787 ****
    pushlevel (0);
    current_binding_level->parm_flag = 1;
  
-   cplus_decl_attributes (&decl1, attrs, 0);
- 
-   /* Promote the value to int before returning it.  */
-   if (c_promoting_integer_type_p (restype))
-     restype = type_promotes_to (restype);
- 
-   if (DECL_RESULT (decl1) == NULL_TREE)
-     {
-       DECL_RESULT (decl1)
- 	= build_decl (RESULT_DECL, 0, TYPE_MAIN_VARIANT (restype));
-       TREE_READONLY (DECL_RESULT (decl1)) = CP_TYPE_CONST_P (restype);
-       TREE_THIS_VOLATILE (DECL_RESULT (decl1)) = CP_TYPE_VOLATILE_P (restype);
-     }
- 
    ++function_depth;
  
    if (DECL_DESTRUCTOR_P (decl1))
--- 13768,13773 ----

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