cpperror.c (print_location): Don't print include chain if line == 0.
authorNeil Booth <neil@daikokuya.demon.co.uk>
Sun, 14 Apr 2002 18:42:47 +0000 (18:42 +0000)
committerNeil Booth <neil@gcc.gnu.org>
Sun, 14 Apr 2002 18:42:47 +0000 (18:42 +0000)
* cpperror.c (print_location): Don't print include chain
if line == 0.
(cpp_begin_message): Update to use DL_ macros.
(cpp_ice, cpp_fatal, cpp_error_from_errno, cpp_warning,
cpp_warning_with_line, cpp_pedwarn, cpp_pedwarn_with_line,
cpp_notice, cpp_notice_from_errno): Remove.
(cpp_error, cpp_error_with_line): Update to take a diagnostic
level.
(cpp_errno): New.
* cppexp.c (CPP_ICE): Remove.
(SYNTAX_ERROR, SYNTAX_ERROR2, parse_number, parse_defined,
lex, integer_overflow, _cpp_parse_expr): Update.
* cppfiles.c (read_include_file, find_include_file,
handle_missing_header, _cpp_read_file, remap_filename): Update.
* cpphash.h (enum error_type): Remove.
(_cpp_begin_message): Update.
* cppinit.c (append_include_chain, remove_dup_dirs, output_deps,
cpp_handle_option, cpp_post_options): Update.
* cpplex.c (trigraph_p, skip_escaped_newlines, skip_block_comment,
skip_whitespace, parse_identifier, parse_slow, parse_string,
_cpp_lex_direct, cpp_spell_token, maybe_read_ucs, cpp_parse_escape,
cpp_interpret_charconst): Update.
* cpplib.c (check_eol, directive_diagnostics, _cpp_handle_directive,
lex_macro_node, do_undef, glue_header_name, parse_include,
do_include_common, read_flag, do_line, do_linemarker, do_ident,
cpp_register_pragma, do_pragma_once, do_pragma_system_header,
do_pragma_poison, do_pragma_dependency, _cpp_do__Pragma, do_else,
do_elif, do_endif, parse_answer, parse_assertion, do_assert,
_cpp_pop_buffer, do_diagnostic): Update.
* cpplib.h (DL_WARNING, DL_WARNING_SYSHDR, DL_PEDWARN, DL_ERROR,
DL_FATAL, DL_ICE, DL_EXTRACT, DL_WARNING_P): New.
(cpp_ice, cpp_fatal, cpp_error_from_errno, cpp_warning,
cpp_warning_with_line, cpp_pedwarn, cpp_pedwarn_with_line,
cpp_notice, cpp_notice_from_errno): Remove.
(cpp_error, cpp_error_with_line): Update to take a diagnostic
level.
(cpp_errno): New.
* cppmacro.c (builtin_macro, stringify_arg, paste_all_tokens,
collect_args, enter_macro_context, save_parameter, parse_params,
_cpp_create_definition, check_trad_stringification,
cpp_macro_definition): Update.
* cppmain.c (cpp_preprocess_file): Update.
* fix-header.c (read_scan_file): Update.

From-SVN: r52302

12 files changed:
gcc/ChangeLog
gcc/cpperror.c
gcc/cppexp.c
gcc/cppfiles.c
gcc/cpphash.h
gcc/cppinit.c
gcc/cpplex.c
gcc/cpplib.c
gcc/cpplib.h
gcc/cppmacro.c
gcc/cppmain.c
gcc/fix-header.c

index d74ac6efebcac1a0a5e0ba42e3e2e01c68d5eda7..8461ac91193c98bf4ed6edac6822c45a56f82eb1 100644 (file)
@@ -1,3 +1,49 @@
+2002-04-14  Neil Booth  <neil@daikokuya.demon.co.uk>
+
+       * cpperror.c (print_location): Don't print include chain
+       if line == 0.
+       (cpp_begin_message): Update to use DL_ macros.
+       (cpp_ice, cpp_fatal, cpp_error_from_errno, cpp_warning,
+       cpp_warning_with_line, cpp_pedwarn, cpp_pedwarn_with_line,
+       cpp_notice, cpp_notice_from_errno): Remove.
+       (cpp_error, cpp_error_with_line): Update to take a diagnostic
+       level.
+       (cpp_errno): New.
+       * cppexp.c (CPP_ICE): Remove.
+       (SYNTAX_ERROR, SYNTAX_ERROR2, parse_number, parse_defined,
+       lex, integer_overflow, _cpp_parse_expr): Update.
+       * cppfiles.c (read_include_file, find_include_file,
+       handle_missing_header, _cpp_read_file, remap_filename): Update.
+       * cpphash.h (enum error_type): Remove.
+       (_cpp_begin_message): Update.
+       * cppinit.c (append_include_chain, remove_dup_dirs, output_deps,
+       cpp_handle_option, cpp_post_options): Update.
+       * cpplex.c (trigraph_p, skip_escaped_newlines, skip_block_comment,
+       skip_whitespace, parse_identifier, parse_slow, parse_string,
+       _cpp_lex_direct, cpp_spell_token, maybe_read_ucs, cpp_parse_escape,
+       cpp_interpret_charconst): Update.
+       * cpplib.c (check_eol, directive_diagnostics, _cpp_handle_directive,
+       lex_macro_node, do_undef, glue_header_name, parse_include,
+       do_include_common, read_flag, do_line, do_linemarker, do_ident,
+       cpp_register_pragma, do_pragma_once, do_pragma_system_header,
+       do_pragma_poison, do_pragma_dependency, _cpp_do__Pragma, do_else,
+       do_elif, do_endif, parse_answer, parse_assertion, do_assert,
+       _cpp_pop_buffer, do_diagnostic): Update.
+       * cpplib.h (DL_WARNING, DL_WARNING_SYSHDR, DL_PEDWARN, DL_ERROR,
+       DL_FATAL, DL_ICE, DL_EXTRACT, DL_WARNING_P): New.
+       (cpp_ice, cpp_fatal, cpp_error_from_errno, cpp_warning,
+       cpp_warning_with_line, cpp_pedwarn, cpp_pedwarn_with_line,
+       cpp_notice, cpp_notice_from_errno): Remove.
+       (cpp_error, cpp_error_with_line): Update to take a diagnostic
+       level.
+       (cpp_errno): New.
+       * cppmacro.c (builtin_macro, stringify_arg, paste_all_tokens,
+       collect_args, enter_macro_context, save_parameter, parse_params,
+       _cpp_create_definition, check_trad_stringification,
+       cpp_macro_definition): Update.
+       * cppmain.c (cpp_preprocess_file): Update.
+       * fix-header.c (read_scan_file): Update.
+
 2002-04-14  Andreas Schwab  <schwab@suse.de>
 
        * config/ia64/linux.h (CPP_PREDEFINES): Fix missing backslash.
index 375dc2ba5b38143344d7d9eff29ecb4b5e8befad..7d74b2ea684f279a4c3a1e8a4bcac610c52f5272 100644 (file)
@@ -31,32 +31,21 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
 static void print_location PARAMS ((cpp_reader *, unsigned int, unsigned int));
 
-/* Don't remove the blank before do, as otherwise the exgettext
-   script will mistake this as a function definition */
-#define v_message(msgid, ap) \
- do { vfprintf (stderr, _(msgid), ap); putc ('\n', stderr); } while (0)
-
 /* Print the logical file location (LINE, COL) in preparation for a
-   diagnostic.  Outputs the #include chain if it has changed.  */
+   diagnostic.  Outputs the #include chain if it has changed.  A line
+   of zero suppresses the include stack, and outputs the program name
+   instead.  */
 static void
 print_location (pfile, line, col)
      cpp_reader *pfile;
      unsigned int line, col;
 {
-  cpp_buffer *buffer = pfile->buffer;
-
-  if (!buffer)
+  if (!pfile->buffer || line == 0)
     fprintf (stderr, "%s: ", progname);
   else
     {
       const struct line_map *map;
 
-      if (line == 0)
-       {
-         line = pfile->cur_token[-1].line;
-         col = pfile->cur_token[-1].col;
-       }
-
       map = lookup_line (&pfile->line_maps, line);
       print_containing_files (&pfile->line_maps, map);
 
@@ -75,226 +64,123 @@ print_location (pfile, line, col)
     }
 }
 
-/* Set up for an error message: print the file and line, bump the error
+/* Set up for a diagnostic: print the file and line, bump the error
    counter, etc.  LINE is the logical line number; zero means to print
-   at the location of the previously lexed token, which tends to be the
-   correct place by default.  Returns 0 if the error has been suppressed.  */
+   at the location of the previously lexed token, which tends to be
+   the correct place by default.  Returns 0 if the error has been
+   suppressed.  */
 int
 _cpp_begin_message (pfile, code, line, column)
      cpp_reader *pfile;
-     enum error_type code;
+     int code;
      unsigned int line, column;
 {
-  int is_warning = 0;
+  int level = DL_EXTRACT (code);
 
-  switch (code)
+  switch (level)
     {
-    case PEDWARN:
-    case WARNING:
+    case DL_WARNING:
+    case DL_PEDWARN:
       if (CPP_IN_SYSTEM_HEADER (pfile)
          && ! CPP_OPTION (pfile, warn_system_headers))
        return 0;
-    case WARNING_SYSHDR:
+      /* Fall through.  */
+
+    case DL_WARNING_SYSHDR:
       if (CPP_OPTION (pfile, warnings_are_errors)
-         || (code == PEDWARN && CPP_OPTION (pfile, pedantic_errors)))
+         || (level == DL_PEDWARN && CPP_OPTION (pfile, pedantic_errors)))
        {
          if (CPP_OPTION (pfile, inhibit_errors))
            return 0;
          if (pfile->errors < CPP_FATAL_LIMIT)
            pfile->errors++;
        }
-      else
-       {
-          if (CPP_OPTION (pfile, inhibit_warnings))
-           return 0;
-         is_warning = 1;
-       }
+      else if (CPP_OPTION (pfile, inhibit_warnings))
+       return 0;
       break;
        
-    case ERROR:
+    case DL_ERROR:
       if (CPP_OPTION (pfile, inhibit_errors))
        return 0;
       if (pfile->errors < CPP_FATAL_LIMIT)
        pfile->errors++;
       break;
+
       /* Fatal errors cannot be inhibited.  */
-    case FATAL:
-      pfile->errors = CPP_FATAL_LIMIT;
-      break;
-    case ICE:
-      fprintf (stderr, _("internal error: "));
+    case DL_FATAL:
+    case DL_ICE:
       pfile->errors = CPP_FATAL_LIMIT;
       break;
     }
 
   print_location (pfile, line, column);
