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]

[treelang] Static variables and initializations


 Hi,

  This patch adds DECL_EXPRs (which are currently undocumented) to the body
of the current BIND_EXPR, adding the DECL_EXPRs allows initial.tree to compile
and run on sparc-linux.  It also removes the rest_of_decl_compilation for
static variables, removing this call allows static.tree to compile and run
on sparc-linux.

  Included in this email are 5 execution tests for treelang.  All 5 of these
tests (with make check-treelang on sparc-linux).

  I'm currently bootstrapping and regtesting this patch on powerpc-linux.  Ok
for mainline of testing is successful?

-- 
Thanks,
Jim

http://www.student.cs.uwaterloo.ca/~ja2morri/
http://phython.blogspot.com
http://open.nit.ca/wiki/?page=jim
2005-27-01  James A. Morrison  <phython@gcc.gnu.org>

	* treetree.c (tree_code_create_variable): Initialize DECL_EXTERNAL,
	TREE_PUBLIC, and TREE_STATIC for var_decl to zero.  Don't call
	rest_of_decl_compilation on static variables.
	(pushdecl): Put DECL_EXPRs into the current BIND_EXPR for automatic
	variables.
	
Index: treetree.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/treelang/treetree.c,v
retrieving revision 1.50
diff -u -p -r1.50 treetree.c
--- treetree.c	25 Oct 2004 03:03:24 -0000	1.50
+++ treetree.c	27 Jan 2005 04:33:18 -0000
@@ -554,27 +546,25 @@ tree_code_create_variable (unsigned int 
 
   DECL_SOURCE_LOCATION (var_decl) = loc;
 
+  DECL_EXTERNAL (var_decl) = 0;
+  TREE_PUBLIC (var_decl) = 0;
+  TREE_STATIC (var_decl) = 0;
   /* Set the storage mode and whether only visible in the same file.  */
   switch (storage_class)
     {
     case STATIC_STORAGE:
       TREE_STATIC (var_decl) = 1;
-      TREE_PUBLIC (var_decl) = 0;
       break;
 
     case AUTOMATIC_STORAGE:
-      TREE_STATIC (var_decl) = 0;
-      TREE_PUBLIC (var_decl) = 0;
       break;
 
     case EXTERNAL_DEFINITION_STORAGE:
-      TREE_STATIC (var_decl) = 0;
       TREE_PUBLIC (var_decl) = 1;
       break;
 
     case EXTERNAL_REFERENCE_STORAGE:
       DECL_EXTERNAL (var_decl) = 1;
-      TREE_PUBLIC (var_decl) = 0;
       break;
 
     default:
@@ -584,11 +574,6 @@ tree_code_create_variable (unsigned int 
   /* This should really only be set if the variable is used.  */
   TREE_USED (var_decl) = 1;
 
-  /* Expand declaration and initial value if any.  */
-
-  if (TREE_STATIC (var_decl))
-    rest_of_decl_compilation (var_decl, 0, 0);
-
   TYPE_NAME (TREE_TYPE (var_decl)) = TYPE_NAME (var_type);
   return pushdecl (copy_node (var_decl));
 }
@@ -1133,6 +1119,12 @@ pushdecl (tree decl)
       && TYPE_NAME (TREE_TYPE (decl)) == 0)
     TYPE_NAME (TREE_TYPE (decl)) = DECL_NAME (decl);
 
+  /* Put automatic variables into the intermediate representation.  */
+  if (TREE_CODE (decl) == VAR_DECL && !DECL_EXTERNAL (decl)
+      && !TREE_STATIC (decl) && !TREE_PUBLIC (decl))
+    tree_code_output_expression_statement (build1 (DECL_EXPR, void_type_node,
+                                                   decl),
+                                           DECL_SOURCE_LOCATION (decl));
   return decl;
 }
 
testsuite/treelang
2005-01-27  James A. Morrison  <phython@gcc.gnu.org>

        * execute/execute.exp: New file.
        * execute/funccall.tree, execute/funccall-2.tree, execute/initial.tree,
        execute/main.tree, execute/static.tree: New tests.



Attachment: execute.exp
Description: Text document

Attachment: funccall.tree
Description: Text document

Attachment: funccall-2.tree
Description: Text document

Attachment: initial.tree
Description: Text document

Attachment: main.tree
Description: Text document

Attachment: static.tree
Description: Text document


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