summaryrefslogtreecommitdiff
path: root/gcc/diagnostic.c
diff options
context:
space:
mode:
authorgdr <gdr@138bc75d-0d04-0410-961f-82ee72b054a4>2002-06-07 13:00:43 +0000
committergdr <gdr@138bc75d-0d04-0410-961f-82ee72b054a4>2002-06-07 13:00:43 +0000
commit479f88cd0005efdbe433ade3237e2d3a94ff5611 (patch)
treee13052f18e8402392c71592a97c9250f0b8ddccf /gcc/diagnostic.c
parentfc368f7ef6b85dd69efec5ee2ea3d3b697907450 (diff)
downloadgcc-479f88cd0005efdbe433ade3237e2d3a94ff5611.tar.gz
* diagnostic.c (diagnostic_build_prefix): Tidy.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@54337 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/diagnostic.c')
-rw-r--r--gcc/diagnostic.c34
1 files changed, 16 insertions, 18 deletions
diff --git a/gcc/diagnostic.c b/gcc/diagnostic.c
index 2669da1b67a..54f4911e98f 100644
--- a/gcc/diagnostic.c
+++ b/gcc/diagnostic.c
@@ -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.