-  if (is_warning)
+  if (DL_WARNING_P (level))
     fputs (_("warning: "), stderr);
+  else if (level == DL_ICE)
+    fputs (_("internal error: "), stderr);
 
   return 1;
 }
 
-/* Exported interface.  */
-
-/* For reporting internal errors.  Prints "internal error: " for you,
-   otherwise identical to cpp_fatal.  */
-void
-cpp_ice VPARAMS ((cpp_reader *pfile, const char *msgid, ...))
-{  
-  VA_OPEN (ap, msgid);
-  VA_FIXEDARG (ap, cpp_reader *, pfile);
-  VA_FIXEDARG (ap, const char *, msgid);
-
-  if (_cpp_begin_message (pfile, ICE, 0, 0))
-    v_message (msgid, ap);
-
-  VA_CLOSE (ap);
-}
-
-/* Same as cpp_error, except we consider the error to be "fatal",
-   such as inconsistent options.  I.e. there is little point in continuing.
-   (We do not exit, to support use of cpplib as a library.
-   Instead, it is the caller's responsibility to check
-   CPP_FATAL_ERRORS.  */
-void
-cpp_fatal VPARAMS ((cpp_reader *pfile, const char *msgid, ...))
-{  
-  VA_OPEN (ap, msgid);
-  VA_FIXEDARG (ap, cpp_reader *, pfile);
-  VA_FIXEDARG (ap, const char *, msgid);
-
-  if (_cpp_begin_message (pfile, FATAL, 0, 0))
-    v_message (msgid, ap);
+/* Don't remove the blank before do, as otherwise the exgettext
+   script will mistake this as a function definition */
+#define v_message(msgid, ap) \
+ do { vfprintf (stderr, _(msgid), ap); putc ('\n', stderr); } while (0)
 
-  VA_CLOSE (ap);
-}
+/* Exported interface.  */
 
 /* Print an error at the location of the previously lexed token.  */
 void
-cpp_error VPARAMS ((cpp_reader * pfile, const char *msgid, ...))
-{
-  VA_OPEN (ap, msgid);
-  VA_FIXEDARG (ap, cpp_reader *, pfile);
-  VA_FIXEDARG (ap, const char *, msgid);
-
-  if (_cpp_begin_message (pfile, ERROR, 0, 0))
-    v_message (msgid, ap);
-
-  VA_CLOSE (ap);
-}
-
-/* Print an error at a specific location.  */
-void
-cpp_error_with_line VPARAMS ((cpp_reader *pfile, int line, int column,
-                            const char *msgid, ...))
+cpp_error VPARAMS ((cpp_reader * pfile, int level, const char *msgid, ...))
 {
-  VA_OPEN (ap, msgid);
-  VA_FIXEDARG (ap, cpp_reader *, pfile);
-  VA_FIXEDARG (ap, int, line);
-  VA_FIXEDARG (ap, int, column);
-  VA_FIXEDARG (ap, const char *, msgid);
-
-  if (_cpp_begin_message (pfile, ERROR, line, column))
-    v_message (msgid, ap);
+  unsigned int line, column;
 
-  VA_CLOSE (ap);
-}
-
-/* Error including a message from `errno'.  */
-void
-cpp_error_from_errno (pfile, name)
-     cpp_reader *pfile;
-     const char *name;
-{
-  cpp_error (pfile, "%s: %s", name, xstrerror (errno));
-}
-
-/* Print a warning at the location of the previously lexed token.  */
-void
-cpp_warning VPARAMS ((cpp_reader * pfile, const char *msgid, ...))
-{
-  VA_OPEN (ap, msgid);
-  VA_FIXEDARG (ap, cpp_reader *, pfile);
-  VA_FIXEDARG (ap, const char *, msgid);
-
-  if (_cpp_begin_message (pfile, WARNING, 0, 0))
-    v_message (msgid, ap);
-
-  VA_CLOSE (ap);
-}
-
-/* Print a warning at a specific location.  */
-void
-cpp_warning_with_line VPARAMS ((cpp_reader * pfile, int line, int column,
-                              const char *msgid, ...))
-{
   VA_OPEN (ap, msgid);
   VA_FIXEDARG (ap, cpp_reader *, pfile);
-  VA_FIXEDARG (ap, int, line);
-  VA_FIXEDARG (ap, int, column);
+  VA_FIXEDARG (ap, int, level);
   VA_FIXEDARG (ap, const char *, msgid);
 
-  if (_cpp_begin_message (pfile, WARNING, line, column))
-    v_message (msgid, ap);
-
-  VA_CLOSE (ap);
-}
-
-/* Pedwarn at the location of the previously lexed token.  */
-void
-cpp_pedwarn VPARAMS ((cpp_reader * pfile, const char *msgid, ...))
-{
-  VA_OPEN (ap, msgid);
-  VA_FIXEDARG (ap, cpp_reader *, pfile);
-  VA_FIXEDARG (ap, const char *, msgid);
+  if (pfile->buffer)
+    {
+      line = pfile->cur_token[-1].line;
+      column = pfile->cur_token[-1].col;
+    }
+  else
+    line = column = 0;
 
-  if (_cpp_begin_message (pfile, PEDWARN, 0, 0))
+  if (_cpp_begin_message (pfile, level, line, column))
     v_message (msgid, ap);
 
   VA_CLOSE (ap);
 }
 
-/* Pedwarn at a specific location.  */
+/* Print an error at a specific location.  */
 void
-cpp_pedwarn_with_line VPARAMS ((cpp_reader * pfile, int line, int column,
-                              const char *msgid, ...))
+cpp_error_with_line VPARAMS ((cpp_reader *pfile, int level,
+                             unsigned int line, unsigned int column,
+                             const char *msgid, ...))
 {
   VA_OPEN (ap, msgid);
   VA_FIXEDARG (ap, cpp_reader *, pfile);
-  VA_FIXEDARG (ap, int, line);
-  VA_FIXEDARG (ap, int, column);
+  VA_FIXEDARG (ap, int, level);
+  VA_FIXEDARG (ap, unsigned int, line);
+  VA_FIXEDARG (ap, unsigned int, column);
   VA_FIXEDARG (ap, const char *, msgid);
 
-  if (_cpp_begin_message (pfile, PEDWARN, line, column))
+  if (_cpp_begin_message (pfile, level, line, column))
     v_message (msgid, ap);
 
   VA_CLOSE (ap);
 }
 
-/* Print an error message not associated with the translation unit.  */
 void
-cpp_notice VPARAMS ((cpp_reader *pfile, const char *msgid, ...))
-{
-  VA_OPEN (ap, msgid);
-  VA_FIXEDARG (ap, cpp_reader *, pfile);
-  VA_FIXEDARG (ap, const char *, msgid);
-
-  if (pfile->errors < CPP_FATAL_LIMIT)
-    pfile->errors++;
-
-  v_message (msgid, ap);
-
-  VA_CLOSE (ap);
-}
-
-/* Print an error message originating from ERRNO and not associated
-   with the translation unit.  */
-void
-cpp_notice_from_errno (pfile, name)
+cpp_errno (pfile, level, msgid)
      cpp_reader *pfile;
-     const char *name;
+     int level;
+     const char *msgid;
 {
-  if (name[0] == '\0')
-    name = "stdout";
-  cpp_notice (pfile, "%s: %s", name, xstrerror (errno));
+  if (msgid[0] == '\0')
+    msgid = _("stdout");
+
+  cpp_error (pfile, level, "%s: %s", msgid, xstrerror (errno));
 }
index 5766a7903c07fb6a9bccf0a57274e737e5a5e9ab..e5b5ef7ae60d364e848fc68ca646ae0d96022f57 100644 (file)
@@ -54,12 +54,10 @@ struct op
 
 /* With -O2, gcc appears to produce nice code, moving the error
    message load and subsequent jump completely out of the main path.  */
-#define CPP_ICE(msgid) \
-  do { cpp_ice (pfile, msgid); goto syntax_error; } while(0)
 #define SYNTAX_ERROR(msgid) \
-  do { cpp_error (pfile, msgid); goto syntax_error; } while(0)
+  do { cpp_error (pfile, DL_ERROR, msgid); goto syntax_error; } while(0)
 #define SYNTAX_ERROR2(msgid, arg) \
-  do { cpp_error (pfile, msgid, arg); goto syntax_error; } while(0)
+  do { cpp_error (pfile, DL_ERROR, msgid, arg); goto syntax_error; } while(0)
 
 struct suffix
 {
@@ -172,23 +170,26 @@ parse_number (pfile, tok)
       if (CPP_WTRADITIONAL (pfile)
          && sufftab[i].u
          && ! cpp_sys_macro_p (pfile))
-       cpp_warning (pfile, "traditional C rejects the `U' suffix");
+       cpp_error (pfile, DL_WARNING, "traditional C rejects the `U' suffix");
       if (sufftab[i].l == 2 && CPP_OPTION (pfile, pedantic)
          && ! CPP_OPTION (pfile, c99))
-       cpp_pedwarn (pfile, "too many 'l' suffixes in integer constant");
+       cpp_error (pfile, DL_PEDWARN,
+                  "too many 'l' suffixes in integer constant");
     }
   
   if (base <= largest_digit)
-    cpp_pedwarn (pfile, "integer constant contains digits beyond the radix");
+    cpp_error (pfile, DL_PEDWARN,
+              "integer constant contains digits beyond the radix");
 
   if (overflow)
-    cpp_pedwarn (pfile, "integer constant out of range");
+    cpp_error (pfile, DL_PEDWARN, "integer constant out of range");
 
   /* If too big to be signed, consider it unsigned.  */
   else if ((HOST_WIDEST_INT) n < 0 && ! op.unsignedp)
     {
       if (base == 10)
-       cpp_warning (pfile, "integer constant is so large that it is unsigned");
+       cpp_error (pfile, DL_WARNING,
+                  "integer constant is so large that it is unsigned");
       op.unsignedp = 1;
     }
 
@@ -197,7 +198,7 @@ parse_number (pfile, tok)
   return op;
 
  invalid_suffix:
-  cpp_error (pfile, "invalid suffix '%.*s' on integer constant",
+  cpp_error (pfile, DL_ERROR, "invalid suffix '%.*s' on integer constant",
             (int) (end - p), p);
  syntax_error:
   op.op = CPP_ERROR;
@@ -230,20 +231,21 @@ parse_defined (pfile)
       node = token->val.node;
       if (paren && cpp_get_token (pfile)->type != CPP_CLOSE_PAREN)
        {
-         cpp_error (pfile, "missing ')' after \"defined\"");
+         cpp_error (pfile, DL_ERROR, "missing ')' after \"defined\"");
          node = 0;
        }
     }
   else
     {
-      cpp_error (pfile, "operator \"defined\" requires an identifier");
+      cpp_error (pfile, DL_ERROR,
+                "operator \"defined\" requires an identifier");
       if (token->flags & NAMED_OP)
        {
          cpp_token op;
 
          op.flags = 0;
          op.type = token->type;
-         cpp_error (pfile,
+         cpp_error (pfile, DL_ERROR,
                     "(\"%s\" is an alternative token for \"%s\" in C++)",
                     cpp_token_as_text (pfile, token),
                     cpp_token_as_text (pfile, &op));
@@ -255,7 +257,8 @@ parse_defined (pfile)
   else
     {
       if (pfile->context != initial_context)
-       cpp_warning (pfile, "this use of \"defined\" may not be portable");
+       cpp_error (pfile, DL_WARNING,
+                  "this use of \"defined\" may not be portable");
 
       op.value = node->type == NT_MACRO;
       op.unsignedp = 0;
@@ -326,8 +329,9 @@ lex (pfile, skip_evaluation)
             and stdbool.h has not been included.  */
          if (CPP_PEDANTIC (pfile)
              && ! cpp_defined (pfile, DSC("__bool_true_false_are_defined")))
-           cpp_pedwarn (pfile, "ISO C++ does not permit \"%s\" in #if",
-                        NODE_NAME (token->val.node));
+           cpp_error (pfile, DL_PEDWARN,
+                      "ISO C++ does not permit \"%s\" in #if",
+                      NODE_NAME (token->val.node));
          return op;
        }
       else
@@ -337,8 +341,8 @@ lex (pfile, skip_evaluation)
          op.value = 0;
 
          if (CPP_OPTION (pfile, warn_undef) && !skip_evaluation)
-           cpp_warning (pfile, "\"%s\" is not defined",
-                        NODE_NAME (token->val.node));
+           cpp_error (pfile, DL_WARNING, "\"%s\" is not defined",
+                      NODE_NAME (token->val.node));
          return op;
        }
 
@@ -378,7 +382,8 @@ integer_overflow (pfile)
      cpp_reader *pfile;
 {
   if (CPP_PEDANTIC (pfile))
-    cpp_pedwarn (pfile, "integer overflow in preprocessor expression");
+    cpp_error (pfile, DL_PEDWARN,
+              "integer overflow in preprocessor expression");
 }
 
 /* Handle shifting A left by B bits.  UNSIGNEDP is non-zero if A is
@@ -657,8 +662,8 @@ _cpp_parse_expr (pfile)
          switch (top[1].op)
            {
            default:
-             cpp_ice (pfile, "impossible operator '%s'",
-                              op_as_text (pfile, top[1].op));
+             cpp_error (pfile, DL_ICE, "impossible operator '%s'",
+                        op_as_text (pfile, top[1].op));
              goto syntax_error;
 
            case CPP_NOT:        UNARY(!);      break;
@@ -688,7 +693,7 @@ _cpp_parse_expr (pfile)
                  top->flags |= HAVE_VALUE;
 
                  if (CPP_WTRADITIONAL (pfile))
-                   cpp_warning (pfile,
+                   cpp_error (pfile, DL_WARNING,
                        "traditional C rejects the unary plus operator");
                }
              else
@@ -767,7 +772,8 @@ _cpp_parse_expr (pfile)
              break;
            case CPP_COMMA:
              if (CPP_PEDANTIC (pfile))
-               cpp_pedwarn (pfile, "comma operator in operand of #if");
+               cpp_error (pfile, DL_PEDWARN,
+                          "comma operator in operand of #if");
              top->value = v2;
              top->unsignedp = unsigned2;
              break;
@@ -860,7 +866,10 @@ _cpp_parse_expr (pfile)
   result = (top[1].value != 0);
 
   if (top != stack)
-    CPP_ICE ("unbalanced stack in #if");
+    {
+      cpp_error (pfile, DL_ICE, "unbalanced stack in #if");
+      goto syntax_error;
+    }
   else if (!(top[1].flags & HAVE_VALUE))
     {
       SYNTAX_ERROR ("#if with no expression");
index 4c595a857055d48e5d41ece898662774282f9c2c..c1e6bfc6c173c150012bb7b59b2c1b2dbd7ae85b 100644 (file)
@@ -392,7 +392,7 @@ read_include_file (pfile, inc)
         does not bite us.  */
       if (inc->st.st_size > INTTYPE_MAXIMUM (ssize_t))
        {
-         cpp_error (pfile, "%s is too large", inc->name);
+         cpp_error (pfile, DL_ERROR, "%s is too large", inc->name);
          goto fail;
        }
       size = inc->st.st_size;
@@ -422,8 +422,8 @@ read_include_file (pfile, inc)
              if (count == 0)
                {
                  if (!STAT_SIZE_TOO_BIG (inc->st))
-                   cpp_warning
-                     (pfile, "%s is shorter than expected", inc->name);
+                   cpp_error (pfile, DL_WARNING,
+                              "%s is shorter than expected", inc->name);
                  size = offset;
                  buf = xrealloc (buf, size + 1);
                  inc->st.st_size = size;
@@ -437,7 +437,7 @@ read_include_file (pfile, inc)
     }
   else if (S_ISBLK (inc->st.st_mode))
     {
-      cpp_error (pfile, "%s is a block device", inc->name);
+      cpp_error (pfile, DL_ERROR, "%s is a block device", inc->name);
       goto fail;
     }
   else
@@ -473,7 +473,7 @@ read_include_file (pfile, inc)
   return 0;
 
  perror_fail:
-  cpp_error_from_errno (pfile, inc->name);
+  cpp_errno (pfile, DL_ERROR, inc->name);
  fail:
   return 1;
 }
@@ -563,7 +563,8 @@ find_include_file (pfile, header, type)
 
   if (path == NULL)
     {
-      cpp_error (pfile, "no include path in which to find %s", fname);
+      cpp_error (pfile, DL_ERROR, "no include path in which to find %s",
+                fname);
       return NO_INCLUDE_PATH;
     }
 
@@ -685,12 +686,10 @@ handle_missing_header (pfile, fname, angle_brackets)
      we can still produce correct output.  Otherwise, we can't produce
      correct output, because there may be dependencies we need inside
      the missing file, and we don't know what directory this missing
-     file exists in.  FIXME: Use a future cpp_diagnostic_with_errno ()
-     for both of these cases.  */
-  else if (CPP_PRINT_DEPS (pfile) && ! print_dep)
-    cpp_warning (pfile, "%s: %s", fname, xstrerror (errno));
+     file exists in.  */
   else
-    cpp_error_from_errno (pfile, fname);
+    cpp_errno (pfile, CPP_PRINT_DEPS (pfile) && ! print_dep
+              ? DL_WARNING: DL_ERROR, fname);
 }
 
 /* Handles #include-family directives (distinguished by TYPE),
@@ -754,7 +753,7 @@ _cpp_read_file (pfile, fname)
 
   if (f == NULL)
     {
-      cpp_error_from_errno (pfile, fname);
+      cpp_errno (pfile, DL_ERROR, fname);
       return false;
     }
 
@@ -1026,7 +1025,7 @@ remap_filename (pfile, name, loc)
 
   /* We know p != name as absolute paths don't call remap_filename.  */
   if (p == name)
-    cpp_ice (pfile, "absolute file name in remap_filename");
+    cpp_error (pfile, DL_ICE, "absolute file name in remap_filename");
 
   dir = (char *) alloca (p - name + 1);
   memcpy (dir, name, p - name);
index 3112bdb3b37872993b2876f6eca6ff8d2b3105a6..11483b0edef1506047a539c2627dcefb1bb9a91b 100644 (file)
@@ -356,8 +356,7 @@ extern unsigned char _cpp_trigraph_map[UCHAR_MAX + 1];
 #define CPP_WTRADITIONAL(PF) CPP_OPTION (PF, warn_traditional)
 
 /* In cpperror.c  */
