gdb/
[binutils-gdb.git] / gold / errors.cc
index d45d6a58b6153f963b90bc4cae89b3f21c4d9da8..b8031b1ba7bb8519c0581c25758cf260d36d2a5f 100644 (file)
@@ -1,6 +1,6 @@
 // errors.cc -- handle errors for gold
 
-// Copyright 2006, 2007, 2008 Free Software Foundation, Inc.
+// Copyright 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
 // Written by Ian Lance Taylor <iant@google.com>.
 
 // This file is part of gold.
@@ -39,8 +39,8 @@ namespace gold
 const int Errors::max_undefined_error_report;
 
 Errors::Errors(const char* program_name)
-  : program_name_(program_name), lock_(NULL), error_count_(0),
-    warning_count_(0), undefined_symbols_()
+  : program_name_(program_name), lock_(NULL), initialize_lock_(&this->lock_),
+    error_count_(0), warning_count_(0), undefined_symbols_()
 {
 }
 
@@ -53,9 +53,7 @@ Errors::Errors(const char* program_name)
 bool
 Errors::initialize_lock()
 {
-  if (this->lock_ == NULL && parameters->options_valid())
-    this->lock_ = new Lock;
-  return this->lock_ != NULL;
+  return this->initialize_lock_.initialize();
 }
 
 // Increment a counter, holding the lock if available.
@@ -158,21 +156,33 @@ Errors::undefined_symbol(const Symbol* sym, const std::string& location)
 {
   bool initialized = this->initialize_lock();
   gold_assert(initialized);
+
+  const char* zmsg;
   {
     Hold_lock h(*this->lock_);
     if (++this->undefined_symbols_[sym] >= max_undefined_error_report)
       return;
-    ++this->error_count_;
+    if (parameters->options().warn_unresolved_symbols())
+      {
+       ++this->warning_count_;
+       zmsg = _("warning");
+      }
+    else
+      {
+       ++this->error_count_;
+       zmsg = _("error");
+      }
   }
+
   const char* const version = sym->version();
   if (version == NULL)
-    fprintf(stderr, _("%s: %s: error: undefined reference to '%s'\n"),
-           this->program_name_, location.c_str(),
+    fprintf(stderr, _("%s: %s: %s: undefined reference to '%s'\n"),
+           this->program_name_, location.c_str(), zmsg,
            sym->demangled_name().c_str());
   else
     fprintf(stderr,
-            _("%s: %s: error: undefined reference to '%s', version '%s'\n"),
-           this->program_name_, location.c_str(),
+            _("%s: %s: %s: undefined reference to '%s', version '%s'\n"),
+           this->program_name_, location.c_str(), zmsg,
            sym->demangled_name().c_str(), version);
 }