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]

[gccgo] Use saw_errors function


This gccgo patch pulls all the references to errorcount into a single
function, saw_errors.  I also cleaned up a few unnecessary #include
statements.  Committed to gccgo branch.

Ian

diff -r b2ed47f4a21d go/Make-lang.in
--- a/go/Make-lang.in	Thu Feb 04 12:30:02 2010 -0800
+++ b/go/Make-lang.in	Thu Feb 04 21:24:03 2010 -0800
@@ -144,15 +144,14 @@
 go/dataflow.o: go/dataflow.cc $(GO_SYSTEM_H) $(GO_GOGO_H) $(GO_EXPRESSIONS_H) \
 	$(GO_STATEMENTS_H) go/dataflow.h
 go/export.o: go/export.cc $(GO_SYSTEM_H) $(srcdir)/../include/sha1.h \
-	$(MACHMODE_H) output.h $(TARGET_H) $(DIAGNOSTIC_H) $(GO_GOGO_H) \
-	$(GO_TYPES_H) $(GO_STATEMENTS_H) go/export.h
+	$(MACHMODE_H) output.h $(TARGET_H) $(GO_GOGO_H) $(GO_TYPES_H) \
+	$(GO_STATEMENTS_H) go/export.h
 go/expressions.o: go/expressions.cc $(GO_SYSTEM_H) intl.h $(TREE_H) \
-	$(GIMPLE_H) tree-iterator.h convert.h $(REAL_H) $(DIAGNOSTIC_H) \
-	$(TM_P_H) $(GO_C_H) $(GO_GOGO_H) $(GO_TYPES_H) go/export.h \
-	$(GO_IMPORT_H) go/refcount.h $(GO_STATEMENTS_H) $(GO_LEX_H) \
-	$(GO_EXPRESSIONS_H)
-go/go.o: go/go.cc $(GO_SYSTEM_H) options.h $(DIAGNOSTIC_H) $(GO_C_H) \
-	$(GO_LEX_H) $(GO_PARSE_H) $(GO_GOGO_H)
+	$(GIMPLE_H) tree-iterator.h convert.h $(REAL_H) $(TM_P_H) \
+	$(GO_C_H) $(GO_GOGO_H) $(GO_TYPES_H) go/export.h $(GO_IMPORT_H) \
+	go/refcount.h $(GO_STATEMENTS_H) $(GO_LEX_H) $(GO_EXPRESSIONS_H)
+go/go.o: go/go.cc $(GO_SYSTEM_H) $(GO_C_H) $(GO_LEX_H) $(GO_PARSE_H) \
+	$(GO_GOGO_H)
 go/go-dump.o: go/go-dump.cc $(GO_SYSTEM_H) $(GO_C_H) go/go-dump.h
 go/go-lang.o: go/go-lang.c $(GO_SYSTEM_H) coretypes.h opts.h $(TREE_H) \
 	$(GIMPLE_H) $(GGC_H) toplev.h debug.h options.h $(FLAGS_H) convert.h \
@@ -181,7 +180,7 @@
 	$(GO_C_H) $(GO_TYPES_H) $(GO_EXPRESSIONS_H) $(GO_GOGO_H) go/refcount.h \
 	$(GO_STATEMENTS_H)
 go/types.o: go/types.cc $(GO_SYSTEM_H) intl.h $(TREE_H) $(GIMPLE_H) \
-	$(REAL_H) $(DIAGNOSTIC_H) $(GO_C_H) $(GO_GOGO_H) go/operator.h \
-	$(GO_EXPRESSIONS_H) $(GO_STATEMENTS_H) go/export.h $(GO_IMPORT_H) \
-	go/refcount.h $(GO_TYPES_H)
+	$(REAL_H) $(GO_C_H) $(GO_GOGO_H) go/operator.h $(GO_EXPRESSIONS_H) \
+	$(GO_STATEMENTS_H) go/export.h $(GO_IMPORT_H) go/refcount.h \
+	$(GO_TYPES_H)
 go/unsafe.o: go/unsafe.cc $(GO_SYSTEM_H) $(GO_TYPES_H) $(GO_GOGO_H)
diff -r b2ed47f4a21d go/export.cc
--- a/go/export.cc	Thu Feb 04 12:30:02 2010 -0800
+++ b/go/export.cc	Thu Feb 04 21:24:03 2010 -0800
@@ -14,7 +14,6 @@
 #include "machmode.h"
 #include "output.h"
 #include "target.h"
