diff mbox

[C++] pushdecl and friends

Message ID 1ee6aaae-7e65-f06c-ea5d-dfd8584a5a70@acm.org
State New
Headers show

Commit Message

Nathan Sidwell May 11, 2017, 5:40 p.m. UTC
This patch reduces the variants of pushdecl by use of default arguments. 
  gone are the _maybe_friend variants.

nathan

Comments

Christophe Lyon May 11, 2017, 6:45 p.m. UTC | #1
Hi Nathan

On 11 May 2017 at 19:40, Nathan Sidwell <nathan@acm.org> wrote:
> This patch reduces the variants of pushdecl by use of default arguments.
> gone are the _maybe_friend variants.
>

Since this commit (r247918), GCC builds fail at least for aarch64/arm.
I've noticed this error message:
libtool: compile:  g++ -DHAVE_CONFIG_H -I.
-I/tmp/3713244_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/libcc1 -I
/tmp/3713244_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/li
bcc1/../include -I
/tmp/3713244_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/libcc1/../libgcc
-I ../gcc -I/tmp/3713244_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/libcc1/..
/gcc -I /tmp/3713244_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/libcc1/../gcc/c-family
-I /tmp/3713244_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/libcc1/../libcpp/includ
e -I /tmp/3713244_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/libcc1/../gcc/cp
-I/tmp/3713244_6.tmpdir/aci-gcc-fsf/builds/gcc-fsf-gccsrc/obj-aarch64-none-linux-gnu/gcc1/./
gmp -I/tmp/3713244_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gmp
-I/tmp/3713244_6.tmpdir/aci-gcc-fsf/builds/gcc-fsf-gccsrc/obj-aarch64-none-linux-gnu/gcc1/./mpfr/src
-I/
tmp/3713244_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/mpfr/src
-I/tmp/3713244_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/mpc/src -W
-Wall -fvisibility=hidden -g -O2 -MT
 libcp1plugin.lo -MD -MP -MF .deps/libcp1plugin.Tpo -c
/tmp/3713244_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/libcc1/libcp1plugin.cc
 -fPIC -DPIC -o .libs/libcp1plugin.o
/tmp/3713244_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/libcc1/libcp1plugin.cc:
In function ‘tree_node* safe_pushdecl_maybe_friend(tree_node*, bool)’:
/tmp/3713244_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/libcc1/libcp1plugin.cc:815:
error: ‘pushdecl_maybe_friend’ was not declared in this scope
make[3]: *** [libcp1plugin.lo] Error 1
make[3]: Leaving directory
`/tmp/3713244_6.tmpdir/aci-gcc-fsf/builds/gcc-fsf-gccsrc/obj-aarch64-none-linux-gnu/gcc1/libcc1'

I suspect it will be an obvious fix?

Thanks,

Christophe

> nathan
> --
> Nathan Sidwell
Nathan Sidwell May 11, 2017, 6:49 p.m. UTC | #2
On 05/11/2017 02:45 PM, Christophe Lyon wrote:

> `/tmp/3713244_6.tmpdir/aci-gcc-fsf/builds/gcc-fsf-gccsrc/obj-aarch64-none-linux-gnu/gcc1/libcc1'
> 
> I suspect it will be an obvious fix?

oh gee.  I committed the ChangeLog but not the changed file.   just 
done.  Hopefully soon the churn will be restricted to c++ FE.

