Mercurial > hg > CbC > CbC_gcc
comparison libcpp/errors.c @ 63:b7f97abdc517 gcc-4.6-20100522
update gcc from gcc-4.5.0 to gcc-4.6
author | ryoma <e075725@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 24 May 2010 12:47:05 +0900 |
parents | 77e2b8dfacca |
children | f6334be47118 |
comparison
equal
deleted
inserted
replaced
56:3c8a44c06a95 | 63:b7f97abdc517 |
---|---|
26 #include "config.h" | 26 #include "config.h" |
27 #include "system.h" | 27 #include "system.h" |
28 #include "cpplib.h" | 28 #include "cpplib.h" |
29 #include "internal.h" | 29 #include "internal.h" |
30 | 30 |
31 /* Print an error at the location of the previously lexed token. */ | 31 /* Print a diagnostic at the location of the previously lexed token. */ |
32 bool | 32 |
33 cpp_error (cpp_reader * pfile, int level, const char *msgid, ...) | 33 ATTRIBUTE_FPTR_PRINTF(4,0) |
34 static bool | |
35 cpp_diagnostic (cpp_reader * pfile, int level, int reason, | |
36 const char *msgid, va_list *ap) | |
34 { | 37 { |
35 source_location src_loc; | 38 source_location src_loc; |
36 va_list ap; | 39 bool ret; |
37 bool ret; | |
38 | |
39 va_start (ap, msgid); | |
40 | 40 |
41 if (CPP_OPTION (pfile, traditional)) | 41 if (CPP_OPTION (pfile, traditional)) |
42 { | 42 { |
43 if (pfile->state.in_directive) | 43 if (pfile->state.in_directive) |
44 src_loc = pfile->directive_line; | 44 src_loc = pfile->directive_line; |
59 src_loc = pfile->cur_token[-1].src_loc; | 59 src_loc = pfile->cur_token[-1].src_loc; |
60 } | 60 } |
61 | 61 |
62 if (!pfile->cb.error) | 62 if (!pfile->cb.error) |
63 abort (); | 63 abort (); |
64 ret = pfile->cb.error (pfile, level, src_loc, 0, _(msgid), &ap); | 64 ret = pfile->cb.error (pfile, level, reason, src_loc, 0, _(msgid), ap); |
65 | 65 |
66 va_end (ap); | 66 return ret; |
67 return ret; | 67 } |
68 } | 68 |
69 | 69 /* Print a warning or error, depending on the value of LEVEL. */ |
70 /* Print an error at a specific location. */ | 70 |
71 bool | |
72 cpp_error (cpp_reader * pfile, int level, const char *msgid, ...) | |
73 { | |
74 va_list ap; | |
75 bool ret; | |
76 | |
77 va_start (ap, msgid); | |
78 | |
79 ret = cpp_diagnostic (pfile, level, CPP_W_NONE, msgid, &ap); | |
80 | |
81 va_end (ap); | |
82 return ret; | |
83 } | |
84 | |
85 /* Print a warning. The warning reason may be given in REASON. */ | |
86 | |
87 bool | |
88 cpp_warning (cpp_reader * pfile, int reason, const char *msgid, ...) | |
89 { | |
90 va_list ap; | |
91 bool ret; | |
92 | |
93 va_start (ap, msgid); | |
94 | |
95 ret = cpp_diagnostic (pfile, CPP_DL_WARNING, reason, msgid, &ap); | |
96 | |
97 va_end (ap); | |
98 return ret; | |
99 } | |
100 | |
101 /* Print a pedantic warning. The warning reason may be given in REASON. */ | |
102 | |
103 bool | |
104 cpp_pedwarning (cpp_reader * pfile, int reason, const char *msgid, ...) | |
105 { | |
106 va_list ap; | |
107 bool ret; | |
108 | |
109 va_start (ap, msgid); | |
110 | |
111 ret = cpp_diagnostic (pfile, CPP_DL_PEDWARN, reason, msgid, &ap); | |
112 | |
113 va_end (ap); | |
114 return ret; | |
115 } | |
116 | |
117 /* Print a warning, including system headers. The warning reason may be | |
118 given in REASON. */ | |
119 | |
120 bool | |
121 cpp_warning_syshdr (cpp_reader * pfile, int reason, const char *msgid, ...) | |
122 { | |
123 va_list ap; | |
124 bool ret; | |
125 | |
126 va_start (ap, msgid); | |
127 | |
128 ret = cpp_diagnostic (pfile, CPP_DL_WARNING_SYSHDR, reason, msgid, &ap); | |
129 | |
130 va_end (ap); | |
131 return ret; | |
132 } | |
133 | |
134 /* Print a diagnostic at a specific location. */ | |
135 | |
136 ATTRIBUTE_FPTR_PRINTF(6,0) | |
137 static bool | |
138 cpp_diagnostic_with_line (cpp_reader * pfile, int level, int reason, | |
139 source_location src_loc, unsigned int column, | |
140 const char *msgid, va_list *ap) | |
141 { | |
142 bool ret; | |
143 | |
144 if (!pfile->cb.error) | |
145 abort (); | |
146 ret = pfile->cb.error (pfile, level, reason, src_loc, column, _(msgid), ap); | |
147 | |
148 return ret; | |
149 } | |
150 | |
151 /* Print a warning or error, depending on the value of LEVEL. */ | |
152 | |
71 bool | 153 bool |
72 cpp_error_with_line (cpp_reader *pfile, int level, | 154 cpp_error_with_line (cpp_reader *pfile, int level, |
73 source_location src_loc, unsigned int column, | 155 source_location src_loc, unsigned int column, |
74 const char *msgid, ...) | 156 const char *msgid, ...) |
75 { | 157 { |
76 va_list ap; | 158 va_list ap; |
77 bool ret; | 159 bool ret; |
78 | 160 |
79 va_start (ap, msgid); | 161 va_start (ap, msgid); |
80 | 162 |
81 if (!pfile->cb.error) | 163 ret = cpp_diagnostic_with_line (pfile, level, CPP_W_NONE, src_loc, |
82 abort (); | 164 column, msgid, &ap); |
83 ret = pfile->cb.error (pfile, level, src_loc, column, _(msgid), &ap); | 165 |
84 | 166 va_end (ap); |
85 va_end (ap); | 167 return ret; |
86 return ret; | 168 } |
87 } | 169 |
170 /* Print a warning. The warning reason may be given in REASON. */ | |
171 | |
172 bool | |
173 cpp_warning_with_line (cpp_reader *pfile, int reason, | |
174 source_location src_loc, unsigned int column, | |
175 const char *msgid, ...) | |
176 { | |
177 va_list ap; | |
178 bool ret; | |
179 | |
180 va_start (ap, msgid); | |
181 | |
182 ret = cpp_diagnostic_with_line (pfile, CPP_DL_WARNING, reason, src_loc, | |
183 column, msgid, &ap); | |
184 | |
185 va_end (ap); | |
186 return ret; | |
187 } | |
188 | |
189 /* Print a pedantic warning. The warning reason may be given in REASON. */ | |
190 | |
191 bool | |
192 cpp_pedwarning_with_line (cpp_reader *pfile, int reason, | |
193 source_location src_loc, unsigned int column, | |
194 const char *msgid, ...) | |
195 { | |
196 va_list ap; | |
197 bool ret; | |
198 | |
199 va_start (ap, msgid); | |
200 | |
201 ret = cpp_diagnostic_with_line (pfile, CPP_DL_PEDWARN, reason, src_loc, | |
202 column, msgid, &ap); | |
203 | |
204 va_end (ap); | |
205 return ret; | |
206 } | |
207 | |
208 /* Print a warning, including system headers. The warning reason may be | |
209 given in REASON. */ | |
210 | |
211 bool | |
212 cpp_warning_with_line_syshdr (cpp_reader *pfile, int reason, | |
213 source_location src_loc, unsigned int column, | |
214 const char *msgid, ...) | |
215 { | |
216 va_list ap; | |
217 bool ret; | |
218 | |
219 va_start (ap, msgid); | |
220 | |
221 ret = cpp_diagnostic_with_line (pfile, CPP_DL_WARNING_SYSHDR, reason, src_loc, | |
222 column, msgid, &ap); | |
223 | |
224 va_end (ap); | |
225 return ret; | |
226 } | |
227 | |
228 /* Print a warning or error, depending on the value of LEVEL. Include | |
229 information from errno. */ | |
88 | 230 |
89 bool | 231 bool |
90 cpp_errno (cpp_reader *pfile, int level, const char *msgid) | 232 cpp_errno (cpp_reader *pfile, int level, const char *msgid) |
91 { | 233 { |
92 if (msgid[0] == '\0') | 234 if (msgid[0] == '\0') |