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] function decl pushing


This patch implements a couple of changes.

1) set DECL_ANTICIPATED before pushing an anticipated builtin. My overload management changes will keep the overload list ordered, so needs to know this up front.

2) pushdecl has some funky code to detect when we're trying to push a function decl into its own scope. And push into its containing scope in that case. But we only need that subterfuge because start_preparsed_function sets current_function_decl, before pushing the decl itself. Reordering the order of events there will make pushdecl's weirdness unnecessary.

nathan
--
Nathan Sidwell
2017-05-08  Nathan Sidwell  <nathan@acm.org>

	* decl.c (builtin_function_1): Set DCL_ANTICIPATED before pushing.
	(start_preparsed_function): Do decl pushing before setting
	current_funciton_decl and announcing it.

Index: decl.c
===================================================================
--- decl.c	(revision 247752)
+++ decl.c	(working copy)
@@ -4375,11 +4375,6 @@ builtin_function_1 (tree decl, tree cont
 
   DECL_CONTEXT (decl) = context;
 
-  if (is_global)
-    pushdecl_top_level (decl);
-  else
-    pushdecl (decl);
-
   /* A function in the user's namespace should have an explicit
      declaration before it is used.  Mark the built-in function as
      anticipated but not actually declared.  */
@@ -4397,6 +4392,11 @@ builtin_function_1 (tree decl, tree cont
 	DECL_ANTICIPATED (decl) = 1;
     }
 
+  if (is_global)
+    pushdecl_top_level (decl);
+  else
+    pushdecl (decl);
+
   return decl;
 }
 
@@ -14821,17 +14821,10 @@ start_preparsed_function (tree decl1, tr
       decl1 = newdecl1;
     }
 
-  /* We are now in the scope of the function being defined.  */
-  current_function_decl = decl1;
-
-  /* Save the parm names or decls from this function's declarator
-     where store_parm_decls will find them.  */
-  current_function_parms = DECL_ARGUMENTS (decl1);
-
   /* Make sure the parameter and return types are reasonable.  When
      you declare a function, these types can be incomplete, but they
      must be complete when you define the function.  */
-  check_function_type (decl1, current_function_parms);
+  check_function_type (decl1, DECL_ARGUMENTS (decl1));
 
   /* Build the return declaration for the function.  */
   restype = TREE_TYPE (fntype);
@@ -14848,9 +14841,6 @@ start_preparsed_function (tree decl1, tr
       cp_apply_type_quals_to_decl (cp_type_quals (restype), resdecl);
     }
 
-  /* Let the user know we're compiling this function.  */
-  announce_function (decl1);
-
   /* Record the decl so that the function name is defined.
      If we already have a decl for this name, and it is a FUNCTION_DECL,
      use the old decl.  */
@@ -14922,9 +14912,16 @@ start_preparsed_function (tree decl1, tr
 	maybe_apply_pragma_weak (decl1);
     }
 
-  /* Reset this in case the call to pushdecl changed it.  */
+  /* We are now in the scope of the function being defined.  */
   current_function_decl = decl1;
 
+  /* Save the parm names or decls from this function's declarator
+     where store_parm_decls will find them.  */
+  current_function_parms = DECL_ARGUMENTS (decl1);
+
+  /* Let the user know we're compiling this function.  */
+  announce_function (decl1);
+
   gcc_assert (DECL_INITIAL (decl1));
 
   /* This function may already have been parsed, in which case just

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