nathan
Christophe Lyon May 11, 2017, 6:54 p.m. UTC | #3
On 11 May 2017 at 20:49, Nathan Sidwell <nathan@acm.org> wrote:
> On 05/11/2017 02:45 PM, Christophe Lyon wrote:
>
>>
>> `/tmp/3713244_6.tmpdir/aci-gcc-fsf/builds/gcc-fsf-gccsrc/obj-aarch64-none-linux-gnu/gcc1/libcc1'
>>
>> I suspect it will be an obvious fix?
>
>
> oh gee.  I committed the ChangeLog but not the changed file.   just done.

Did you really commit the ChangeLog for libcc1/libcp1plugin.cc ?

> Hopefully soon the churn will be restricted to c++ FE.
>
> nathan
>
> --
> Nathan Sidwell
Nathan Sidwell May 11, 2017, 7:16 p.m. UTC | #4
On 05/11/2017 02:54 PM, Christophe Lyon wrote:
> On 11 May 2017 at 20:49, Nathan Sidwell <nathan@acm.org> wrote:

>> oh gee.  I committed the ChangeLog but not the changed file.   just done.
> 

I have now ...

nathan
diff mbox

Patch

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

	* name-lookup.h (pushdecl): Add default friend parm.
	(pushdecl_maybe_friend): Delete.
	(pushdecl_top_level): Add default friend parm.
	(pushdecl_top_level_maybe_friend): Delete.
	* name-lookup.c (pushdecl_maybe_friend): Delete.
	(pushdecl): Add is_friend parm.
	(pushdecl_top_level): Add is friend_parm.
	(pushdecl_top_level_maybe_friend, pushdecl_top_level_1): Delete.
	(pushdecl_top_level_and_finish): Do pushing and finishing directly.
	* friend.c (do_friend): Adjust.
	* pt.c (tsubst_friend_class): Adjust.

Index: friend.c
===================================================================
--- friend.c	(revision 247916)
+++ friend.c	(working copy)
@@ -620,7 +620,7 @@  do_friend (tree ctype, tree declarator,
 		 declaration, the program is ill-formed.  */
 	      tree t = lookup_name_innermost_nonclass_level (DECL_NAME (decl));
 	      if (t)
-		decl = pushdecl_maybe_friend (decl, /*is_friend=*/true);
+		decl = pushdecl (decl, /*is_friend=*/true);
 	      else
 		{
 		  error ("friend declaration %qD in local class without "
Index: name-lookup.c
===================================================================
--- name-lookup.c	(revision 247916)
+++ name-lookup.c	(working copy)
@@ -1862,10 +1862,11 @@  pushdecl_maybe_friend_1 (tree x, bool is
   return x;
 }
 
-/* Wrapper for pushdecl_maybe_friend_1.  */
+/* Record a decl-node X as belonging to the current lexical scope.
+   It's a friend if IS_FRIEND is true.  */
 
 tree
-pushdecl_maybe_friend (tree x, bool is_friend)
+pushdecl (tree x, bool is_friend)
 {
   tree ret;
   bool subtime = timevar_cond_start (TV_NAME_LOOKUP);
@@ -1874,14 +1875,6 @@  pushdecl_maybe_friend (tree x, bool is_f
   return ret;
 }
 
-/* Record a decl-node X as belonging to the current lexical scope.  */
-
-tree
-pushdecl (tree x)
-{
-  return pushdecl_maybe_friend (x, false);
-}
-
 /* Enter DECL into the symbol table, if that's appropriate.  Returns
    DECL, or a modified version thereof.  */
 
@@ -2862,7 +2855,7 @@  pushdecl_with_scope_1 (tree x, cp_bindin
     {
       b = current_binding_level;
       current_binding_level = level;
-      x = pushdecl_maybe_friend (x, is_friend);
+      x = pushdecl (x, is_friend);
       current_binding_level = b;
     }
   current_function_decl = function_decl;
@@ -4548,47 +4541,30 @@  parse_using_directive (tree name_space,
     }
 }
 
-/* Like pushdecl, only it places X in the global scope if appropriate.
-   Calls cp_finish_decl to register the variable, initializing it with
-   *INIT, if INIT is non-NULL.  */
+/* Pushes X into the global namespace.  */
 
-static tree
-pushdecl_top_level_1 (tree x, tree *init, bool is_friend)
+tree
+pushdecl_top_level (tree x, bool is_friend)
 {
   bool subtime = timevar_cond_start (TV_NAME_LOOKUP);
   push_to_top_level ();
   x = pushdecl_namespace_level (x, is_friend);
-  if (init)
-    cp_finish_decl (x, *init, false, NULL_TREE, 0);
   pop_from_top_level ();
   timevar_cond_stop (TV_NAME_LOOKUP, subtime);
   return x;
 }
 
-/* Like pushdecl, only it places X in the global scope if appropriate.  */
-
-tree
-pushdecl_top_level (tree x)
-{
-  return pushdecl_top_level_1 (x, NULL, false);
-}
-
-/* Like pushdecl_top_level, but adding the IS_FRIEND parameter.  */
-
-tree
-pushdecl_top_level_maybe_friend (tree x, bool is_friend)
-{
-  return pushdecl_top_level_1 (x, NULL, is_friend);
-}
-
-/* Like pushdecl, only it places X in the global scope if
-   appropriate.  Calls cp_finish_decl to register the variable,
-   initializing it with INIT.  */
+/* Pushes X into the global namespace and Calls cp_finish_decl to
+   register the variable, initializing it with INIT.  */
 
 tree
 pushdecl_top_level_and_finish (tree x, tree init)
 {
-  return pushdecl_top_level_1 (x, &init, false);
+  push_to_top_level ();
+  x = pushdecl_namespace_level (x, false);
+  cp_finish_decl (x, init, false, NULL_TREE, 0);
+  pop_from_top_level ();
+  return x;
 }
 
 /* Combines two sets of overloaded functions into an OVERLOAD chain, removing
Index: name-lookup.h
===================================================================
--- name-lookup.h	(revision 247916)
+++ name-lookup.h	(working copy)
@@ -335,11 +335,9 @@  extern tree innermost_non_namespace_valu
 extern cxx_binding *outer_binding (tree, cxx_binding *, bool);
 extern void cp_emit_debug_info_for_using (tree, tree);
 
-extern tree pushdecl_maybe_friend (tree, bool is_friend);
-extern tree pushdecl (tree);
 extern tree pushdecl_outermost_localscope (tree);
-extern tree pushdecl_top_level_maybe_friend (tree, bool is_friend);
-extern tree pushdecl_top_level (tree);
+extern tree pushdecl (tree, bool is_friend = false);
+extern tree pushdecl_top_level (tree, bool is_friend = false);
 extern tree pushdecl_top_level_and_finish (tree, tree);
 extern tree pushtag (tree, tree, tag_scope);
 extern bool push_namespace (tree);
Index: pt.c
===================================================================
--- pt.c	(revision 247916)
+++ pt.c	(working copy)
@@ -9920,7 +9920,7 @@  tsubst_friend_class (tree friend_tmpl, t
 	= INNERMOST_TEMPLATE_ARGS (CLASSTYPE_TI_ARGS (TREE_TYPE (tmpl)));
 
       /* Inject this template into the global scope.  */
-      friend_type = TREE_TYPE (pushdecl_top_level_maybe_friend (tmpl, true));
+      friend_type = TREE_TYPE (pushdecl_top_level (tmpl, true));
     }
 
   if (context != global_namespace)