public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH]: Remove staticp langhook
@ 2007-04-05 21:28 Daniel Berlin
  2007-04-06 21:12 ` Mark Mitchell
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Daniel Berlin @ 2007-04-05 21:28 UTC (permalink / raw)
  To: gcc-patches >> GCC Patches; +Cc: Mark Mitchell, Ian Lance Taylor

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

This langhook is a remnant from a time when expand had to handle all
the frontend specific trees.
This is no longer the case, and as such, all the implementations of
this are dead code.

I have added asserts in place of the langhook use on the off chance
someone out-of-tree is trying to still throw lang-specific trees at
expand.

Bootstrapped and regtested on i686-pc-linux-gnu and i686-darwin.
Okay for mainline?

In /
2007-04-05  Daniel Berlin  <dberlin@dberlin.org>

	* tree.c (staticp): No longer use staticp langhook.
	* langhooks.c (lhd_staticp): Removed.
	* langhooks.h (struct lang_hooks): Remove staticp.
	* c-common.c (c_staticp): Remove.
	* c-common.h (c_staticp): Ditto.
	* langhooks-defs.h (lhd_staticp): Ditto.
	(LHD_HOOKS_STATICP): Ditto

In cp/
2007-04-05  Daniel Berlin  <dberlin@dberlin.org>

	* cp-objcp-common.c (cxx_staticp): Remove.
	* cp-objcp-common.h (LANG_HOOKS_STATICP): Remove.
	* cp-tree.h (cxx_staticp):

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: removestaticp.diff --]
[-- Type: text/x-diff; name="removestaticp.diff", Size: 5476 bytes --]

--- tree.c	(revision 2902)
+++ tree.c	(revision 2903)
@@ -1986,10 +1986,7 @@ staticp (tree arg)
       return arg;
 
     case COMPONENT_REF:
-      /* If the thing being referenced is not a field, then it is
-	 something language specific.  */
-      if (TREE_CODE (TREE_OPERAND (arg, 1)) != FIELD_DECL)
-	return (*lang_hooks.staticp) (arg);
+      gcc_assert (TREE_CODE (TREE_OPERAND (arg, 1)) == FIELD_DECL)
 
       /* If we are referencing a bitfield, we can't evaluate an
 	 ADDR_EXPR at compile time and so it isn't a constant.  */
@@ -2015,11 +2012,8 @@ staticp (tree arg)
 	return false;
 
     default:
-      if ((unsigned int) TREE_CODE (arg)
-	  >= (unsigned int) LAST_AND_UNUSED_TREE_CODE)
-	return lang_hooks.staticp (arg);
-      else
-	return NULL;
+      gcc_assert (TREE_CODE (arg) <= LAST_AND_UNUSED_TREE_CODE);
+      return NULL;
     }
 }
 \f
--- cp/cp-objcp-common.c	(revision 2902)
+++ cp/cp-objcp-common.c	(revision 2903)
@@ -200,21 +200,6 @@ cxx_types_compatible_p (tree x, tree y)
   return 0;
 }
 
-tree
-cxx_staticp (tree arg)
-{
-  switch (TREE_CODE (arg))
-    {
-    case BASELINK:
-      return staticp (BASELINK_FUNCTIONS (arg));
-
-    default:
-      break;
-    }
-  
-  return NULL_TREE;
-}
-
 /* Stubs to keep c-opts.c happy.  */
 void
 push_file_scope (void)
--- cp/cp-objcp-common.h	(revision 2902)
+++ cp/cp-objcp-common.h	(revision 2903)
@@ -59,8 +59,6 @@ extern tree objcp_tsubst_copy_and_build 
 #define LANG_HOOKS_EXPAND_DECL c_expand_decl
 #undef LANG_HOOKS_PARSE_FILE
 #define LANG_HOOKS_PARSE_FILE c_common_parse_file
-#undef LANG_HOOKS_STATICP
-#define LANG_HOOKS_STATICP cxx_staticp
 #undef LANG_HOOKS_DUP_LANG_SPECIFIC_DECL
 #define LANG_HOOKS_DUP_LANG_SPECIFIC_DECL cxx_dup_lang_specific_decl
 #undef LANG_HOOKS_SET_DECL_ASSEMBLER_NAME
--- cp/cp-tree.h	(revision 2902)
+++ cp/cp-tree.h	(revision 2903)
@@ -4816,7 +4816,6 @@ extern bool cp_var_mod_type_p			(tree, t
 extern void cxx_initialize_diagnostics		(struct diagnostic_context *);
 extern int cxx_types_compatible_p		(tree, tree);
 extern void init_shadowed_var_for_decl		(void);
-extern tree cxx_staticp                         (tree);
 
 /* in cp-gimplify.c */
 extern int cp_gimplify_expr			(tree *, tree *, tree *);
--- c-objc-common.h	(revision 2902)
+++ c-objc-common.h	(revision 2903)
@@ -56,8 +56,6 @@ extern void c_initialize_diagnostics (di
 #define LANG_HOOKS_FINISH_INCOMPLETE_DECL c_finish_incomplete_decl
 #undef LANG_HOOKS_REDUCE_BIT_FIELD_OPERATIONS
 #define LANG_HOOKS_REDUCE_BIT_FIELD_OPERATIONS true
-#undef LANG_HOOKS_STATICP
-#define LANG_HOOKS_STATICP c_staticp
 #undef LANG_HOOKS_NO_BODY_BLOCKS
 #define LANG_HOOKS_NO_BODY_BLOCKS true
 #undef LANG_HOOKS_WARN_UNUSED_GLOBAL_DECL
--- langhooks.c	(revision 2902)
+++ langhooks.c	(revision 2903)
@@ -125,14 +125,6 @@ lhd_safe_from_p (rtx ARG_UNUSED (x), tre
   return 1;
 }
 
-/* Called from staticp.  */
-
-tree
-lhd_staticp (tree ARG_UNUSED (exp))
-{
-  return NULL;
-}
-
 /* Called from check_global_declarations.  */
 
 bool
--- langhooks.h	(revision 2902)
+++ langhooks.h	(revision 2903)
@@ -333,9 +333,6 @@ struct lang_hooks
      successful.  */
   bool (*mark_addressable) (tree);
 
-  /* Hook called by staticp for language-specific tree codes.  */
-  tree (*staticp) (tree);
-
   /* Replace the DECL_LANG_SPECIFIC data, which may be NULL, of the
      DECL_NODE with a newly GC-allocated copy.  */
   void (*dup_lang_specific_decl) (tree);
--- c-common.c	(revision 2902)
+++ c-common.c	(revision 2903)
@@ -4294,15 +4294,6 @@ c_expand_body (tree fndecl)
 				decl_fini_priority_lookup (fndecl));
 }
 
-/* Hook used by staticp to handle language-specific tree codes.  */
-
-tree
-c_staticp (tree exp)
-{
-  return (TREE_CODE (exp) == COMPOUND_LITERAL_EXPR
-	  && TREE_STATIC (COMPOUND_LITERAL_EXPR_DECL (exp))
-	  ? exp : NULL);
-}
 \f
 
 /* Given a boolean expression ARG, return a tree representing an increment
--- c-common.h	(revision 2902)
+++ c-common.h	(revision 2903)
@@ -825,8 +825,6 @@ extern bool vector_types_convertible_p (
 extern rtx c_expand_expr (tree, rtx, enum machine_mode, int, rtx *);
 extern void c_expand_body (tree);
 
-extern tree c_staticp (tree);
-
 extern void init_c_lex (void);
 
 extern void c_cpp_builtins (cpp_reader *);
--- langhooks-def.h	(revision 2902)
+++ langhooks-def.h	(revision 2903)
@@ -50,7 +50,6 @@ extern tree lhd_return_null_tree_v (void
 extern tree lhd_return_null_tree (tree);
 extern tree lhd_do_nothing_iii_return_null_tree (int, int, int);
 extern int lhd_safe_from_p (rtx, tree);
-extern tree lhd_staticp (tree);
 extern void lhd_print_tree_nothing (FILE *, tree, int);
 extern const char *lhd_decl_printable_name (tree, int);
 extern const char *lhd_dwarf_name (tree, int);
@@ -112,7 +111,6 @@ extern void lhd_omp_firstprivatize_type_
 #define LANG_HOOKS_EXPAND_DECL		lhd_expand_decl
 #define LANG_HOOKS_SAFE_FROM_P		lhd_safe_from_p
 #define LANG_HOOKS_FINISH_INCOMPLETE_DECL lhd_do_nothing_t
-#define LANG_HOOKS_STATICP		lhd_staticp
 #define LANG_HOOKS_DUP_LANG_SPECIFIC_DECL lhd_do_nothing_t
 #define LANG_HOOKS_SET_DECL_ASSEMBLER_NAME lhd_set_decl_assembler_name
 #define LANG_HOOKS_REDUCE_BIT_FIELD_OPERATIONS false
@@ -299,7 +297,6 @@ extern tree lhd_make_node (enum tree_cod
   LANG_HOOKS_SAFE_FROM_P, \
   LANG_HOOKS_FINISH_INCOMPLETE_DECL, \
   LANG_HOOKS_MARK_ADDRESSABLE, \
-  LANG_HOOKS_STATICP, \
   LANG_HOOKS_DUP_LANG_SPECIFIC_DECL, \
   LANG_HOOKS_SET_DECL_ASSEMBLER_NAME, \
   LANG_HOOKS_REDUCE_BIT_FIELD_OPERATIONS, \

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH]: Remove staticp langhook
  2007-04-05 21:28 [PATCH]: Remove staticp langhook Daniel Berlin
@ 2007-04-06 21:12 ` Mark Mitchell
  2007-04-06 23:59   ` Daniel Berlin
  2007-04-07  9:23 ` Andreas Schwab
  2007-04-07 23:05 ` Daniel Berlin
  2 siblings, 1 reply; 7+ messages in thread
From: Mark Mitchell @ 2007-04-06 21:12 UTC (permalink / raw)
  To: Daniel Berlin; +Cc: gcc-patches >> GCC Patches, Ian Lance Taylor

Daniel Berlin wrote:

> In /
> 2007-04-05  Daniel Berlin  <dberlin@dberlin.org>
> 
>     * tree.c (staticp): No longer use staticp langhook.
>     * langhooks.c (lhd_staticp): Removed.
>     * langhooks.h (struct lang_hooks): Remove staticp.
>     * c-common.c (c_staticp): Remove.
>     * c-common.h (c_staticp): Ditto.
>     * langhooks-defs.h (lhd_staticp): Ditto.
>     (LHD_HOOKS_STATICP): Ditto
> 
> In cp/
> 2007-04-05  Daniel Berlin  <dberlin@dberlin.org>
> 
>     * cp-objcp-common.c (cxx_staticp): Remove.
>     * cp-objcp-common.h (LANG_HOOKS_STATICP): Remove.
>     * cp-tree.h (cxx_staticp):

How pleasant that this works!

Yes, this patch is fine, but please add a comment before:

> +      gcc_assert (TREE_CODE (arg) <= LAST_AND_UNUSED_TREE_CODE);

like so:

  /* All language-specific nodes should already have been lowered.  */

just so we know what that's for.  Or, even better, create a
gcc_assert_lowered macro and use that.  This isn't a big deal; if you're
not in the mood, just add the comment and check this in.

-- 
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH]: Remove staticp langhook
  2007-04-06 21:12 ` Mark Mitchell
