Add support for ARM's Thumb instruction set.
[official-gcc.git] / gcc / cpperror.c
blobe03deb4fce34469d11ef7ae7709757875b58b52a
1 /* Default error handlers for CPP Library.
2 Copyright (C) 1986, 87, 89, 92 - 95, 1998 Free Software Foundation, Inc.
3 Written by Per Bothner, 1994.
4 Based on CCCP program by by Paul Rubin, June 1986
5 Adapted to ANSI C, Richard Stallman, Jan 1987
7 This program is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 2, or (at your option) any
10 later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 In other words, you are welcome to use, share and improve this program.
22 You are forbidden to forbid anyone else to use, share and improve
23 what you give them. Help stamp out software-hoarding! */
25 #ifndef EMACS
26 #include "config.h"
27 #endif /* not EMACS */
29 #include "cpplib.h"
30 #include <stdio.h>
32 /* Print the file names and line numbers of the #include
33 commands which led to the current file. */
35 void
36 cpp_print_containing_files (pfile)
37 cpp_reader *pfile;
39 cpp_buffer *ip;
40 int first = 1;
42 /* If stack of files hasn't changed since we last printed
43 this info, don't repeat it. */
44 if (pfile->input_stack_listing_current)
45 return;
47 ip = cpp_file_buffer (pfile);
49 /* Give up if we don't find a source file. */
50 if (ip == NULL)
51 return;
53 /* Find the other, outer source files. */
54 while ((ip = CPP_PREV_BUFFER (ip)), ip != CPP_NULL_BUFFER (pfile))
56 long line, col;
57 cpp_buf_line_and_col (ip, &line, &col);
58 if (ip->fname != NULL)
60 if (first)
62 first = 0;
63 fprintf (stderr, "In file included");
65 else
66 fprintf (stderr, ",\n ");
69 fprintf (stderr, " from %s:%ld", ip->nominal_fname, line);
71 if (! first)
72 fprintf (stderr, ":\n");
74 /* Record we have printed the status as of this time. */
75 pfile->input_stack_listing_current = 1;
78 void
79 cpp_file_line_for_message (pfile, filename, line, column)
80 cpp_reader *pfile;
81 char *filename;
82 int line, column;
84 if (column > 0)
85 fprintf (stderr, "%s:%d:%d: ", filename, line, column);
86 else
87 fprintf (stderr, "%s:%d: ", filename, line);
90 /* IS_ERROR is 2 for "fatal" error, 1 for error, 0 for warning */
92 void
93 cpp_message (pfile, is_error, msg, arg1, arg2, arg3)
94 int is_error;
95 cpp_reader *pfile;
96 char *msg;
97 char *arg1, *arg2, *arg3;
99 if (!is_error)
100 fprintf (stderr, "warning: ");
101 else if (is_error == 2)
102 pfile->errors = CPP_FATAL_LIMIT;
103 else if (pfile->errors < CPP_FATAL_LIMIT)
104 pfile->errors++;
105 fprintf (stderr, msg, arg1, arg2, arg3);
106 fprintf (stderr, "\n");
109 /* Same as cpp_error, except we consider the error to be "fatal",
110 such as inconsistent options. I.e. there is little point in continuing.
111 (We do not exit, to support use of cpplib as a library.
112 Instead, it is the caller's responsibility to check
113 CPP_FATAL_ERRORS. */
115 void
116 cpp_fatal (pfile, str, arg)
117 cpp_reader *pfile;
118 char *str, *arg;
120 fprintf (stderr, "%s: ", progname);
121 cpp_message (pfile, 2, str, arg);
124 void
125 cpp_pfatal_with_name (pfile, name)
126 cpp_reader *pfile;
127 char *name;
129 cpp_perror_with_name (pfile, name);
130 #ifdef VMS
131 exit (vaxc$errno);
132 #else
133 exit (FATAL_EXIT_CODE);
134 #endif