-#include "diagnostic.h"
 }
 
 #include "gogo.h"
@@ -107,7 +106,7 @@
   // If there have been any errors so far, don't try to export
   // anything.  That way the export code doesn't have to worry about
   // mismatched types or other confusions.
-  if (errorcount + sorrycount > 0)
+  if (saw_errors())
     return;
 
   // Export the symbols in sorted order.  That will reduce cases where
diff -r b2ed47f4a21d go/expressions.cc
--- a/go/expressions.cc	Thu Feb 04 12:30:02 2010 -0800
+++ b/go/expressions.cc	Thu Feb 04 21:24:03 2010 -0800
@@ -16,7 +16,6 @@
 #include "tree-iterator.h"
 #include "convert.h"
 #include "real.h"
-#include "diagnostic.h"
 #include "tm_p.h"
 }
 
diff -r b2ed47f4a21d go/go.cc
--- a/go/go.cc	Thu Feb 04 12:30:02 2010 -0800
+++ b/go/go.cc	Thu Feb 04 21:24:03 2010 -0800
@@ -10,11 +10,6 @@
 
 #include "go-system.h"
 
-extern "C" {
-#include "options.h"
-#include "diagnostic.h"
-}
-
 #include "go-c.h"
 
 #include "lex.h"
diff -r b2ed47f4a21d go/gogo-tree.cc
--- a/go/gogo-tree.cc	Thu Feb 04 12:30:02 2010 -0800
+++ b/go/gogo-tree.cc	Thu Feb 04 21:24:03 2010 -0800
@@ -31,6 +31,14 @@
 #include "refcount.h"
 #include "gogo.h"
 
+// Whether we have seen any errors.
+
+bool
+saw_errors()
+{
+  return errorcount != 0 || sorrycount != 0;
+}
+
 // A helper function.
 
 static inline tree
@@ -549,7 +557,7 @@
 
       if (vec[i] == error_mark_node)
 	{
-	  gcc_assert(errorcount || sorrycount);
+	  gcc_assert(saw_errors());
 	  --i;
 	  --count;
 	  continue;
@@ -570,7 +578,7 @@
 	    {
 	      tree init = no->var_value()->get_init_tree(this, NULL);
 	      if (init == error_mark_node)
-		gcc_assert(errorcount || sorrycount);
+		gcc_assert(saw_errors());
 	      else if (init == NULL_TREE)
 		;
 	      else if (TREE_CONSTANT(init))
diff -r b2ed47f4a21d go/gogo.cc
--- a/go/gogo.cc	Thu Feb 04 12:30:02 2010 -0800
+++ b/go/gogo.cc	Thu Feb 04 21:24:03 2010 -0800
@@ -998,7 +998,8 @@
       if (package != this->package_
 	  && package->is_imported()
 	  && !package->used()
-	  && !package->uses_sink_alias())
+	  && !package->uses_sink_alias()
+	  && !saw_errors())
 	error_at(package->location(), "imported and not used: %s",
 		 package->name().c_str());
       package->clear_is_imported();
diff -r b2ed47f4a21d go/gogo.h
--- a/go/gogo.h	Thu Feb 04 12:30:02 2010 -0800
+++ b/go/gogo.h	Thu Feb 04 21:24:03 2010 -0800
@@ -2468,4 +2468,8 @@
 // This is used by some of the langhooks.
 extern Gogo* go_get_gogo();
 
+// Whether we have seen any errors.  FIXME: Replace with a backend
+// interface.
+extern bool saw_errors();
+
 #endif // !defined(GO_GOGO_H)
diff -r b2ed47f4a21d go/types.cc
--- a/go/types.cc	Thu Feb 04 12:30:02 2010 -0800
+++ b/go/types.cc	Thu Feb 04 21:24:03 2010 -0800
@@ -16,7 +16,6 @@
 #include "tree.h"
 #include "gimple.h"
 #include "real.h"
-#include "diagnostic.h"
 }
 
 #include "go-c.h"
@@ -811,7 +810,7 @@
 
   void
   do_reflection(Gogo*, std::string*) const
-  { gcc_assert(errorcount + sorrycount > 0); }
+  { gcc_assert(saw_errors()); }
 
   void
   do_mangled_name(Gogo*, std::string* ret) const

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