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]

[incremental] Patch: FYI: fix a number of ICEs


I'm checking this in on the incremental-compiler branch.

This fixes a number of minor ICEs I found while running the test
suite.  I also added a way to verify that it is ok to do
"code-generation-like" things.  This will let us catch certain kinds
of bugs; namely, when I add a C pass to re-smash decls for code
generation, it will ensure that we don't smash the long-lived server
data structures.

There are still a bunch of failures.  PCH doesn't work, some debug
levels don't work (but these failures are "good" in that they point
out ramifications of intentional changes), there are some oddities
relating to calling the pushdecl lang hook in the middle end, and then
there are a bunch I haven't categorized yet :-)

Finally, this patch cleans up the lookup_name hack from last week,
moving it where it belongs.

Tom

ChangeLog:
2007-12-17  Tom Tromey  <tromey@redhat.com>

	* gimplify.c (gimplify_function_tree): Use
	server_assert_code_generation.
	* server.h (server_assert_code_generation): Declare.
	* server.c (enum server_state): New.
	(current_server_state): New global.
	(server_main_loop): Set it.
	(server_start_back_end): Likewise.
	(server_assert_code_generation): New function.
	* c-pretty-print.c (pp_c_expression): Handle VIEW_CONVERT_EXPR.
	(pp_c_cast_expression): Likewise.
	* c-typeck.c (really_start_incremental_init): Handle error mark
	nodes.
	(build_external_ref): Wrap variables in VIEW_CONVERT_EXPR.
	* c-parser.c (c_parser_lookup_callback): Handle error mark nodes.
	* c-decl.c (check_bitfield_type_and_width): Handle enum type
	without a min and max.
	(lookup_name): Revert earlier patch; don't wrap with
	VIEW_CONVERT_EXPR.

Index: server.c
===================================================================
--- server.c	(revision 130779)
+++ server.c	(working copy)
@@ -28,6 +28,22 @@
 #include <sys/socket.h>
 #include <sys/un.h>
 
+/* Possible server-related states that the compiler can be in.  */
+enum server_state
+{
+  /* Not running as a server.  */
+  SERVER_NONE,
+  /* Running as a server, in the server itself.  */
+  SERVER_SERVER,
+  /* Running as a server, in the forked code-generation subprocess.  */
+  SERVER_CODEGEN
+};
+
+/* The server state.  It is useful to keep this for internal checking,
+   but it seems better not to export it as a global to the rest of the
+   compiler.  */
+static enum server_state current_server_state = SERVER_NONE;
+
 /* The name of the server socket we're using.  */
 static char *server_socket_name;
 
@@ -237,6 +253,8 @@
   char reply = 't';
   bool result = true;
 
+  current_server_state = SERVER_SERVER;
+
   if (sockfd < 0)
     {
       error ("couldn't create server socket: %s", xstrerror (errno));
@@ -287,6 +305,7 @@
   else if (child == 0)
     {
       /* Child process.  */
+      current_server_state = SERVER_CODEGEN;
       return false;
     }
 
@@ -414,3 +433,14 @@
     }
   send_command_and_wait ('K');
 }
+
+/* Assert that either this compiler is running standalone, or that the
+   compiler has forked and we are in the code generation subprocess.
+   This can be used to decide when it is ok to destructively rewrite
+   front end trees.  */
+void
+server_assert_code_generation (void)
+{
+  gcc_assert (current_server_state == SERVER_NONE
+	      || current_server_state == SERVER_CODEGEN);
+}
Index: server.h
===================================================================
--- server.h	(revision 130779)
+++ server.h	(working copy)
@@ -35,4 +35,8 @@
 /* The main loop calls this when a command is read.  */
 extern void server_callback (int, char *, char **, char **);
 
+/* Ensure that we are either running standalone, or in the
+   code-generation subprocess.  */
+extern void server_assert_code_generation (void);
+
 #endif /* GCC_SERVER_H */
