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]

Patch to add language hook in staticp


This patch adds a language hook into staticp, which is needed to
implement C99 semantics for compound literals (which have static
storage duration if outside any functions, but will have a
language-specific tree code).

Bootstrapped with no regressions on i686-pc-linux-gnu.  OK to commit?

2001-12-03  Joseph S. Myers  <jsm28@cam.ac.uk>

	* langhooks.h (struct lang_hooks): Add staticp.
	* langhooks-def.h (lhd_staticp, LANG_HOOKS_STATICP): New.
	(LANG_HOOKS_INITIALIZER): Add LANG_HOOKS_STATICP.
	* langhooks.c (lhd_staticp): New function.
	* tree.c (staticp): Call lang_hooks.staticp for language-specific
	tree codes.

diff -rupN gcc.orig/langhooks-def.h gcc/langhooks-def.h
--- gcc.orig/langhooks-def.h	Tue Nov 27 17:38:09 2001
+++ gcc/langhooks-def.h	Mon Dec  3 01:19:28 2001
@@ -42,6 +42,7 @@ extern int lhd_decode_option PARAMS ((in
 extern HOST_WIDE_INT lhd_get_alias_set PARAMS ((tree));
 extern tree lhd_return_tree PARAMS ((tree));
 extern int lhd_safe_from_p PARAMS ((rtx, tree));
+extern int lhd_staticp PARAMS ((tree));
 extern void lhd_clear_binding_stack PARAMS ((void));
 extern void lhd_print_tree_nothing PARAMS ((FILE *, tree, int));
 extern void lhd_set_yydebug PARAMS ((int));
@@ -71,6 +72,7 @@ int lhd_tree_inlining_anon_aggr_type_p		
 #define LANG_HOOKS_GET_ALIAS_SET	lhd_get_alias_set
 #define LANG_HOOKS_EXPAND_CONSTANT	lhd_return_tree
 #define LANG_HOOKS_SAFE_FROM_P		lhd_safe_from_p
+#define LANG_HOOKS_STATICP		lhd_staticp
 #define LANG_HOOKS_HONOR_READONLY	false
 #define LANG_HOOKS_PRINT_STATISTICS	lhd_do_nothing
 #define LANG_HOOKS_PRINT_XNODE		lhd_print_tree_nothing
@@ -132,6 +134,7 @@ int lhd_tree_dump_type_quals			PARAMS ((
   LANG_HOOKS_GET_ALIAS_SET, \
   LANG_HOOKS_EXPAND_CONSTANT, \
   LANG_HOOKS_SAFE_FROM_P, \
+  LANG_HOOKS_STATICP, \
   LANG_HOOKS_HONOR_READONLY, \
   LANG_HOOKS_PRINT_STATISTICS, \
   LANG_HOOKS_PRINT_XNODE, \
diff -rupN gcc.orig/langhooks.c gcc/langhooks.c
--- gcc.orig/langhooks.c	Wed Nov 28 17:41:33 2001
+++ gcc/langhooks.c	Mon Dec  3 01:22:06 2001
@@ -77,6 +77,15 @@ lhd_safe_from_p (x, exp)
   return 1;
 }
 
+/* Called from staticp.  */
+
+int
+lhd_staticp (exp)
+     tree exp;
+{
+  return 0;
+}
+
 /* Called when -dy is given on the command line.  */
 
 void
diff -rupN gcc.orig/langhooks.h gcc/langhooks.h
--- gcc.orig/langhooks.h	Tue Nov 27 17:38:09 2001
+++ gcc/langhooks.h	Mon Dec  3 01:21:25 2001
@@ -123,6 +123,9 @@ struct lang_hooks
      parameter.  */
   int (*safe_from_p) PARAMS ((rtx, tree));
 
+  /* Hook called by staticp for language-specific tree codes.  */
+  int (*staticp) PARAMS ((tree));
+
   /* Nonzero if TYPE_READONLY and TREE_READONLY should always be honored.  */
   bool honor_readonly;
 
diff -rupN gcc.orig/tree.c gcc/tree.c
--- gcc.orig/tree.c	Sun Dec  2 16:46:27 2001
+++ gcc/tree.c	Mon Dec  3 01:23:50 2001
@@ -1518,7 +1518,11 @@ staticp (arg)
 	return staticp (TREE_OPERAND (arg, 0));
 
     default:
-      return 0;
+      if ((unsigned int) TREE_CODE (arg)
+	  >= (unsigned int) LAST_AND_UNUSED_TREE_CODE)
+	return (*lang_hooks.staticp) (arg);
+      else
+	return 0;
     }
 }
 

-- 
Joseph S. Myers
jsm28@cam.ac.uk


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