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]

Diagnostic.c: Describe diagnostic kind


This patchlet makes us prefix a diagnostic with a string that
describes its kind (e.g. "Error: ", "Warning: ", "Note: ", ...)

Bootstrapped and tested on an i686-pc-linux.

-- Gaby

2002-06-07  Gabriel Dos Reis  <gdr@codesourcery.com>

	* diagnostic.c (diagnostic_build_prefix): Tidy.

Index: diagnostic.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/diagnostic.c,v
retrieving revision 1.86
diff -p -r1.86 diagnostic.c
*** diagnostic.c	5 Jun 2002 19:35:31 -0000	1.86
--- diagnostic.c	7 Jun 2002 12:58:48 -0000
*************** char *
*** 790,813 ****
  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);
!     }
  }
  
  /* Report a diagnostic MESSAGE at the declaration DECL.
--- 790,811 ----
  diagnostic_build_prefix (diagnostic)
       diagnostic_info *diagnostic;
  {
!   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.


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