-enum error_type { WARNING = 0, WARNING_SYSHDR, PEDWARN, ERROR, FATAL, ICE };
-extern int _cpp_begin_message PARAMS ((cpp_reader *, enum error_type,
+extern int _cpp_begin_message PARAMS ((cpp_reader *, int,
                                       unsigned int, unsigned int));
 
 /* In cppmacro.c */
index ce950c0eaf5c81bd7b80c38e1bc262cc53d0d34a..a9092edf429c4e2ef867282e258f0f14a525f26d 100644 (file)
@@ -225,7 +225,7 @@ append_include_chain (pfile, dir, path, cxx_aware)
     {
       /* Dirs that don't exist are silently ignored.  */
       if (errno != ENOENT)
-       cpp_notice_from_errno (pfile, dir);
+       cpp_errno (pfile, DL_ERROR, dir);
       else if (CPP_OPTION (pfile, verbose))
        fprintf (stderr, _("ignoring nonexistent directory \"%s\"\n"), dir);
       free (dir);
@@ -234,7 +234,7 @@ append_include_chain (pfile, dir, path, cxx_aware)
 
   if (!S_ISDIR (st.st_mode))
     {
-      cpp_notice (pfile, "%s: Not a directory", dir);
+      cpp_error_with_line (pfile, DL_ERROR, 0, 0, "%s: Not a directory", dir);
       free (dir);
       return;
     }
@@ -308,16 +308,16 @@ remove_dup_dirs (pfile, head)
          {
            if (cur->sysp && !other->sysp)
              {
-               cpp_warning (pfile,
-                            "changing search order for system directory \"%s\"",
-                            cur->name);
+               cpp_error (pfile, DL_WARNING,
+                          "changing search order for system directory \"%s\"",
+                          cur->name);
                if (strcmp (cur->name, other->name))
-                 cpp_warning (pfile, 
-                              "  as it is the same as non-system directory \"%s\"",
-                              other->name);
+                 cpp_error (pfile, DL_WARNING,
+                            "  as it is the same as non-system directory \"%s\"",
+                            other->name);
                else
-                 cpp_warning (pfile, 
-                              "  as it has already been specified as a non-system directory");
+                 cpp_error (pfile, DL_WARNING,
+                            "  as it has already been specified as a non-system directory");
              }
            cur = remove_dup_dir (pfile, prev);
            break;
@@ -1092,7 +1092,7 @@ output_deps (pfile)
       deps_stream = fopen (CPP_OPTION (pfile, deps_file), deps_mode);
       if (deps_stream == 0)
        {
-         cpp_notice_from_errno (pfile, CPP_OPTION (pfile, deps_file));
+         cpp_errno (pfile, DL_ERROR, CPP_OPTION (pfile, deps_file));
          return;
        }
     }
@@ -1106,7 +1106,7 @@ output_deps (pfile)
   if (deps_stream != stdout)
     {
       if (ferror (deps_stream) || fclose (deps_stream) != 0)
-       cpp_fatal (pfile, "I/O error on output");
+       cpp_error (pfile, DL_FATAL, "I/O error on output");
     }
 }
 
@@ -1350,7 +1350,8 @@ cpp_handle_option (pfile, argc, argv, ignore)
       else if (CPP_OPTION (pfile, out_fname) == NULL)
        CPP_OPTION (pfile, out_fname) = argv[i];
       else
-       cpp_fatal (pfile, "too many filenames. Type %s --help for usage info",
+       cpp_error (pfile, DL_FATAL,
+                  "too many filenames. Type %s --help for usage info",
                   progname);
     }
   else
@@ -1377,7 +1378,8 @@ cpp_handle_option (pfile, argc, argv, ignore)
              arg = argv[++i];
              if (!arg)
                {
-                 cpp_fatal (pfile, cl_options[opt_index].msg, argv[i - 1]);
+                 cpp_error (pfile, DL_FATAL,
+                            cl_options[opt_index].msg, argv[i - 1]);
                  return argc;
                }
            }
@@ -1545,7 +1547,7 @@ cpp_handle_option (pfile, argc, argv, ignore)
            CPP_OPTION (pfile, out_fname) = arg;
          else
            {
-             cpp_fatal (pfile, "output filename specified twice");
+             cpp_error (pfile, DL_FATAL, "output filename specified twice");
              return argc;
            }
          break;
@@ -1657,7 +1659,7 @@ cpp_handle_option (pfile, argc, argv, ignore)
                }
              else
                {
-                 cpp_fatal (pfile, "-I- specified twice");
+                 cpp_error (pfile, DL_FATAL, "-I- specified twice");
                  return argc;
                }
            }
@@ -1843,7 +1845,8 @@ cpp_post_options (pfile)
       (CPP_OPTION (pfile, print_deps_missing_files)
        || CPP_OPTION (pfile, deps_file)
        || CPP_OPTION (pfile, deps_phony_targets)))
-    cpp_fatal (pfile, "you must additionally specify either -M or -MM");
+    cpp_error (pfile, DL_FATAL,
+              "you must additionally specify either -M or -MM");
 }
 
 /* Set up dependency-file output.  On exit, if print_deps is non-zero
index a6180314511d5fc7327751eaadef680e1e07c84b..47b1bcf86402020457b6bf0c8bdbf24b1416b483 100644 (file)
@@ -150,16 +150,17 @@ trigraph_p (pfile)
   if (CPP_OPTION (pfile, warn_trigraphs) && !pfile->state.lexing_comment)
     {
       if (accept)
-       cpp_warning_with_line (pfile, pfile->line, CPP_BUF_COL (buffer) - 1,
-                              "trigraph ??%c converted to %c",
-                              (int) from_char,
-                              (int) _cpp_trigraph_map[from_char]);
+       cpp_error_with_line (pfile, DL_WARNING,
+                            pfile->line, CPP_BUF_COL (buffer) - 1,
+                            "trigraph ??%c converted to %c",
+                            (int) from_char,
+                            (int) _cpp_trigraph_map[from_char]);
       else if (buffer->cur != buffer->last_Wtrigraphs)
        {
          buffer->last_Wtrigraphs = buffer->cur;
-         cpp_warning_with_line (pfile, pfile->line,
-                                CPP_BUF_COL (buffer) - 1,
-                                "trigraph ??%c ignored", (int) from_char);
+         cpp_error_with_line (pfile, DL_WARNING,
+                              pfile->line, CPP_BUF_COL (buffer) - 1,
+                              "trigraph ??%c ignored", (int) from_char);
        }
     }
 
@@ -215,13 +216,15 @@ skip_escaped_newlines (pfile)
 
          if (saved_cur != buffer->cur - 1
              && !pfile->state.lexing_comment)
-           cpp_warning (pfile, "backslash and newline separated by space");
+           cpp_error (pfile, DL_WARNING,
+                      "backslash and newline separated by space");
 
          handle_newline (pfile);
          buffer->backup_to = buffer->cur;
          if (buffer->cur == buffer->rlimit)
            {
-             cpp_pedwarn (pfile, "backslash-newline at end of file");
+             cpp_error (pfile, DL_PEDWARN,
+                        "backslash-newline at end of file");
              next = EOF;
            }
          else
@@ -285,9 +288,9 @@ skip_block_comment (pfile)
             Don't bother to get it right across escaped newlines.  */
          if (CPP_OPTION (pfile, warn_comments)
              && buffer->cur[0] == '*' && buffer->cur[1] != '/')
-           cpp_warning_with_line (pfile,
-                                  pfile->line, CPP_BUF_COL (buffer),
-                                  "\"/*\" within comment");
+           cpp_error_with_line (pfile, DL_WARNING,
+                                pfile->line, CPP_BUF_COL (buffer),
+                                "\"/*\" within comment");
        }
       else if (is_vspace (c))
        handle_newline (pfile);
@@ -370,15 +373,15 @@ skip_whitespace (pfile, c)
            return 0;
          if (!warned)
            {
-             cpp_warning (pfile, "null character(s) ignored");
+             cpp_error (pfile, DL_WARNING, "null character(s) ignored");
              warned = 1;
            }
        }
       else if (pfile->state.in_directive && CPP_PEDANTIC (pfile))
-       cpp_pedwarn_with_line (pfile, pfile->line,
-                              CPP_BUF_COL (buffer),
-                              "%s in preprocessing directive",
-                              c == '\f' ? "form feed" : "vertical tab");
+       cpp_error_with_line (pfile, DL_PEDWARN, pfile->line,
+                            CPP_BUF_COL (buffer),
+                            "%s in preprocessing directive",
+                            c == '\f' ? "form feed" : "vertical tab");
 
       c = *buffer->cur++;
     }
@@ -450,14 +453,14 @@ parse_identifier (pfile)
     {
       /* It is allowed to poison the same identifier twice.  */
       if ((result->flags & NODE_POISONED) && !pfile->state.poisoned_ok)
-       cpp_error (pfile, "attempt to use poisoned \"%s\"",
+       cpp_error (pfile, DL_ERROR, "attempt to use poisoned \"%s\"",
                   NODE_NAME (result));
 
       /* Constraint 6.10.3.5: __VA_ARGS__ should only appear in the
         replacement list of a variadic macro.  */
       if (result == pfile->spec_nodes.n__VA_ARGS__
          && !pfile->state.va_args_ok)
-       cpp_pedwarn (pfile,
+       cpp_error (pfile, DL_PEDWARN,
        "__VA_ARGS__ can only appear in the expansion of a C99 variadic macro");
     }
 
@@ -530,7 +533,7 @@ parse_slow (pfile, cur, number_p, plen)
      accepted as an extension.  Don't warn about it in skipped
      conditional blocks.  */
   if (saw_dollar && CPP_PEDANTIC (pfile) && ! pfile->state.skipping)
-    cpp_pedwarn (pfile, "'$' character(s) in identifier or number");
+    cpp_error (pfile, DL_PEDWARN, "'$' character(s) in identifier or number");
 
   /* Identifiers and numbers are null-terminated.  */
   *plen = obstack_object_size (stack);
@@ -647,7 +650,8 @@ parse_string (pfile, token, terminator)
             comments are.  */
        unterminated:
          if (CPP_OPTION (pfile, lang) != CLK_ASM || terminator == '>')
-           cpp_error (pfile, "missing terminating %c character", terminator);
+           cpp_error (pfile, DL_ERROR, "missing terminating %c character",
+                      terminator);
          buffer->cur--;
          break;
        }
@@ -658,7 +662,8 @@ parse_string (pfile, token, terminator)
          if (!warned_nulls)
            {
              warned_nulls = true;
-             cpp_warning (pfile, "null character(s) preserved in literal");
+             cpp_error (pfile, DL_WARNING,
+                        "null character(s) preserved in literal");
            }
        }
 
@@ -881,7 +886,7 @@ _cpp_lex_direct (pfile)
              /* Non-empty files should end in a newline.  Don't warn
                 for command line and _Pragma buffers.  */
              if (!buffer->from_stage3)
-               cpp_pedwarn (pfile, "no newline at end of file");
+               cpp_error (pfile, DL_PEDWARN, "no newline at end of file");
              handle_newline (pfile);
            }
 
@@ -1001,7 +1006,7 @@ _cpp_lex_direct (pfile)
       if (c == '*')
        {
          if (skip_block_comment (pfile))
-           cpp_error (pfile, "unterminated comment");
+           cpp_error (pfile, DL_ERROR, "unterminated comment");
        }
       else if (c == '/' && (CPP_OPTION (pfile, cplusplus_comments)
                            || CPP_IN_SYSTEM_HEADER (pfile)))
@@ -1011,15 +1016,15 @@ _cpp_lex_direct (pfile)
          if (CPP_OPTION (pfile, lang) == CLK_GNUC89 && CPP_PEDANTIC (pfile)
              && ! buffer->warned_cplusplus_comments)
            {
-             cpp_pedwarn (pfile,
+             cpp_error (pfile, DL_PEDWARN,
                           "C++ style comments are not allowed in ISO C89");
-             cpp_pedwarn (pfile,
-                          "(this will be reported only once per input file)");
+             cpp_error (pfile, DL_PEDWARN,
+                        "(this will be reported only once per input file)");
              buffer->warned_cplusplus_comments = 1;
            }
 
          if (skip_line_comment (pfile) && CPP_OPTION (pfile, warn_comments))
-           cpp_warning (pfile, "multi-line comment");
+           cpp_error (pfile, DL_WARNING, "multi-line comment");
        }
       else if (c == '=')
        {
@@ -1334,7 +1339,8 @@ cpp_spell_token (pfile, token, buffer)
          case CPP_WCHAR:       left = '\''; right = '\''; tag = 'L';  break;
          case CPP_HEADER_NAME: left = '<';  right = '>';  tag = '\0'; break;
          default:
-           cpp_ice (pfile, "unknown string token %s\n", TOKEN_NAME (token));
+           cpp_error (pfile, DL_ICE, "unknown string token %s\n",
+                      TOKEN_NAME (token));
            return buffer;
          }
        if (tag) *buffer++ = tag;