@ 2007-04-06 23:59   ` Daniel Berlin
  0 siblings, 0 replies; 7+ messages in thread
From: Daniel Berlin @ 2007-04-06 23:59 UTC (permalink / raw)
  To: Mark Mitchell; +Cc: gcc-patches >> GCC Patches, Ian Lance Taylor

On 4/6/07, Mark Mitchell <mark@codesourcery.com> wrote:
> Daniel Berlin wrote:
>
> > In /
> > 2007-04-05  Daniel Berlin  <dberlin@dberlin.org>
> >
> >     * tree.c (staticp): No longer use staticp langhook.
> >     * langhooks.c (lhd_staticp): Removed.
> >     * langhooks.h (struct lang_hooks): Remove staticp.
> >     * c-common.c (c_staticp): Remove.
> >     * c-common.h (c_staticp): Ditto.
> >     * langhooks-defs.h (lhd_staticp): Ditto.
> >     (LHD_HOOKS_STATICP): Ditto
> >
> > In cp/
> > 2007-04-05  Daniel Berlin  <dberlin@dberlin.org>
> >
> >     * cp-objcp-common.c (cxx_staticp): Remove.
> >     * cp-objcp-common.h (LANG_HOOKS_STATICP): Remove.
> >     * cp-tree.h (cxx_staticp):
>
> How pleasant that this works!
>
> Yes, this patch is fine, but please add a comment before:
>
> > +      gcc_assert (TREE_CODE (arg) <= LAST_AND_UNUSED_TREE_CODE);
>
> like so:
>
>   /* All language-specific nodes should already have been lowered.  */
>
> just so we know what that's for.  Or, even better, create a
> gcc_assert_lowered macro and use that.  This isn't a big deal; if you're
> not in the mood, just add the comment and check this in.

I added it to tree.h, and am checking this in.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH]: Remove staticp langhook
  2007-04-05 21:28 [PATCH]: Remove staticp langhook Daniel Berlin
  2007-04-06 21:12 ` Mark Mitchell
