public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [C++ PATCH] function decl pushing
@ 2017-05-08 18:20 Nathan Sidwell
  0 siblings, 0 replies; only message in thread
From: Nathan Sidwell @ 2017-05-08 18:20 UTC (permalink / raw)
  To: GCC Patches

[-- Attachment #1: Type: text/plain, Size: 606 bytes --]

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

[-- Attachment #2: ann.diff --]
[-- Type: text/x-patch, Size: 2740 bytes --]

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2017-05-08 18:02 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-08 18:20 [C++ PATCH] function decl pushing Nathan Sidwell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).