@@ -1346,7 +1352,7 @@ cpp_spell_token (pfile, token, buffer)
       break;
 
     case SPELL_NONE:
-      cpp_ice (pfile, "unspellable token %s", TOKEN_NAME (token));
+      cpp_error (pfile, DL_ICE, "unspellable token %s", TOKEN_NAME (token));
       break;
     }
 
@@ -1602,13 +1608,14 @@ maybe_read_ucs (pfile, pstr, limit, pc)
     return 1;
 
   if (CPP_WTRADITIONAL (pfile))
-    cpp_warning (pfile, "the meaning of '\\%c' is different in traditional C", c);
+    cpp_error (pfile, DL_WARNING,
+              "the meaning of '\\%c' is different in traditional C", c);
 
   length = (c == 'u' ? 4: 8);
 
   if ((size_t) (limit - p) < length)
     {
-      cpp_error (pfile, "incomplete universal-character-name");
+      cpp_error (pfile, DL_ERROR, "incomplete universal-character-name");
       /* Skip to the end to avoid more diagnostics.  */
       p = limit;
     }
@@ -1621,7 +1628,7 @@ maybe_read_ucs (pfile, pstr, limit, pc)
            code = (code << 4) + hex_digit_value (c);
          else
            {
-             cpp_error (pfile,
+             cpp_error (pfile, DL_ERROR,
                         "non-hex digit '%c' in universal-character-name", c);
              /* We shouldn't skip in case there are multibyte chars.  */
              break;
@@ -1630,7 +1637,7 @@ maybe_read_ucs (pfile, pstr, limit, pc)
     }
 
 #ifdef TARGET_EBCDIC
-  cpp_error (pfile, "universal-character-name on EBCDIC target");
+  cpp_error (pfile, DL_ERROR, "universal-character-name on EBCDIC target");
   code = 0x3f;  /* EBCDIC invalid character */
 #else
  /* True extended characters are OK.  */
@@ -1644,7 +1651,7 @@ maybe_read_ucs (pfile, pstr, limit, pc)
     ;
   /* Don't give another error if one occurred above.  */
   else if (length == 0)
-    cpp_error (pfile, "universal-character-name out of range");
+    cpp_error (pfile, DL_ERROR, "universal-character-name out of range");
 #endif
 
   *pstr = p;
@@ -1687,13 +1694,15 @@ cpp_parse_escape (pfile, pstr, limit, mask)
 
     case 'a':
       if (CPP_WTRADITIONAL (pfile))
-       cpp_warning (pfile, "the meaning of '\\a' is different in traditional C");
+       cpp_error (pfile, DL_WARNING,
+                  "the meaning of '\\a' is different in traditional C");
       c = TARGET_BELL;
       break;
 
     case 'e': case 'E':
       if (CPP_PEDANTIC (pfile))
-       cpp_pedwarn (pfile, "non-ISO-standard escape sequence, '\\%c'", c);
+       cpp_error (pfile, DL_PEDWARN,
+                  "non-ISO-standard escape sequence, '\\%c'", c);
       c = TARGET_ESC;
       break;
       
@@ -1703,7 +1712,8 @@ cpp_parse_escape (pfile, pstr, limit, mask)
 
     case 'x':
       if (CPP_WTRADITIONAL (pfile))
-       cpp_warning (pfile, "the meaning of '\\x' is different in traditional C");
+       cpp_error (pfile, DL_WARNING,
+                  "the meaning of '\\x' is different in traditional C");
 
        {
          unsigned int i = 0, overflow = 0;
@@ -1721,11 +1731,13 @@ cpp_parse_escape (pfile, pstr, limit, mask)
            }
 
          if (!digits_found)
-           cpp_error (pfile, "\\x used with no following hex digits");
+           cpp_error (pfile, DL_ERROR, 
+                      "\\x used with no following hex digits");
 
          if (overflow | (i != (i & mask)))
            {
-             cpp_pedwarn (pfile, "hex escape sequence out of range");
+             cpp_error (pfile, DL_PEDWARN,
+                        "hex escape sequence out of range");
              i &= mask;
            }
          c = i;
@@ -1749,7 +1761,8 @@ cpp_parse_escape (pfile, pstr, limit, mask)
 
        if (i != (i & mask))
          {
-           cpp_pedwarn (pfile, "octal escape sequence out of range");
+           cpp_error (pfile, DL_PEDWARN,
+                      "octal escape sequence out of range");
            i &= mask;
          }
        c = i;
@@ -1764,13 +1777,13 @@ cpp_parse_escape (pfile, pstr, limit, mask)
   if (unknown)
     {
       if (ISGRAPH (c))
-       cpp_pedwarn (pfile, "unknown escape sequence '\\%c'", c);
+       cpp_error (pfile, DL_PEDWARN, "unknown escape sequence '\\%c'", c);
       else
-       cpp_pedwarn (pfile, "unknown escape sequence: '\\%03o'", c);
+       cpp_error (pfile, DL_PEDWARN, "unknown escape sequence: '\\%03o'", c);
     }
 
   if (c > mask)
-    cpp_pedwarn (pfile, "escape sequence out of range for character");
+    cpp_error (pfile, DL_PEDWARN, "escape sequence out of range for type");
 
   *pstr = str;
   return c;
@@ -1833,7 +1846,8 @@ cpp_interpret_charconst (pfile, token, warn_multi, pchars_seen)
       char_len = local_mbtowc (&wc, str, limit - str);
       if (char_len == -1)
        {
-         cpp_warning (pfile, "ignoring invalid multibyte character");
+         cpp_error (pfile, DL_WARNING,
+                    "ignoring invalid multibyte character");
          c = *str++;
        }
       else
@@ -1864,14 +1878,14 @@ cpp_interpret_charconst (pfile, token, warn_multi, pchars_seen)
     }
 
   if (chars_seen == 0)
-    cpp_error (pfile, "empty character constant");
+    cpp_error (pfile, DL_ERROR, "empty character constant");
   else if (chars_seen > max_chars)
     {
       chars_seen = max_chars;
-      cpp_warning (pfile, "character constant too long");
+      cpp_error (pfile, DL_WARNING, "character constant too long");
     }
   else if (chars_seen > 1 && warn_multi)
-    cpp_warning (pfile, "multi-character character constant");
+    cpp_error (pfile, DL_WARNING, "multi-character character constant");
 
   /* If relevant type is signed, sign-extend the constant.  */
   if (chars_seen)
index 47dd977f3051c32a20b09c02cf2086eff207274e..52c394055c8030ff511fff3df11214ab864555e6 100644 (file)
@@ -107,7 +107,7 @@ static U_CHAR *dequote_string       PARAMS ((cpp_reader *, const U_CHAR *,
                                         unsigned int));
 static int  strtoul_for_line   PARAMS ((const U_CHAR *, unsigned int,
                                         unsigned long *));
-static void do_diagnostic      PARAMS ((cpp_reader *, enum error_type, int));
+static void do_diagnostic      PARAMS ((cpp_reader *, int, int));
 static cpp_hashnode *lex_macro_node    PARAMS ((cpp_reader *));
 static void do_include_common  PARAMS ((cpp_reader *, enum include_type));
 static struct pragma_entry *lookup_pragma_entry
@@ -225,8 +225,8 @@ check_eol (pfile)
      cpp_reader *pfile;
 {
   if (! SEEN_EOL () && _cpp_lex_token (pfile)->type != CPP_EOF)
-    cpp_pedwarn (pfile, "extra tokens at end of #%s directive",
-                pfile->directive->name);
+    cpp_error (pfile, DL_PEDWARN, "extra tokens at end of #%s directive",
+              pfile->directive->name);
 }
 
 /* Called when entering a directive, _Pragma or command-line directive.  */
@@ -278,7 +278,7 @@ directive_diagnostics (pfile, dir, indented)
   if (CPP_PEDANTIC (pfile)
       && ! pfile->state.skipping
       && dir->origin == EXTENSION)