@ 2007-04-07  9:23 ` Andreas Schwab
  2007-04-07 22:39   ` Daniel Berlin
  2007-04-07 23:05 ` Daniel Berlin
  2 siblings, 1 reply; 7+ messages in thread
From: Andreas Schwab @ 2007-04-07  9:23 UTC (permalink / raw)
  To: Daniel Berlin
  Cc: gcc-patches >> GCC Patches, Mark Mitchell, Ian Lance Taylor

"Daniel Berlin" <dberlin@dberlin.org> writes:

> This langhook is a remnant from a time when expand had to handle all
> the frontend specific trees.
> This is no longer the case, and as such, all the implementations of
> this are dead code.
>
> I have added asserts in place of the langhook use on the off chance
> someone out-of-tree is trying to still throw lang-specific trees at
> expand.

Apparently the Ada frontend doesn't behave.

+===========================GNAT BUG DETECTED==============================+
| 4.3.0 20070407 (experimental) (ia64-suse-linux-gnu) GCC error:           |
| in staticp, at tree.c:2017                                               |
| Error detected around ../../gcc/ada/memtrack.adb:163                     |

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH]: Remove staticp langhook
  2007-04-07  9:23 ` Andreas Schwab
@ 2007-04-07 22:39   ` Daniel Berlin
  0 siblings, 0 replies; 7+ messages in thread
From: Daniel Berlin @ 2007-04-07 22:39 UTC (permalink / raw)
  To: Andreas Schwab
  Cc: gcc-patches >> GCC Patches, Mark Mitchell, Ian Lance Taylor

On 4/7/07, Andreas Schwab <schwab@suse.de> wrote:
> "Daniel Berlin" <dberlin@dberlin.org> writes:
>
> > This langhook is a remnant from a time when expand had to handle all
> > the frontend specific trees.
> > This is no longer the case, and as such, all the implementations of
> > this are dead code.
> >
> > I have added asserts in place of the langhook use on the off chance
> > someone out-of-tree is trying to still throw lang-specific trees at
> > expand.
>
> Apparently the Ada frontend doesn't behave.
>
> +===========================GNAT BUG DETECTED==============================+
> | 4.3.0 20070407 (experimental) (ia64-suse-linux-gnu) GCC error:           |
> | in staticp, at tree.c:2017                                               |
> | Error detected around ../../gcc/ada/memtrack.adb:163                     |
>

Sorry, I don't have a machine that builds Ada right now (darwin).
The Ada frontend didn't implement this langhook, so it would have
always gotten NULL on any non-lowered tree.
I don't know why they are trying to use staticp, it looks like they
are effectively trying to get the same result that TREE_STATIC (arg)
|| (DECL_P (arg) && DECL_EXTERNAL), but i'm not positive.
They never actually use the result it returns, just check it for
whether it is NULL.

In any case, if you simply remove the assert, the Ada frontend will
get the result it used to, since again, it didn't implement this
langhook.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH]: Remove staticp langhook
  2007-04-05 21:28 [PATCH]: Remove staticp langhook Daniel Berlin
  2007-04-06 21:12 ` Mark Mitchell
  2007-04-07  9:23 ` Andreas Schwab
@ 2007-04-07 23:05 ` Daniel Berlin
  2007-04-08 14:42   ` Daniel Berlin
  2 siblings, 1 reply; 7+ messages in thread
From: Daniel Berlin @ 2007-04-07 23:05 UTC (permalink / raw)
  To: gcc-patches >> GCC Patches; +Cc: Mark Mitchell, Ian Lance Taylor

As this is causing failures in C for some people, i'm reverting it.
It looks like we try to use it for determining whether initializer
constants are valid in C, and hand it compound literals.

Shame, since all we do in that case is check TREE_STATIC on them, but
I really don't want to go mucking through to see what is up.

For purposes of the middle end, we can just switch the langhook to the
default after the frontends are done processing, which is all I really
care about.

On 4/5/07, Daniel Berlin <dberlin@dberlin.org> wrote:
> This langhook is a remnant from a time when expand had to handle all
> the frontend specific trees.
> This is no longer the case, and as such, all the implementations of
> this are dead code.
>
> I have added asserts in place of the langhook use on the off chance
> someone out-of-tree is trying to still throw lang-specific trees at
> expand.
>
> Bootstrapped and regtested on i686-pc-linux-gnu and i686-darwin.
> Okay for mainline?
>
> In /
> 2007-04-05  Daniel Berlin  <dberlin@dberlin.org>
>
>         * tree.c (staticp): No longer use staticp langhook.
>         * langhooks.c (lhd_staticp): Removed.
>         * langhooks.h (struct lang_hooks): Remove staticp.
>         * c-common.c (c_staticp): Remove.
>         * c-common.h (c_staticp): Ditto.
>         * langhooks-defs.h (lhd_staticp): Ditto.
>         (LHD_HOOKS_STATICP): Ditto
>
> In cp/
> 2007-04-05  Daniel Berlin  <dberlin@dberlin.org>
>
>         * cp-objcp-common.c (cxx_staticp): Remove.
>         * cp-objcp-common.h (LANG_HOOKS_STATICP): Remove.
>         * cp-tree.h (cxx_staticp):
>
>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH]: Remove staticp langhook
  2007-04-07 23:05 ` Daniel Berlin
