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]

[committed] Set TREE_USED properly in treelang


 Hi,

  This patch sets TREE_USED when functions and variables are
actually used.  Bootstrapped and tested treelang on sparc-linux.


-- 
Thanks,
Jim

http://www.student.cs.uwaterloo.ca/~ja2morri/
http://phython.blogspot.com
http://open.nit.ca/wiki/?page=jim

Attachment: extrafunc.tree
Description: Text document

Attachment: extravar.tree
Description: Text document

2005-02-26  James A. Morrison  <phython@gcc.gnu.org>

	* treelang.texi: Treelang does have warnings.
	* treetree.c (tree_code_create_function_prototype): Don't set
	TREE_USED and set TREE_PUBLIC, DECL_EXTERNAL, and TREE_STATIC
	as few times as needed on the function declaration.
	(tree_code_create_function_initial): Don't set TREE_USED,
	TREE_ADDRESSABLE, but set TREE_STATIC on the function declaration.
	(tree_code_create_variable): Don't set TREE_USED on VAR_DECL.
	(tree_code_get_expression): Set TREE_USED for variable references
	and function calls.

Index: treelang.texi
===================================================================
RCS file: /cvs/gcc/gcc/gcc/treelang/treelang.texi,v
retrieving revision 1.15
diff -u -p -r1.15 treelang.texi
--- treelang.texi	26 Feb 2005 00:25:52 -0000	1.15
+++ treelang.texi	26 Feb 2005 04:43:27 -0000
@@ -710,9 +710,11 @@ the programmer's intention.)
 @cindex warnings
 @cindex questionable instructions
 @item
-There are few warnings in treelang.  A program is either correct or in
-error.  The only exception to this is an expression in a return statement for
-functions that return nothing.
+There are a few warnings in treelang.  For example an unused static function
+generate a warnings when -Wunused-function is specified, similarily an unused
+static variable generates a warning when -Wunused-variable are specified.
+The only treelang specific warning is a warning when an expression is in a
+return statement for functions that return void.
 @end itemize
 
 @cindex components of treelang
Index: treetree.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/treelang/treetree.c,v
retrieving revision 1.55
diff -u -p -r1.55 treetree.c
--- treetree.c	24 Feb 2005 16:23:14 -0000	1.55
+++ treetree.c	26 Feb 2005 04:43:27 -0000
@@ -352,25 +352,19 @@ tree_code_create_function_prototype (uns
   DECL_CONTEXT (fn_decl) = NULL_TREE;
   DECL_SOURCE_LOCATION (fn_decl) = loc;
 
-  TREE_USED (fn_decl) = 1;
-
   TREE_PUBLIC (fn_decl) = 0;
   DECL_EXTERNAL (fn_decl) = 0;
   TREE_STATIC (fn_decl) = 0;
   switch (storage_class)
     {
     case STATIC_STORAGE:
-      TREE_PUBLIC (fn_decl) = 0;
       break;
 
     case EXTERNAL_DEFINITION_STORAGE:
       TREE_PUBLIC (fn_decl) = 1;
-      TREE_STATIC (fn_decl) = 0;
-      DECL_EXTERNAL (fn_decl) = 0;
       break;
 
     case EXTERNAL_REFERENCE_STORAGE:
-      TREE_PUBLIC (fn_decl) = 0;
       DECL_EXTERNAL (fn_decl) = 1;
       break;
 
@@ -457,11 +451,7 @@ tree_code_create_function_initial (tree 
 
   pushlevel (0);
 
-  /* Force it to be output, else may be solely inlined.  */
-  TREE_ADDRESSABLE (fn_decl) = 1;
-
-  /* Stop -O3 from deleting it.  */
-  TREE_USED (fn_decl) = 1;
+  TREE_STATIC (fn_decl) = 1;
 }
 
 /* Wrapup a function contained in file FILENAME, ending at line LINENO.  */
@@ -570,9 +560,6 @@ tree_code_create_variable (unsigned int 
       gcc_unreachable ();
     }
 
-  /* This should really only be set if the variable is used.  */
-  TREE_USED (var_decl) = 1;
-
   TYPE_NAME (TREE_TYPE (var_decl)) = TYPE_NAME (var_type);
   return pushdecl (copy_node (var_decl));
 }
@@ -700,6 +688,7 @@ tree_code_get_expression (unsigned int e
          variable type, convert it.  */
     case EXP_REFERENCE:
       gcc_assert (op1);
+      TREE_USED (op1) = 1;
       if (type == TREE_TYPE (op1))
         ret1 = op1;
       else
@@ -710,6 +699,7 @@ tree_code_get_expression (unsigned int e
       gcc_assert (op1);
       {
         tree fun_ptr;
+	TREE_USED (op1) = 1;
         fun_ptr = fold (build1 (ADDR_EXPR,
                                 build_pointer_type (TREE_TYPE (op1)), op1));
         ret1 = build3 (CALL_EXPR, type, fun_ptr, nreverse (op2), NULL_TREE);

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