-    cpp_pedwarn (pfile, "#%s is a GCC extension", dir->name);
+    cpp_error (pfile, DL_PEDWARN, "#%s is a GCC extension", dir->name);
 
   /* Traditionally, a directive is ignored unless its # is in
      column 1.  Therefore in code intended to work with K+R
@@ -289,15 +289,16 @@ directive_diagnostics (pfile, dir, indented)
   if (CPP_WTRADITIONAL (pfile))
     {
       if (dir == &dtable[T_ELIF])
-       cpp_warning (pfile, "suggest not using #elif in traditional C");
+       cpp_error (pfile, DL_WARNING,
+                  "suggest not using #elif in traditional C");
       else if (indented && dir->origin == KANDR)
-       cpp_warning (pfile,
-                    "traditional C ignores #%s with the # indented",
-                    dir->name);
+       cpp_error (pfile, DL_WARNING,
+                  "traditional C ignores #%s with the # indented",
+                  dir->name);
       else if (!indented && dir->origin != KANDR)
-       cpp_warning (pfile,
-                    "suggest hiding #%s from traditional C with an indented #",
-                    dir->name);
+       cpp_error (pfile, DL_WARNING,
+                  "suggest hiding #%s from traditional C with an indented #",
+                  dir->name);
     }
 }
 
@@ -319,7 +320,7 @@ _cpp_handle_directive (pfile, indented)
   if (was_parsing_args)
     {
       if (CPP_OPTION (pfile, pedantic))
-       cpp_pedwarn (pfile,
+       cpp_error (pfile, DL_PEDWARN,
             "embedding a directive within macro arguments is not portable");
       pfile->state.parsing_args = 0;
       pfile->state.prevent_expansion = 0;
@@ -339,7 +340,8 @@ _cpp_handle_directive (pfile, indented)
       dir = &linemarker_dir;
       if (CPP_PEDANTIC (pfile) && ! CPP_OPTION (pfile, preprocessed)
          && ! pfile->state.skipping)
-       cpp_pedwarn (pfile, "style of line directive is a GCC extension");
+       cpp_error (pfile, DL_PEDWARN,
+                  "style of line directive is a GCC extension");
     }
 
   if (dir)
@@ -388,7 +390,7 @@ _cpp_handle_directive (pfile, indented)
       if (CPP_OPTION (pfile, lang) == CLK_ASM)
        skip = 0;
       else if (!pfile->state.skipping)
-       cpp_error (pfile, "invalid preprocessing directive #%s",
+       cpp_error (pfile, DL_ERROR, "invalid preprocessing directive #%s",
                   cpp_token_as_text (pfile, dname));
     }
 
@@ -466,14 +468,14 @@ lex_macro_node (pfile)
   if (token->type != CPP_NAME)
     {
       if (token->type == CPP_EOF)
-       cpp_error (pfile, "no macro name given in #%s directive",
+       cpp_error (pfile, DL_ERROR, "no macro name given in #%s directive",
                   pfile->directive->name);
       else if (token->flags & NAMED_OP)
-       cpp_error (pfile,
+       cpp_error (pfile, DL_ERROR,
           "\"%s\" cannot be used as a macro name as it is an operator in C++",
                   NODE_NAME (token->val.node));
       else
-       cpp_error (pfile, "macro names must be identifiers");
+       cpp_error (pfile, DL_ERROR, "macro names must be identifiers");
 
       return 0;
     }
@@ -484,7 +486,7 @@ lex_macro_node (pfile)
 
   if (node == pfile->spec_nodes.n_defined)
     {
-      cpp_error (pfile, "\"%s\" cannot be used as a macro name",
+      cpp_error (pfile, DL_ERROR, "\"%s\" cannot be used as a macro name",
                 NODE_NAME (node));
       return 0;
     }
@@ -522,7 +524,7 @@ do_undef (pfile)
        (*pfile->cb.undef) (pfile, pfile->directive_line, node);
 
       if (node->flags & NODE_WARN)
-       cpp_warning (pfile, "undefining \"%s\"", NODE_NAME (node));
+       cpp_error (pfile, DL_WARNING, "undefining \"%s\"", NODE_NAME (node));
 
       _cpp_free_definition (node);
     }
@@ -565,7 +567,7 @@ glue_header_name (pfile)
     }
 
   if (token->type == CPP_EOF)
-    cpp_error (pfile, "missing terminating > character");
+    cpp_error (pfile, DL_ERROR, "missing terminating > character");
   else
     {
       unsigned char *token_mem = _cpp_unaligned_alloc (pfile, total_len + 1);
@@ -603,7 +605,8 @@ parse_include (pfile)
     {
       if (header->type != CPP_LESS)
        {
-         cpp_error (pfile, "#%s expects \"FILENAME\" or <FILENAME>", dir);
+         cpp_error (pfile, DL_ERROR,
+                    "#%s expects \"FILENAME\" or <FILENAME>", dir);
          return NULL;
        }
 
@@ -614,7 +617,7 @@ parse_include (pfile)
 
   if (header->val.str.len == 0)
     {
-      cpp_error (pfile, "empty file name in #%s", dir);
+      cpp_error (pfile, DL_ERROR, "empty file name in #%s", dir);
       return NULL;
     }
 
@@ -633,13 +636,13 @@ do_include_common (pfile, type)
      use the normal search logic.  */
   if (type == IT_INCLUDE_NEXT && ! pfile->buffer->prev)
     {
-      cpp_warning (pfile, "#include_next in primary source file");
+      cpp_error (pfile, DL_WARNING, "#include_next in primary source file");
       type = IT_INCLUDE;
     }
   else if (type == IT_IMPORT && CPP_OPTION (pfile, warn_import))
     {
       CPP_OPTION (pfile, warn_import) = 0;
-      cpp_warning (pfile,
+      cpp_error (pfile, DL_WARNING,
           "#import is obsolete, use an #ifndef wrapper in the header file");
     }
 
@@ -648,7 +651,7 @@ do_include_common (pfile, type)
     {
       /* Prevent #include recursion.  */
       if (pfile->line_maps.depth >= CPP_STACK_MAX)
-       cpp_fatal (pfile, "#include nested too deeply");
+       cpp_error (pfile, DL_FATAL, "#include nested too deeply");
       else
        {
          check_eol (pfile);
@@ -706,7 +709,7 @@ read_flag (pfile, last)
     }
 
   if (token->type != CPP_EOF)
-    cpp_error (pfile, "invalid flag \"%s\" in line directive",
+    cpp_error (pfile, DL_ERROR, "invalid flag \"%s\" in line directive",
               cpp_token_as_text (pfile, token));
   return 0;
 }
@@ -788,13 +791,14 @@ do_line (pfile)
       || strtoul_for_line (token->val.str.text, token->val.str.len,
                           &new_lineno))
     {
-      cpp_error (pfile, "\"%s\" after #line is not a positive integer",
+      cpp_error (pfile, DL_ERROR,
+                "\"%s\" after #line is not a positive integer",
                 cpp_token_as_text (pfile, token));
       return;
     }      
 
   if (CPP_PEDANTIC (pfile) && (new_lineno == 0 || new_lineno > cap))
-    cpp_pedwarn (pfile, "line number out of range");
+    cpp_error (pfile, DL_PEDWARN, "line number out of range");
 
   token = cpp_get_token (pfile);
   if (token->type == CPP_STRING)
@@ -805,7 +809,7 @@ do_line (pfile)
     }
   else if (token->type != CPP_EOF)
     {
-      cpp_error (pfile, "\"%s\" is not a valid filename",
+      cpp_error (pfile, DL_ERROR, "\"%s\" is not a valid filename",
                 cpp_token_as_text (pfile, token));
       return;
     }
@@ -840,7 +844,7 @@ do_linemarker (pfile)
       || strtoul_for_line (token->val.str.text, token->val.str.len,
                           &new_lineno))
     {
-      cpp_error (pfile, "\"%s\" after # is not a positive integer",
+      cpp_error (pfile, DL_ERROR, "\"%s\" after # is not a positive integer",
                 cpp_token_as_text (pfile, token));
       return;
     }      
@@ -876,7 +880,7 @@ do_linemarker (pfile)
     }
   else if (token->type != CPP_EOF)
     {
-      cpp_error (pfile, "\"%s\" is not a valid filename",
+      cpp_error (pfile, DL_ERROR, "\"%s\" is not a valid filename",
                 cpp_token_as_text (pfile, token));
       return;
     }
@@ -909,10 +913,12 @@ _cpp_do_file_change (pfile, reason, to_file, file_line, sysp)
 static void
 do_diagnostic (pfile, code, print_dir)
      cpp_reader *pfile;
-     enum error_type code;
+     int code;
      int print_dir;
 {
-  if (_cpp_begin_message (pfile, code, 0, 0))
+  if (_cpp_begin_message (pfile, code,
+                         pfile->cur_token[-1].line,
+                         pfile->cur_token[-1].col))
     {
       if (print_dir)
        fprintf (stderr, "#%s ", pfile->directive->name);
@@ -926,7 +932,7 @@ static void
 do_error (pfile)
      cpp_reader *pfile;
 {
-  do_diagnostic (pfile, ERROR, 1);
+  do_diagnostic (pfile, DL_ERROR, 1);
 }
 
 static void
@@ -934,7 +940,7 @@ do_warning (pfile)
      cpp_reader *pfile;
 {
   /* We want #warning diagnostics to be emitted in system headers too.  */
-  do_diagnostic (pfile, WARNING_SYSHDR, 1);
+  do_diagnostic (pfile, DL_WARNING_SYSHDR, 1);
 }
 
 /* Report program identification.  */
@@ -945,7 +951,7 @@ do_ident (pfile)
   const cpp_token *str = cpp_get_token (pfile);
 
   if (str->type != CPP_STRING)
-    cpp_error (pfile, "invalid #ident directive");
+    cpp_error (pfile, DL_ERROR, "invalid #ident directive");
   else if (pfile->cb.ident)
     (*pfile->cb.ident) (pfile, pfile->directive_line, &str->val.str);
 
@@ -1032,13 +1038,14 @@ cpp_register_pragma (pfile, space, name, handler)
     {
       if (entry->is_nspace)
        clash:
-       cpp_ice (pfile,
+       cpp_error (pfile, DL_ICE,
                 "registering \"%s\" as both a pragma and a pragma namespace",
                 NODE_NAME (node));
       else if (space)
-       cpp_ice (pfile, "#pragma %s %s is already registered", space, name);
+       cpp_error (pfile, DL_ICE, "#pragma %s %s is already registered",
+                  space, name);
       else
-       cpp_ice (pfile, "#pragma %s is already registered", name);
+       cpp_error (pfile, DL_ICE, "#pragma %s is already registered", name);
     }
   else
     insert_pragma_entry (pfile, chain, node, handler);
@@ -1113,10 +1120,10 @@ static void
 do_pragma_once (pfile)
      cpp_reader *pfile;
 {
-  cpp_warning (pfile, "#pragma once is obsolete");
+  cpp_error (pfile, DL_WARNING, "#pragma once is obsolete");
  
   if (pfile->buffer->prev == NULL)
-    cpp_warning (pfile, "#pragma once in main file");
+    cpp_error (pfile, DL_WARNING, "#pragma once in main file");
   else
     _cpp_never_reread (pfile->buffer->inc);
 
@@ -1140,7 +1147,7 @@ do_pragma_poison (pfile)
        break;
       if (tok->type != CPP_NAME)
        {
-         cpp_error (pfile, "invalid #pragma GCC poison directive");
+         cpp_error (pfile, DL_ERROR, "invalid #pragma GCC poison directive");
          break;
        }
 
@@ -1149,7 +1156,8 @@ do_pragma_poison (pfile)
        continue;
 
       if (hp->type == NT_MACRO)
-       cpp_warning (pfile, "poisoning existing macro \"%s\"", NODE_NAME (hp));
+       cpp_error (pfile, DL_WARNING, "poisoning existing macro \"%s\"",
+                  NODE_NAME (hp));
       _cpp_free_definition (hp);
       hp->flags |= NODE_POISONED | NODE_DIAGNOSTIC;
     }
@@ -1169,7 +1177,8 @@ do_pragma_system_header (pfile)
   cpp_buffer *buffer = pfile->buffer;
 
   if (buffer->prev == 0)
-    cpp_warning (pfile, "#pragma system_header ignored outside include file");
+    cpp_error (pfile, DL_WARNING,
+              "#pragma system_header ignored outside include file");
   else
     {
       check_eol (pfile);
@@ -1194,16 +1203,16 @@ do_pragma_dependency (pfile)
 
   ordering = _cpp_compare_file_date (pfile, header);
   if (ordering < 0)
-    cpp_warning (pfile, "cannot find source %s",
-                cpp_token_as_text (pfile, header));
+    cpp_error (pfile, DL_WARNING, "cannot find source %s",
+              cpp_token_as_text (pfile, header));
   else if (ordering > 0)
     {
-      cpp_warning (pfile, "current file is older than %s",
-                  cpp_token_as_text (pfile, header));
+      cpp_error (pfile, DL_WARNING, "current file is older than %s",
+                cpp_token_as_text (pfile, header));
       if (cpp_get_token (pfile)->type != CPP_EOF)
        {
          _cpp_backup_tokens (pfile, 1);
-         do_diagnostic (pfile, WARNING, 0);
+         do_diagnostic (pfile, DL_WARNING, 0);
        }
     }
 }
@@ -1273,7 +1282,8 @@ _cpp_do__Pragma (pfile)
   const cpp_token *string = get__Pragma_string (pfile);
 
   if (!string)
-    cpp_error (pfile, "_Pragma takes a parenthesized string literal");
+    cpp_error (pfile, DL_ERROR,
+              "_Pragma takes a parenthesized string literal");
   else
     {
       /* Ideally, we'd like
@@ -1372,13 +1382,13 @@ do_else (pfile)
   struct if_stack *ifs = buffer->if_stack;
 
   if (ifs == NULL)
-    cpp_error (pfile, "#else without #if");
+    cpp_error (pfile, DL_ERROR, "#else without #if");
   else
     {
       if (ifs->type == T_ELSE)
        {
-         cpp_error (pfile, "#else after #else");
-         cpp_error_with_line (pfile, ifs->line, 0,
+         cpp_error (pfile, DL_ERROR, "#else after #else");
+         cpp_error_with_line (pfile, DL_ERROR, ifs->line, 0,
                               "the conditional began here");
        }
       ifs->type = T_ELSE;
@@ -1406,13 +1416,13 @@ do_elif (pfile)
   struct if_stack *ifs = buffer->if_stack;
 
   if (ifs == NULL)
-    cpp_error (pfile, "#elif without #if");
+    cpp_error (pfile, DL_ERROR, "#elif without #if");
   else
     {
       if (ifs->type == T_ELSE)
        {
-         cpp_error (pfile, "#elif after #else");
-         cpp_error_with_line (pfile, ifs->line, 0,
+         cpp_error (pfile, DL_ERROR, "#elif after #else");
+         cpp_error_with_line (pfile, DL_ERROR, ifs->line, 0,
                               "the conditional began here");
        }
       ifs->type = T_ELIF;
@@ -1442,7 +1452,7 @@ do_endif (pfile)
   struct if_stack *ifs = buffer->if_stack;
 
   if (ifs == NULL)
-    cpp_error (pfile, "#endif without #if");
+    cpp_error (pfile, DL_ERROR, "#endif without #if");
   else
     {
       /* Only check EOL if was not originally skipping.  */
@@ -1525,7 +1535,7 @@ parse_answer (pfile, answerp, type)
       if (type == T_UNASSERT && paren->type == CPP_EOF)
        return 0;
 
-      cpp_error (pfile, "missing '(' after predicate");
+      cpp_error (pfile, DL_ERROR, "missing '(' after predicate");
       return 1;
     }
 
@@ -1540,7 +1550,7 @@ parse_answer (pfile, answerp, type)
 
       if (token->type == CPP_EOF)
        {
-         cpp_error (pfile, "missing ')' to complete answer");
+         cpp_error (pfile, DL_ERROR, "missing ')' to complete answer");
          return 1;
        }
 
@@ -1560,7 +1570,7 @@ parse_answer (pfile, answerp, type)
 
   if (acount == 0)
     {
-      cpp_error (pfile, "predicate's answer is empty");
+      cpp_error (pfile, DL_ERROR, "predicate's answer is empty");
       return 1;
     }
 
@@ -1590,9 +1600,9 @@ parse_assertion (pfile, answerp, type)
   *answerp = 0;
   predicate = cpp_get_token (pfile);
   if (predicate->type == CPP_EOF)
-    cpp_error (pfile, "assertion without predicate");
+    cpp_error (pfile, DL_ERROR, "assertion without predicate");
   else if (predicate->type != CPP_NAME)
-    cpp_error (pfile, "predicate must be an identifier");
+    cpp_error (pfile, DL_ERROR, "predicate must be an identifier");
   else if (parse_answer (pfile, answerp, type) == 0)
     {
       unsigned int len = NODE_LEN (predicate->val.node);
@@ -1674,7 +1684,8 @@ do_assert (pfile)
        {
          if (*find_answer (node, new_answer))
            {
-             cpp_warning (pfile, "\"%s\" re-asserted", NODE_NAME (node) + 1);
+             cpp_error (pfile, DL_WARNING, "\"%s\" re-asserted",
+                        NODE_NAME (node) + 1);
              return;
            }
          new_answer->next = node->value.answers;
@@ -1903,7 +1914,7 @@ _cpp_pop_buffer (pfile)
   /* Walk back up the conditional stack till we reach its level at
      entry to this file, issuing error messages.  */
   for (ifs = buffer->if_stack; ifs; ifs = ifs->next)
-    cpp_error_with_line (pfile, ifs->line, 0,
+    cpp_error_with_line (pfile, DL_ERROR, ifs->line, 0,
                         "unterminated #%s", dtable[ifs->type].name);
 
   /* In case of a missing #endif.  */
index 8b87b1b41a02780022ecc58dbaaec5bfddcfd316..359326e0138384e2ce21e734f01e43c85a37e9ea 100644 (file)
@@ -546,32 +546,50 @@ extern cpp_buffer *cpp_push_buffer PARAMS ((cpp_reader *,
                                            int, int));
 extern int cpp_defined PARAMS ((cpp_reader *, const unsigned char *, int));
 
+/* Diagnostic levels.  To get a dianostic without associating a
+   position in the translation unit with it, use cpp_error_with_line
+   with a line number of zero.  */
+
+/* Warning, an error with -Werror.  */
+#define DL_WARNING             0x00
+/* Same as DL_WARNING, except it is not suppressed in system headers.  */
+#define DL_WARNING_SYSHDR      0x01
+/* Warning, an error with -pedantic-errors or -Werror.  */
+#define DL_PEDWARN             0x02
+/* An error.  */
+#define DL_ERROR               0x03
+/* A fatal error.  We do not exit, to support use of cpplib as a
+   library, but may only return CPP_EOF tokens thereon.  It is the
+   caller's responsibility to check CPP_FATAL_ERRORS.  */
+#define DL_FATAL               0x04
+/* An internal consistency check failed.  Prints "internal error: ",
+   otherwise the same as DL_FATAL.  */
+#define DL_ICE                 0x05
+/* Extracts a diagnostic level from an int.  */
+#define DL_EXTRACT(l)          (l & 0xf)
+/* Non-zero if a diagnostic level is one of the warnings.  */
+#define DL_WARNING_P(l)                (DL_EXTRACT (l) >= DL_WARNING \
+                                && DL_EXTRACT (l) <= DL_PEDWARN)
+
 /* N.B. The error-message-printer prototypes have not been nicely
    formatted because exgettext needs to see 'msgid' on the same line
    as the name of the function in order to work properly.  Only the
    string argument gets a name in an effort to keep the lines from
    getting ridiculously oversized.  */
 
-extern void cpp_ice PARAMS ((cpp_reader *, const char *msgid, ...))
-  ATTRIBUTE_PRINTF_2;
-extern void cpp_fatal PARAMS ((cpp_reader *, const char *msgid, ...))
-  ATTRIBUTE_PRINTF_2;
-extern void cpp_error PARAMS ((cpp_reader *, const char *msgid, ...))
-  ATTRIBUTE_PRINTF_2;
-extern void cpp_warning PARAMS ((cpp_reader *, const char *msgid, ...))
-  ATTRIBUTE_PRINTF_2;
-extern void cpp_pedwarn PARAMS ((cpp_reader *, const char *msgid, ...))
-  ATTRIBUTE_PRINTF_2;
-extern void cpp_notice PARAMS ((cpp_reader *, const char *msgid, ...))
-  ATTRIBUTE_PRINTF_2;
-extern void cpp_error_with_line PARAMS ((cpp_reader *, int, int, const char *msgid, ...))
-  ATTRIBUTE_PRINTF_4;
-extern void cpp_warning_with_line PARAMS ((cpp_reader *, int, int, const char *msgid, ...))
-  ATTRIBUTE_PRINTF_4;
-extern void cpp_pedwarn_with_line PARAMS ((cpp_reader *, int, int, const char *msgid, ...))
-  ATTRIBUTE_PRINTF_4;
-extern void cpp_error_from_errno PARAMS ((cpp_reader *, const char *));
-extern void cpp_notice_from_errno PARAMS ((cpp_reader *, const char *));
+/* Output a diagnostic of some kind.  */
+extern void cpp_error PARAMS ((cpp_reader *, int, const char *msgid, ...))
+  ATTRIBUTE_PRINTF_3;
+
+/* Output a diagnostic of severity LEVEL, with "MSG: " preceding the
+   error string of errno.  No location is printed.  */
+extern void cpp_errno PARAMS ((cpp_reader *, int level, const char *msg));
+
+/* Same as cpp_error, except additionally specifies a position as a
+   (translation unit) physical line and physical column.  If the line is
+   zero, then no location is printed.  */
+extern void cpp_error_with_line PARAMS ((cpp_reader *, int, unsigned, unsigned, const char *msgid, ...))
+  ATTRIBUTE_PRINTF_5;
 
 /* In cpplex.c */
 extern int cpp_ideq                    PARAMS ((const cpp_token *,
index 6ba7ec4780e624bfe22b0bdbd36ccfc63fb340df..207085175ea4fedbf030194622e322fceab9dd45 100644 (file)
@@ -143,7 +143,8 @@ builtin_macro (pfile, node)
   switch (node->value.builtin)
     {
     default:
-      cpp_ice (pfile, "invalid built-in macro \"%s\"", NODE_NAME (node));
+      cpp_error (pfile, DL_ICE, "invalid built-in macro \"%s\"",
+                NODE_NAME (node));
       return 0;
 
     case BT_FILE:
@@ -344,7 +345,8 @@ stringify_arg (pfile, arg)
   /* Ignore the final \ of invalid string literals.  */
   if (backslash_count & 1)
     {
-      cpp_warning (pfile, "invalid string literal, ignoring final '\\'");
+      cpp_error (pfile, DL_WARNING,
+                "invalid string literal, ignoring final '\\'");
       dest--;
     }
 
@@ -435,10 +437,10 @@ paste_all_tokens (pfile, lhs)
 
          /* Mandatory warning for all apart from assembler.  */
          if (CPP_OPTION (pfile, lang) != CLK_ASM)
-           cpp_warning (pfile,
+           cpp_error (pfile, DL_WARNING,
         "pasting \"%s\" and \"%s\" does not give a valid preprocessing token",
-                        cpp_token_as_text (pfile, lhs),
-                        cpp_token_as_text (pfile, rhs));
+                      cpp_token_as_text (pfile, lhs),
+                      cpp_token_as_text (pfile, rhs));
          break;
        }
     }
@@ -555,7 +557,8 @@ collect_args (pfile, node)
         callers at the end of an -include-d file.  */
       if (pfile->context->prev || pfile->state.in_directive)
        _cpp_backup_tokens (pfile, 1);
-      cpp_error (pfile, "unterminated argument list invoking macro \"%s\"",
+      cpp_error (pfile, DL_ERROR,
+                "unterminated argument list invoking macro \"%s\"",
                 NODE_NAME (node));
       error = true;
     }
@@ -572,11 +575,12 @@ collect_args (pfile, node)
       if (argc + 1 == macro->paramc && macro->variadic)
        {
          if (CPP_PEDANTIC (pfile) && ! macro->syshdr)
-           cpp_pedwarn (pfile, "ISO C99 requires rest arguments to be used");
+           cpp_error (pfile, DL_PEDWARN,
+                      "ISO C99 requires rest arguments to be used");
        }
       else
        {
-         cpp_error (pfile,
+         cpp_error (pfile, DL_ERROR,
                     "macro \"%s\" requires %u arguments, but only %u given",
                     NODE_NAME (node), macro->paramc, argc);
          error = true;
@@ -587,7 +591,7 @@ collect_args (pfile, node)
       /* Empty argument to a macro taking no arguments is OK.  */
       if (argc != 1 || arg->count)
        {
-         cpp_error (pfile,
+         cpp_error (pfile, DL_ERROR,
                     "macro \"%s\" passed %u arguments, but takes just %u",
                     NODE_NAME (node), argc, macro->paramc);
          error = true;
@@ -670,9 +674,9 @@ enter_macro_context (pfile, node)
          if (buff == NULL)
            {
              if (CPP_WTRADITIONAL (pfile) && ! node->value.macro->syshdr)
-               cpp_warning (pfile,
+               cpp_error (pfile, DL_WARNING,
  "function-like macro \"%s\" must be used with arguments in traditional C",
-                            NODE_NAME (node));
+                          NODE_NAME (node));
 
              return 0;
            }
@@ -1169,7 +1173,8 @@ save_parameter (pfile, macro, node)
   /* Constraint 6.10.3.6 - duplicate parameter names.  */
   if (node->arg_index)
     {
-      cpp_error (pfile, "duplicate macro parameter \"%s\"", NODE_NAME (node));
+      cpp_error (pfile, DL_ERROR, "duplicate macro parameter \"%s\"",
+                NODE_NAME (node));
       return 1;
     }
 
@@ -1203,14 +1208,16 @@ parse_params (pfile, macro)
              && ! CPP_OPTION (pfile, discard_comments_in_macro_exp))
            continue;
 
-         cpp_error (pfile, "\"%s\" may not appear in macro parameter list",
+         cpp_error (pfile, DL_ERROR,
+                    "\"%s\" may not appear in macro parameter list",
                     cpp_token_as_text (pfile, token));
          return 0;
 
        case CPP_NAME:
          if (prev_ident)
            {
-             cpp_error (pfile, "macro parameters must be comma-separated");
+             cpp_error (pfile, DL_ERROR,
+                        "macro parameters must be comma-separated");
              return 0;
            }
          prev_ident = 1;
@@ -1227,7 +1234,7 @@ parse_params (pfile, macro)
        case CPP_COMMA:
          if (!prev_ident)
            {
-             cpp_error (pfile, "parameter name missing");
+             cpp_error (pfile, DL_ERROR, "parameter name missing");
              return 0;
            }
          prev_ident = 0;
@@ -1240,11 +1247,12 @@ parse_params (pfile, macro)
              save_parameter (pfile, macro, pfile->spec_nodes.n__VA_ARGS__);
              pfile->state.va_args_ok = 1;
              if (! CPP_OPTION (pfile, c99) && CPP_OPTION (pfile, pedantic))
-               cpp_pedwarn (pfile,
-                    "anonymous variadic macros were introduced in C99");
+               cpp_error (pfile, DL_PEDWARN,
+                          "anonymous variadic macros were introduced in C99");
            }
          else if (CPP_OPTION (pfile, pedantic))
-           cpp_pedwarn (pfile, "ISO C does not permit named variadic macros");
+           cpp_error (pfile, DL_PEDWARN,
+                      "ISO C does not permit named variadic macros");
 
          /* We're at the end, and just expect a closing parenthesis.  */
          token = _cpp_lex_token (pfile);
@@ -1253,7 +1261,7 @@ parse_params (pfile, macro)
          /* Fall through.  */
 
        case CPP_EOF:
-         cpp_error (pfile, "missing ')' in macro parameter list");
+         cpp_error (pfile, DL_ERROR, "missing ')' in macro parameter list");
          return 0;
        }
     }
@@ -1331,7 +1339,8 @@ _cpp_create_definition (pfile, node)
       macro->fun_like = 1;
     }
   else if (ctoken->type != CPP_EOF && !(ctoken->flags & PREV_WHITE))
-    cpp_pedwarn (pfile, "ISO C requires whitespace after the macro name");
+    cpp_error (pfile, DL_PEDWARN,
+              "ISO C requires whitespace after the macro name");
 
   saved_cur_token = pfile->cur_token;
 
@@ -1361,7 +1370,8 @@ _cpp_create_definition (pfile, node)
          else if (CPP_OPTION (pfile, lang) != CLK_ASM)
            {
              ok = 0;
-             cpp_error (pfile, "'#' is not followed by a macro parameter");
+             cpp_error (pfile, DL_ERROR,
+                        "'#' is not followed by a macro parameter");
              goto cleanup1;
            }
        }
@@ -1380,7 +1390,7 @@ _cpp_create_definition (pfile, node)
          if (macro->count == 0 || token->type == CPP_EOF)
            {
              ok = 0;
-             cpp_error (pfile,
+             cpp_error (pfile, DL_ERROR,
                         "'##' cannot appear at either end of a macro expansion");
              goto cleanup1;
            }
@@ -1416,11 +1426,11 @@ _cpp_create_definition (pfile, node)
     {
       if (warn_of_redefinition (node, macro))
        {
-         cpp_pedwarn_with_line (pfile, pfile->directive_line, 0,
-                                "\"%s\" redefined", NODE_NAME (node));
+         cpp_error_with_line (pfile, DL_PEDWARN, pfile->directive_line, 0,
+                              "\"%s\" redefined", NODE_NAME (node));
 
          if (node->type == NT_MACRO && !(node->flags & NODE_BUILTIN))
-           cpp_pedwarn_with_line (pfile, node->value.macro->line, 0,
+           cpp_error_with_line (pfile, DL_PEDWARN, node->value.macro->line, 0,
                            "this is the location of the previous definition");
        }
       _cpp_free_definition (node);
@@ -1484,9 +1494,9 @@ check_trad_stringification (pfile, macro, string)
          if (NODE_LEN (node) == len
              && !memcmp (p, NODE_NAME (node), len))
            {
-             cpp_warning (pfile,
+             cpp_error (pfile, DL_WARNING,
           "macro argument \"%s\" would be stringified in traditional C",
-                          NODE_NAME (node));
+                        NODE_NAME (node));
              break;
            }
        }
@@ -1509,7 +1519,8 @@ cpp_macro_definition (pfile, node)
 
   if (node->type != NT_MACRO || (node->flags & NODE_BUILTIN))
     {
-      cpp_ice (pfile, "invalid hash type %d in cpp_macro_definition", node->type);
+      cpp_error (pfile, DL_ICE,
+                "invalid hash type %d in cpp_macro_definition", node->type);
       return 0;
     }
 
index 0d427292662b409a9c398ef12aae10142a3bfdb1..bab1ff6cd76d6a73760a2ee2919517323ca84a6e 100644 (file)
@@ -89,7 +89,7 @@ cpp_preprocess_file (pfile)
       print.outf = fopen (options->out_fname, "w");
       if (print.outf == NULL)
        {
-         cpp_notice_from_errno (pfile, options->out_fname);
+         cpp_errno (pfile, DL_ERROR, options->out_fname);
          return;
        }
     }
@@ -120,7 +120,7 @@ cpp_preprocess_file (pfile)
   if (print.outf != stdout)
     {
       if (ferror (print.outf) || fclose (print.outf))
-       cpp_notice_from_errno (pfile, options->out_fname);
+       cpp_errno (pfile, DL_ERROR, options->out_fname);
     }
 }
 
index 836e840fb82d3e7b6b4a5df91260c7074fb21f0f..6d054b5c1076f64f80d7bd06b00bf827d761631d 100644 (file)
@@ -633,7 +633,7 @@ read_scan_file (in_fname, argc, argv)
 
   i = cpp_handle_options (scan_in, argc, argv);
   if (i < argc && ! CPP_FATAL_ERRORS (scan_in))
-    cpp_fatal (scan_in, "Invalid option `%s'", argv[i]);
+    cpp_error (scan_in, DL_FATAL, "invalid option `%s'", argv[i]);
   cpp_post_options (scan_in);
   if (CPP_FATAL_ERRORS (scan_in))
     exit (FATAL_EXIT_CODE);