@ 2007-04-08 14:42   ` Daniel Berlin
  0 siblings, 0 replies; 7+ messages in thread
From: Daniel Berlin @ 2007-04-08 14:42 UTC (permalink / raw)
  To: gcc-patches >> GCC Patches

As a final followup, I discovered why I did not see these failures.
I was regtesting the wrong tree (the one with the other langhook removal).
Sigh.
The patch is now reverted, so all the failures should be gone

On 4/7/07, Daniel Berlin <dberlin@dberlin.org> wrote:
> As this is causing failures in C for some people, i'm reverting it.
> It looks like we try to use it for determining whether initializer
> constants are valid in C, and hand it compound literals.
>
> Shame, since all we do in that case is check TREE_STATIC on them, but
> I really don't want to go mucking through to see what is up.
>
> For purposes of the middle end, we can just switch the langhook to the
> default after the frontends are done processing, which is all I really
> care about.
>

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2007-04-08 14:42 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-04-05 21:28 [PATCH]: Remove staticp langhook Daniel Berlin
2007-04-06 21:12 ` Mark Mitchell
2007-04-06 23:59   ` Daniel Berlin
2007-04-07  9:23 ` Andreas Schwab
2007-04-07 22:39   ` Daniel Berlin
2007-04-07 23:05 ` Daniel Berlin
2007-04-08 14:42   ` Daniel Berlin

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).