* diagnostic.c (diagnostic_build_prefix): Tidy.
authorGabriel Dos Reis <gdr@codesourcery.com>
Fri, 7 Jun 2002 13:00:43 +0000 (13:00 +0000)
committerGabriel Dos Reis <gdr@gcc.gnu.org>
Fri, 7 Jun 2002 13:00:43 +0000 (13:00 +0000)
From-SVN: r54337

gcc/ChangeLog
gcc/diagnostic.c

index 239331c174d521bb1e7f852b1d1ddd8a8fb43a62..10d1df8aa1e2d438fc3e65f31d93eb2d880d0a0d 100644 (file)
@@ -1,3 +1,7 @@
+2002-06-07  Gabriel Dos Reis  <gdr@codesourcery.com>
+
+       * diagnostic.c (diagnostic_build_prefix): Tidy.
+
 2002-06-07  Neil Booth  <neil@daikokuya.demon.co.uk>
 
        * cpptrad.c (struct block, BLOCK_HEADER_LEN, BLOCK_LEN,
index 2669da1b67a8ca07d2456a76d122f872b5126224..54f4911e98fcfc1d87d109b777de6165d4fbcb7c 100644 (file)
@@ -790,24 +790,22 @@ char *
 diagnostic_build_prefix (diagnostic)
      diagnostic_info *diagnostic;
 {
-  if (diagnostic->location.file)
-    {
-      if (diagnostic->kind == DK_WARNING)
-       return build_message_string (_("%s:%d: warning: "),
-                                     diagnostic->location.file,
-                                     diagnostic->location.line);
-      else
-       return build_message_string ("%s:%d: ",
-                                     diagnostic->location.file,
-                                     diagnostic->location.line);
-    }
-  else
-    {
-      if (diagnostic->kind == DK_WARNING)
-       return build_message_string (_("%s: warning: "), progname);
-      else
-       return build_message_string ("%s: ", progname);
-    }
+  static const char *diagnostic_kind_text[] = {
+#define DEFINE_DIAGNOSTIC_KIND(K, T) _(T),
+#include "diagnostic.def"
+#undef DEFINE_DIAGNOSTIC_KIND
+    "must-not-happen"
+  };
+   if (diagnostic->kind >= DK_LAST_DIAGNOSTIC_KIND)
+     abort();
+
+  return diagnostic->location.file
+    ? build_message_string ("%s:%d: %s",
+                            diagnostic->location.file,
+                            diagnostic->location.line,
+                            diagnostic_kind_text[diagnostic->kind])
+    : build_message_string ("%s: %s", progname,
+                            diagnostic_kind_text[diagnostic->kind]);
 }
 
 /* Report a diagnostic MESSAGE at the declaration DECL.