Index: c-decl.c
===================================================================
--- c-decl.c	(revision 130947)
+++ c-decl.c	(working copy)
@@ -2958,18 +2958,7 @@
     {
       tree result = b->decl;
       if (B_IN_FILE_SCOPE (b))
-	{
-	  c_parser_lookup_callback (name, result, false);
-	  /* We should only need to handle smashed types for
-	     file-scope things.  */
-	  if (TREE_TYPE (result) != error_mark_node
-	      && TREE_CODE (result) == VAR_DECL)
-	    {
-	      tree newtype = C_SMASHED_TYPE_VARIANT (TREE_TYPE (result));
-	      if (newtype != TREE_TYPE (result))
-		result = build1 (VIEW_CONVERT_EXPR, newtype, result);
-	    }
-	}
+	c_parser_lookup_callback (name, result, false);
       return result;
     }
   c_parser_lookup_callback (name, NULL_TREE, false);
@@ -4173,6 +4162,9 @@
     {
       struct lang_type *lt = TYPE_LANG_SPECIFIC (*type);
       if (!lt
+	  /* We might have a TYPE_LANG_SPECIFIC but still not have set
+	     the enum min and max.  */
+	  || (!lt->enum_min && !lt->enum_max)
 	  || w < min_precision (lt->enum_min, TYPE_UNSIGNED (*type))
 	  || w < min_precision (lt->enum_max, TYPE_UNSIGNED (*type)))
 	warning (0, "%qs is narrower than values of its type", name);
Index: c-pretty-print.c
===================================================================
--- c-pretty-print.c	(revision 130454)
+++ c-pretty-print.c	(working copy)
@@ -1545,6 +1545,7 @@
     case FIX_TRUNC_EXPR:
     case CONVERT_EXPR:
     case NOP_EXPR:
+    case VIEW_CONVERT_EXPR:
       pp_c_type_cast (pp, TREE_TYPE (e));
       pp_c_cast_expression (pp, TREE_OPERAND (e, 0));
       break;
@@ -1931,6 +1932,7 @@
     case FIX_TRUNC_EXPR:
     case CONVERT_EXPR:
     case NOP_EXPR:
+    case VIEW_CONVERT_EXPR:
       pp_c_cast_expression (pp, e);
       break;
 
Index: c-typeck.c
===================================================================
--- c-typeck.c	(revision 130776)
+++ c-typeck.c	(working copy)
@@ -2160,6 +2160,15 @@
     pedwarn ("%H%qD is static but used in inline function %qD "
 	     "which is not static", &loc, ref, current_function_decl);
 
+  /* Functions are handled when building a function call.  FIXME: but
+     is that right?  What about pointer-to-fn?  */
+  if (TREE_CODE (ref) != FUNCTION_DECL)
+    {
+      tree smashtype = C_SMASHED_TYPE_VARIANT (TREE_TYPE (ref));
+      if (smashtype != TREE_TYPE (ref))
+	ref = build1 (VIEW_CONVERT_EXPR, smashtype, ref);
+    }
+
   return ref;
 }
 
@@ -5084,7 +5093,8 @@
 
   if (type == 0)
     type = TREE_TYPE (constructor_decl);
-  type = C_SMASHED_TYPE_VARIANT (type);
+  if (TREE_CODE (type) != ERROR_MARK)
+    type = C_SMASHED_TYPE_VARIANT (type);
 
   if (targetm.vector_opaque_p (type))
     error ("opaque vector types cannot be initialized");
Index: gimplify.c
===================================================================
--- gimplify.c	(revision 130603)
+++ gimplify.c	(working copy)
@@ -49,6 +49,7 @@
 #include "optabs.h"
 #include "pointer-set.h"
 #include "splay-tree.h"
+#include "server.h"
 
 
 enum gimplify_omp_var_data
@@ -6467,6 +6468,8 @@
   tree oldfn, parm, ret;
   struct function *fun;
 
+  server_assert_code_generation ();
+
   fun = DECL_STRUCT_FUNCTION (fndecl);
   if (fun && fun->gimplified)
     return;
Index: c-parser.c
===================================================================
--- c-parser.c	(revision 130946)
+++ c-parser.c	(working copy)
@@ -894,7 +894,8 @@
      requires many changes.  */
   c_parser *parser = the_parser;
 
-  if (!parser || !parser->current_hunk_binding)
+  if (!parser || !parser->current_hunk_binding
+      || (result && TREE_CODE (result) == ERROR_MARK))
     return;
   binding = result ? find_hunk_binding (result) : NULL;
 


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