]> gcc.gnu.org Git - gcc.git/blob - gcc/cppinit.c
cpperror.c: Fix formatting.
[gcc.git] / gcc / cppinit.c
1 /* CPP Library.
2 Copyright (C) 1986, 1987, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
3 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
4 Contributed by Per Bothner, 1994-95.
5 Based on CCCP program by Paul Rubin, June 1986
6 Adapted to ANSI C, Richard Stallman, Jan 1987
7
8 This program is free software; you can redistribute it and/or modify it
9 under the terms of the GNU General Public License as published by the
10 Free Software Foundation; either version 2, or (at your option) any
11 later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
21
22 #include "config.h"
23 #include "system.h"
24 #include "cpplib.h"
25 #include "cpphash.h"
26 #include "prefix.h"
27 #include "intl.h"
28 #include "version.h"
29 #include "mkdeps.h"
30 #include "cppdefault.h"
31
32 /* Predefined symbols, built-in macros, and the default include path. */
33
34 #ifndef GET_ENV_PATH_LIST
35 #define GET_ENV_PATH_LIST(VAR,NAME) do { (VAR) = getenv (NAME); } while (0)
36 #endif
37
38 /* Windows does not natively support inodes, and neither does MSDOS.
39 Cygwin's emulation can generate non-unique inodes, so don't use it.
40 VMS has non-numeric inodes. */
41 #ifdef VMS
42 # define INO_T_EQ(A, B) (!memcmp (&(A), &(B), sizeof (A)))
43 # define INO_T_COPY(DEST, SRC) memcpy(&(DEST), &(SRC), sizeof (SRC))
44 #else
45 # if (defined _WIN32 && ! defined (_UWIN)) || defined __MSDOS__
46 # define INO_T_EQ(A, B) 0
47 # else
48 # define INO_T_EQ(A, B) ((A) == (B))
49 # endif
50 # define INO_T_COPY(DEST, SRC) (DEST) = (SRC)
51 #endif
52
53 /* Internal structures and prototypes. */
54
55 /* A `struct pending_option' remembers one -D, -A, -U, -include, or
56 -imacros switch. */
57 typedef void (* cl_directive_handler) PARAMS ((cpp_reader *, const char *));
58 struct pending_option
59 {
60 struct pending_option *next;
61 const char *arg;
62 cl_directive_handler handler;
63 };
64
65 /* The `pending' structure accumulates all the options that are not
66 actually processed until we hit cpp_read_main_file. It consists of
67 several lists, one for each type of option. We keep both head and
68 tail pointers for quick insertion. */
69 struct cpp_pending
70 {
71 struct pending_option *directive_head, *directive_tail;
72
73 struct search_path *quote_head, *quote_tail;
74 struct search_path *brack_head, *brack_tail;
75 struct search_path *systm_head, *systm_tail;
76 struct search_path *after_head, *after_tail;
77
78 struct pending_option *imacros_head, *imacros_tail;
79 struct pending_option *include_head, *include_tail;
80 };
81
82 #ifdef __STDC__
83 #define APPEND(pend, list, elt) \
84 do { if (!(pend)->list##_head) (pend)->list##_head = (elt); \
85 else (pend)->list##_tail->next = (elt); \
86 (pend)->list##_tail = (elt); \
87 } while (0)
88 #else
89 #define APPEND(pend, list, elt) \
90 do { if (!(pend)->list/**/_head) (pend)->list/**/_head = (elt); \
91 else (pend)->list/**/_tail->next = (elt); \
92 (pend)->list/**/_tail = (elt); \
93 } while (0)
94 #endif
95
96 static void print_help PARAMS ((void));
97 static void path_include PARAMS ((cpp_reader *,
98 char *, int));
99 static void init_library PARAMS ((void));
100 static void init_builtins PARAMS ((cpp_reader *));
101 static void append_include_chain PARAMS ((cpp_reader *,
102 char *, int, int));
103 static struct search_path * remove_dup_dir PARAMS ((cpp_reader *,
104 struct search_path *));
105 static struct search_path * remove_dup_dirs PARAMS ((cpp_reader *,
106 struct search_path *));
107 static void merge_include_chains PARAMS ((cpp_reader *));
108 static bool push_include PARAMS ((cpp_reader *,
109 struct pending_option *));
110 static void free_chain PARAMS ((struct pending_option *));
111 static void set_lang PARAMS ((cpp_reader *, enum c_lang));
112 static void init_dependency_output PARAMS ((cpp_reader *));
113 static void init_standard_includes PARAMS ((cpp_reader *));
114 static void read_original_filename PARAMS ((cpp_reader *));
115 static void new_pending_directive PARAMS ((struct cpp_pending *,
116 const char *,
117 cl_directive_handler));
118 static void output_deps PARAMS ((cpp_reader *));
119 static int parse_option PARAMS ((const char *));
120
121 /* Fourth argument to append_include_chain: chain to use.
122 Note it's never asked to append to the quote chain. */
123 enum { BRACKET = 0, SYSTEM, AFTER };
124
125 /* If we have designated initializers (GCC >2.7) these tables can be
126 initialized, constant data. Otherwise, they have to be filled in at
127 runtime. */
128 #if HAVE_DESIGNATED_INITIALIZERS
129
130 #define init_trigraph_map() /* Nothing. */
131 #define TRIGRAPH_MAP \
132 __extension__ const uchar _cpp_trigraph_map[UCHAR_MAX + 1] = {
133
134 #define END };
135 #define s(p, v) [p] = v,
136
137 #else
138
139 #define TRIGRAPH_MAP uchar _cpp_trigraph_map[UCHAR_MAX + 1] = { 0 }; \
140 static void init_trigraph_map PARAMS ((void)) { \
141 unsigned char *x = _cpp_trigraph_map;
142
143 #define END }
144 #define s(p, v) x[p] = v;
145
146 #endif
147
148 TRIGRAPH_MAP
149 s('=', '#') s(')', ']') s('!', '|')
150 s('(', '[') s('\'', '^') s('>', '}')
151 s('/', '\\') s('<', '{') s('-', '~')
152 END
153
154 #undef s
155 #undef END
156 #undef TRIGRAPH_MAP
157
158 /* Given a colon-separated list of file names PATH,
159 add all the names to the search path for include files. */
160 static void
161 path_include (pfile, list, path)
162 cpp_reader *pfile;
163 char *list;
164 int path;
165 {
166 char *p, *q, *name;
167
168 p = list;
169
170 do
171 {
172 /* Find the end of this name. */
173 q = p;
174 while (*q != 0 && *q != PATH_SEPARATOR) q++;
175 if (q == p)
176 {
177 /* An empty name in the path stands for the current directory. */
178 name = (char *) xmalloc (2);
179 name[0] = '.';
180 name[1] = 0;
181 }
182 else
183 {
184 /* Otherwise use the directory that is named. */
185 name = (char *) xmalloc (q - p + 1);
186 memcpy (name, p, q - p);
187 name[q - p] = 0;
188 }
189
190 append_include_chain (pfile, name, path, 0);
191
192 /* Advance past this name. */
193 if (*q == 0)
194 break;
195 p = q + 1;
196 }
197 while (1);
198 }
199
200 /* Append DIR to include path PATH. DIR must be allocated on the
201 heap; this routine takes responsibility for freeing it. CXX_AWARE
202 is non-zero if the header contains extern "C" guards for C++,
203 otherwise it is zero. */
204 static void
205 append_include_chain (pfile, dir, path, cxx_aware)
206 cpp_reader *pfile;
207 char *dir;
208 int path;
209 int cxx_aware ATTRIBUTE_UNUSED;
210 {
211 struct cpp_pending *pend = CPP_OPTION (pfile, pending);
212 struct search_path *new;
213 struct stat st;
214 unsigned int len;
215
216 if (*dir == '\0')
217 {
218 free (dir);
219 dir = xstrdup (".");
220 }
221 _cpp_simplify_pathname (dir);
222
223 if (stat (dir, &st))
224 {
225 /* Dirs that don't exist are silently ignored. */
226 if (errno != ENOENT)
227 cpp_errno (pfile, DL_ERROR, dir);
228 else if (CPP_OPTION (pfile, verbose))
229 fprintf (stderr, _("ignoring nonexistent directory \"%s\"\n"), dir);
230 free (dir);
231 return;
232 }
233
234 if (!S_ISDIR (st.st_mode))
235 {
236 cpp_error_with_line (pfile, DL_ERROR, 0, 0, "%s: Not a directory", dir);
237 free (dir);
238 return;
239 }
240
241 len = strlen (dir);
242 if (len > pfile->max_include_len)
243 pfile->max_include_len = len;
244
245 new = (struct search_path *) xmalloc (sizeof (struct search_path));
246 new->name = dir;
247 new->len = len;
248 INO_T_COPY (new->ino, st.st_ino);
249 new->dev = st.st_dev;
250 /* Both systm and after include file lists should be treated as system
251 include files since these two lists are really just a concatenation
252 of one "system" list. */
253 if (path == SYSTEM || path == AFTER)
254 #ifdef NO_IMPLICIT_EXTERN_C
255 new->sysp = 1;
256 #else
257 new->sysp = cxx_aware ? 1 : 2;
258 #endif
259 else
260 new->sysp = 0;
261 new->name_map = NULL;
262 new->next = NULL;
263
264 switch (path)
265 {
266 case BRACKET: APPEND (pend, brack, new); break;
267 case SYSTEM: APPEND (pend, systm, new); break;
268 case AFTER: APPEND (pend, after, new); break;
269 }
270 }
271
272 /* Handle a duplicated include path. PREV is the link in the chain
273 before the duplicate. The duplicate is removed from the chain and
274 freed. Returns PREV. */
275 static struct search_path *
276 remove_dup_dir (pfile, prev)
277 cpp_reader *pfile;
278 struct search_path *prev;
279 {
280 struct search_path *cur = prev->next;
281
282 if (CPP_OPTION (pfile, verbose))
283 fprintf (stderr, _("ignoring duplicate directory \"%s\"\n"), cur->name);
284
285 prev->next = cur->next;
286 free ((PTR) cur->name);
287 free (cur);
288
289 return prev;
290 }
291
292 /* Remove duplicate directories from a chain. Returns the tail of the
293 chain, or NULL if the chain is empty. This algorithm is quadratic
294 in the number of -I switches, which is acceptable since there
295 aren't usually that many of them. */
296 static struct search_path *
297 remove_dup_dirs (pfile, head)
298 cpp_reader *pfile;
299 struct search_path *head;
300 {
301 struct search_path *prev = NULL, *cur, *other;
302
303 for (cur = head; cur; cur = cur->next)
304 {
305 for (other = head; other != cur; other = other->next)
306 if (INO_T_EQ (cur->ino, other->ino) && cur->dev == other->dev)
307 {
308 if (cur->sysp && !other->sysp)
309 {
310 cpp_error (pfile, DL_WARNING,
311 "changing search order for system directory \"%s\"",
312 cur->name);
313 if (strcmp (cur->name, other->name))
314 cpp_error (pfile, DL_WARNING,
315 " as it is the same as non-system directory \"%s\"",
316 other->name);
317 else
318 cpp_error (pfile, DL_WARNING,
319 " as it has already been specified as a non-system directory");
320 }
321 cur = remove_dup_dir (pfile, prev);
322 break;
323 }
324 prev = cur;
325 }
326
327 return prev;
328 }
329
330 /* Merge the four include chains together in the order quote, bracket,
331 system, after. Remove duplicate dirs (as determined by
332 INO_T_EQ()). The system_include and after_include chains are never
333 referred to again after this function; all access is through the
334 bracket_include path. */
335 static void
336 merge_include_chains (pfile)
337 cpp_reader *pfile;
338 {
339 struct search_path *quote, *brack, *systm, *qtail;
340
341 struct cpp_pending *pend = CPP_OPTION (pfile, pending);
342
343 quote = pend->quote_head;
344 brack = pend->brack_head;
345 systm = pend->systm_head;
346 qtail = pend->quote_tail;
347
348 /* Paste together bracket, system, and after include chains. */
349 if (systm)
350 pend->systm_tail->next = pend->after_head;
351 else
352 systm = pend->after_head;
353
354 if (brack)
355 pend->brack_tail->next = systm;
356 else
357 brack = systm;
358
359 /* This is a bit tricky. First we drop dupes from the quote-include
360 list. Then we drop dupes from the bracket-include list.
361 Finally, if qtail and brack are the same directory, we cut out
362 brack and move brack up to point to qtail.
363
364 We can't just merge the lists and then uniquify them because
365 then we may lose directories from the <> search path that should
366 be there; consider -Ifoo -Ibar -I- -Ifoo -Iquux. It is however
367 safe to treat -Ibar -Ifoo -I- -Ifoo -Iquux as if written
368 -Ibar -I- -Ifoo -Iquux. */
369
370 remove_dup_dirs (pfile, brack);
371 qtail = remove_dup_dirs (pfile, quote);
372
373 if (quote)
374 {
375 qtail->next = brack;
376
377 /* If brack == qtail, remove brack as it's simpler. */
378 if (brack && INO_T_EQ (qtail->ino, brack->ino)
379 && qtail->dev == brack->dev)
380 brack = remove_dup_dir (pfile, qtail);
381 }
382 else
383 quote = brack;
384
385 CPP_OPTION (pfile, quote_include) = quote;
386 CPP_OPTION (pfile, bracket_include) = brack;
387 }
388
389 /* A set of booleans indicating what CPP features each source language
390 requires. */
391 struct lang_flags
392 {
393 char c99;
394 char cplusplus;
395 char extended_numbers;
396 char trigraphs;
397 char dollars_in_ident;
398 char cplusplus_comments;
399 char digraphs;
400 };
401
402 /* ??? Enable $ in identifiers in assembly? */
403 static const struct lang_flags lang_defaults[] =
404 { /* c99 c++ xnum trig dollar c++comm digr */
405 /* GNUC89 */ { 0, 0, 1, 0, 1, 1, 1 },
406 /* GNUC99 */ { 1, 0, 1, 0, 1, 1, 1 },
407 /* STDC89 */ { 0, 0, 0, 1, 0, 0, 0 },
408 /* STDC94 */ { 0, 0, 0, 1, 0, 0, 1 },
409 /* STDC99 */ { 1, 0, 1, 1, 0, 1, 1 },
410 /* GNUCXX */ { 0, 1, 1, 0, 1, 1, 1 },
411 /* CXX98 */ { 0, 1, 1, 1, 0, 1, 1 },
412 /* ASM */ { 0, 0, 1, 0, 0, 1, 0 }
413 };
414
415 /* Sets internal flags correctly for a given language. */
416 static void
417 set_lang (pfile, lang)
418 cpp_reader *pfile;
419 enum c_lang lang;
420 {
421 const struct lang_flags *l = &lang_defaults[(int) lang];
422
423 CPP_OPTION (pfile, lang) = lang;
424
425 CPP_OPTION (pfile, c99) = l->c99;
426 CPP_OPTION (pfile, cplusplus) = l->cplusplus;
427 CPP_OPTION (pfile, extended_numbers) = l->extended_numbers;
428 CPP_OPTION (pfile, trigraphs) = l->trigraphs;
429 CPP_OPTION (pfile, dollars_in_ident) = l->dollars_in_ident;
430 CPP_OPTION (pfile, cplusplus_comments) = l->cplusplus_comments;
431 CPP_OPTION (pfile, digraphs) = l->digraphs;
432 }
433
434 #ifdef HOST_EBCDIC
435 static int opt_comp PARAMS ((const void *, const void *));
436
437 /* Run-time sorting of options array. */
438 static int
439 opt_comp (p1, p2)
440 const void *p1, *p2;
441 {
442 return strcmp (((struct cl_option *) p1)->opt_text,
443 ((struct cl_option *) p2)->opt_text);
444 }
445 #endif
446
447 /* init initializes library global state. It might not need to
448 do anything depending on the platform and compiler. */
449 static void
450 init_library ()
451 {
452 static int initialized = 0;
453
454 if (! initialized)
455 {
456 initialized = 1;
457
458 #ifdef HOST_EBCDIC
459 /* For non-ASCII hosts, the cl_options array needs to be sorted at
460 runtime. */
461 qsort (cl_options, N_OPTS, sizeof (struct cl_option), opt_comp);
462 #endif
463
464 /* Set up the trigraph map. This doesn't need to do anything if
465 we were compiled with a compiler that supports C99 designated
466 initializers. */
467 init_trigraph_map ();
468 }
469 }
470
471 /* Initialize a cpp_reader structure. */
472 cpp_reader *
473 cpp_create_reader (lang)
474 enum c_lang lang;
475 {
476 cpp_reader *pfile;
477
478 /* Initialise this instance of the library if it hasn't been already. */
479 init_library ();
480
481 pfile = (cpp_reader *) xcalloc (1, sizeof (cpp_reader));
482
483 set_lang (pfile, lang);
484 CPP_OPTION (pfile, warn_import) = 1;
485 CPP_OPTION (pfile, warn_multichar) = 1;
486 CPP_OPTION (pfile, discard_comments) = 1;
487 CPP_OPTION (pfile, discard_comments_in_macro_exp) = 1;
488 CPP_OPTION (pfile, show_column) = 1;
489 CPP_OPTION (pfile, tabstop) = 8;
490 CPP_OPTION (pfile, operator_names) = 1;
491 CPP_OPTION (pfile, warn_endif_labels) = 1;
492
493 CPP_OPTION (pfile, pending) =
494 (struct cpp_pending *) xcalloc (1, sizeof (struct cpp_pending));
495
496 /* Default CPP arithmetic to something sensible for the host for the
497 benefit of dumb users like fix-header. */
498 #define BITS_PER_HOST_WIDEST_INT (CHAR_BIT * sizeof (HOST_WIDEST_INT))
499 CPP_OPTION (pfile, precision) = BITS_PER_HOST_WIDEST_INT;
500 CPP_OPTION (pfile, char_precision) = CHAR_BIT;
501 CPP_OPTION (pfile, wchar_precision) = CHAR_BIT * sizeof (int);
502 CPP_OPTION (pfile, int_precision) = CHAR_BIT * sizeof (int);
503 CPP_OPTION (pfile, unsigned_char) = 0;
504 CPP_OPTION (pfile, unsigned_wchar) = 1;
505
506 /* It's simplest to just create this struct whether or not it will
507 be needed. */
508 pfile->deps = deps_init ();
509
510 /* Initialise the line map. Start at logical line 1, so we can use
511 a line number of zero for special states. */
512 init_line_maps (&pfile->line_maps);
513 pfile->trad_line = pfile->line = 1;
514
515 /* Initialize lexer state. */
516 pfile->state.save_comments = ! CPP_OPTION (pfile, discard_comments);
517
518 /* Set up static tokens. */
519 pfile->date.type = CPP_EOF;
520 pfile->avoid_paste.type = CPP_PADDING;
521 pfile->avoid_paste.val.source = NULL;
522 pfile->eof.type = CPP_EOF;
523 pfile->eof.flags = 0;
524
525 /* Create a token buffer for the lexer. */
526 _cpp_init_tokenrun (&pfile->base_run, 250);
527 pfile->cur_run = &pfile->base_run;
528 pfile->cur_token = pfile->base_run.base;
529
530 /* Initialise the base context. */
531 pfile->context = &pfile->base_context;
532 pfile->base_context.macro = 0;
533 pfile->base_context.prev = pfile->base_context.next = 0;
534
535 /* Aligned and unaligned storage. */
536 pfile->a_buff = _cpp_get_buff (pfile, 0);
537 pfile->u_buff = _cpp_get_buff (pfile, 0);
538
539 /* The expression parser stack. */
540 _cpp_expand_op_stack (pfile);
541
542 /* Initialise the buffer obstack. */
543 gcc_obstack_init (&pfile->buffer_ob);
544
545 _cpp_init_includes (pfile);
546
547 return pfile;
548 }
549
550 /* Free resources used by PFILE. Accessing PFILE after this function
551 returns leads to undefined behaviour. Returns the error count. */
552 int
553 cpp_destroy (pfile)
554 cpp_reader *pfile;
555 {
556 int result;
557 struct search_path *dir, *dirn;
558 cpp_context *context, *contextn;
559 tokenrun *run, *runn;
560
561 free_chain (CPP_OPTION (pfile, pending)->include_head);
562 free (CPP_OPTION (pfile, pending));
563 free (pfile->op_stack);
564
565 while (CPP_BUFFER (pfile) != NULL)
566 _cpp_pop_buffer (pfile);
567
568 if (pfile->trad_out_base)
569 free (pfile->trad_out_base);
570
571 if (pfile->macro_buffer)
572 {
573 free ((PTR) pfile->macro_buffer);
574 pfile->macro_buffer = NULL;
575 pfile->macro_buffer_len = 0;
576 }
577
578 deps_free (pfile->deps);
579 obstack_free (&pfile->buffer_ob, 0);
580
581 _cpp_destroy_hashtable (pfile);
582 _cpp_cleanup_includes (pfile);
583
584 _cpp_free_buff (pfile->a_buff);
585 _cpp_free_buff (pfile->u_buff);
586 _cpp_free_buff (pfile->free_buffs);
587
588 for (run = &pfile->base_run; run; run = runn)
589 {
590 runn = run->next;
591 free (run->base);
592 if (run != &pfile->base_run)
593 free (run);
594 }
595
596 for (dir = CPP_OPTION (pfile, quote_include); dir; dir = dirn)
597 {
598 dirn = dir->next;
599 free ((PTR) dir->name);
600 free (dir);
601 }
602
603 for (context = pfile->base_context.next; context; context = contextn)
604 {
605 contextn = context->next;
606 free (context);
607 }
608
609 free_line_maps (&pfile->line_maps);
610
611 result = pfile->errors;
612 free (pfile);
613
614 return result;
615 }
616
617 /* This structure defines one built-in identifier. A node will be
618 entered in the hash table under the name NAME, with value VALUE.
619
620 There are two tables of these. builtin_array holds all the
621 "builtin" macros: these are handled by builtin_macro() in
622 cppmacro.c. Builtin is somewhat of a misnomer -- the property of
623 interest is that these macros require special code to compute their
624 expansions. The value is a "builtin_type" enumerator.
625
626 operator_array holds the C++ named operators. These are keywords
627 which act as aliases for punctuators. In C++, they cannot be
628 altered through #define, and #if recognizes them as operators. In
629 C, these are not entered into the hash table at all (but see
630 <iso646.h>). The value is a token-type enumerator. */
631 struct builtin
632 {
633 const uchar *name;
634 unsigned short len;
635 unsigned short value;
636 };
637
638 #define B(n, t) { DSC(n), t }
639 static const struct builtin builtin_array[] =
640 {
641 B("__TIME__", BT_TIME),
642 B("__DATE__", BT_DATE),
643 B("__FILE__", BT_FILE),
644 B("__BASE_FILE__", BT_BASE_FILE),
645 B("__LINE__", BT_SPECLINE),
646 B("__INCLUDE_LEVEL__", BT_INCLUDE_LEVEL),
647 B("_Pragma", BT_PRAGMA),
648 B("__STDC__", BT_STDC),
649 };
650
651 static const struct builtin operator_array[] =
652 {
653 B("and", CPP_AND_AND),
654 B("and_eq", CPP_AND_EQ),
655 B("bitand", CPP_AND),
656 B("bitor", CPP_OR),
657 B("compl", CPP_COMPL),
658 B("not", CPP_NOT),
659 B("not_eq", CPP_NOT_EQ),
660 B("or", CPP_OR_OR),
661 B("or_eq", CPP_OR_EQ),
662 B("xor", CPP_XOR),
663 B("xor_eq", CPP_XOR_EQ)
664 };
665 #undef B
666
667 /* Subroutine of cpp_read_main_file; reads the builtins table above and
668 enters them, and language-specific macros, into the hash table. */
669 static void
670 init_builtins (pfile)
671 cpp_reader *pfile;
672 {
673 const struct builtin *b;
674
675 for(b = builtin_array;
676 b < (builtin_array + ARRAY_SIZE (builtin_array));
677 b++)
678 {
679 cpp_hashnode *hp = cpp_lookup (pfile, b->name, b->len);
680 hp->type = NT_MACRO;
681 hp->flags |= NODE_BUILTIN | NODE_WARN;
682 hp->value.builtin = b->value;
683 }
684
685 if (CPP_OPTION (pfile, cplusplus) && CPP_OPTION (pfile, operator_names))
686 for (b = operator_array;
687 b < (operator_array + ARRAY_SIZE (operator_array));
688 b++)
689 {
690 cpp_hashnode *hp = cpp_lookup (pfile, b->name, b->len);
691 hp->flags |= NODE_OPERATOR;
692 hp->value.operator = b->value;
693 }
694
695 if (CPP_OPTION (pfile, cplusplus))
696 _cpp_define_builtin (pfile, "__cplusplus 1");
697 else if (CPP_OPTION (pfile, objc))
698 _cpp_define_builtin (pfile, "__OBJC__ 1");
699 else if (CPP_OPTION (pfile, lang) == CLK_ASM)
700 _cpp_define_builtin (pfile, "__ASSEMBLER__ 1");
701
702 if (CPP_OPTION (pfile, lang) == CLK_STDC94)
703 _cpp_define_builtin (pfile, "__STDC_VERSION__ 199409L");
704 else if (CPP_OPTION (pfile, c99))
705 _cpp_define_builtin (pfile, "__STDC_VERSION__ 199901L");
706
707 if (pfile->cb.register_builtins)
708 (*pfile->cb.register_builtins) (pfile);
709 }
710
711 /* And another subroutine. This one sets up the standard include path. */
712 static void
713 init_standard_includes (pfile)
714 cpp_reader *pfile;
715 {
716 char *path;
717 const struct default_include *p;
718 const char *specd_prefix = CPP_OPTION (pfile, include_prefix);
719
720 /* Several environment variables may add to the include search path.
721 CPATH specifies an additional list of directories to be searched
722 as if specified with -I, while C_INCLUDE_PATH, CPLUS_INCLUDE_PATH,
723 etc. specify an additional list of directories to be searched as
724 if specified with -isystem, for the language indicated. */
725
726 GET_ENV_PATH_LIST (path, "CPATH");
727 if (path != 0 && *path != 0)
728 path_include (pfile, path, BRACKET);
729
730 switch ((CPP_OPTION (pfile, objc) << 1) + CPP_OPTION (pfile, cplusplus))
731 {
732 case 0:
733 GET_ENV_PATH_LIST (path, "C_INCLUDE_PATH");
734 break;
735 case 1:
736 GET_ENV_PATH_LIST (path, "CPLUS_INCLUDE_PATH");
737 break;
738 case 2:
739 GET_ENV_PATH_LIST (path, "OBJC_INCLUDE_PATH");
740 break;
741 case 3:
742 GET_ENV_PATH_LIST (path, "OBJCPLUS_INCLUDE_PATH");
743 break;
744 }
745 if (path != 0 && *path != 0)
746 path_include (pfile, path, SYSTEM);
747
748 /* Search "translated" versions of GNU directories.
749 These have /usr/local/lib/gcc... replaced by specd_prefix. */
750 if (specd_prefix != 0 && cpp_GCC_INCLUDE_DIR_len)
751 {
752 /* Remove the `include' from /usr/local/lib/gcc.../include.
753 GCC_INCLUDE_DIR will always end in /include. */
754 int default_len = cpp_GCC_INCLUDE_DIR_len;
755 char *default_prefix = (char *) alloca (default_len + 1);
756 int specd_len = strlen (specd_prefix);
757
758 memcpy (default_prefix, cpp_GCC_INCLUDE_DIR, default_len);
759 default_prefix[default_len] = '\0';
760
761 for (p = cpp_include_defaults; p->fname; p++)
762 {
763 /* Some standard dirs are only for C++. */
764 if (!p->cplusplus
765 || (CPP_OPTION (pfile, cplusplus)
766 && !CPP_OPTION (pfile, no_standard_cplusplus_includes)))
767 {
768 /* Does this dir start with the prefix? */
769 if (!memcmp (p->fname, default_prefix, default_len))
770 {
771 /* Yes; change prefix and add to search list. */
772 int flen = strlen (p->fname);
773 int this_len = specd_len + flen - default_len;
774 char *str = (char *) xmalloc (this_len + 1);
775 memcpy (str, specd_prefix, specd_len);
776 memcpy (str + specd_len,
777 p->fname + default_len,
778 flen - default_len + 1);
779
780 append_include_chain (pfile, str, SYSTEM, p->cxx_aware);
781 }
782 }
783 }
784 }
785
786 /* Search ordinary names for GNU include directories. */
787 for (p = cpp_include_defaults; p->fname; p++)
788 {
789 /* Some standard dirs are only for C++. */
790 if (!p->cplusplus
791 || (CPP_OPTION (pfile, cplusplus)
792 && !CPP_OPTION (pfile, no_standard_cplusplus_includes)))
793 {
794 char *str = update_path (p->fname, p->component);
795 append_include_chain (pfile, str, SYSTEM, p->cxx_aware);
796 }
797 }
798 }
799
800 /* Pushes a command line -imacro and -include file indicated by P onto
801 the buffer stack. Returns non-zero if successful. */
802 static bool
803 push_include (pfile, p)
804 cpp_reader *pfile;
805 struct pending_option *p;
806 {
807 cpp_token header;
808
809 /* Later: maybe update this to use the #include "" search path
810 if cpp_read_file fails. */
811 header.type = CPP_STRING;
812 header.val.str.text = (const unsigned char *) p->arg;
813 header.val.str.len = strlen (p->arg);
814 /* Make the command line directive take up a line. */
815 pfile->line++;
816
817 return _cpp_execute_include (pfile, &header, IT_CMDLINE);
818 }
819
820 /* Frees a pending_option chain. */
821 static void
822 free_chain (head)
823 struct pending_option *head;
824 {
825 struct pending_option *next;
826
827 while (head)
828 {
829 next = head->next;
830 free (head);
831 head = next;
832 }
833 }
834
835 /* Sanity-checks are dependent on command-line options, so it is
836 called as a subroutine of cpp_read_main_file (). */
837 #if ENABLE_CHECKING
838 static void sanity_checks PARAMS ((cpp_reader *));
839 static void sanity_checks (pfile)
840 cpp_reader *pfile;
841 {
842 cppchar_t test = 0;
843
844 /* Sanity checks for assumptions about CPP arithmetic and target
845 type precisions made by cpplib. */
846 test--;
847 if (test < 1)
848 cpp_error (pfile, DL_FATAL, "cppchar_t must be an unsigned type");
849
850 if (CPP_OPTION (pfile, precision) > BITS_PER_HOST_WIDEST_INT)
851 cpp_error (pfile, DL_FATAL,
852 "preprocessor arithmetic has maximum precision of %lu bits; target requires %lu bits",
853 (unsigned long)BITS_PER_HOST_WIDEST_INT,
854 (unsigned long)CPP_OPTION (pfile, precision));
855
856 if (CPP_OPTION (pfile, precision) < CPP_OPTION (pfile, int_precision))
857 cpp_error (pfile, DL_FATAL,
858 "CPP arithmetic must be at least as precise as a target int");
859
860 if (CPP_OPTION (pfile, char_precision) < 8)
861 cpp_error (pfile, DL_FATAL, "target char is less than 8 bits wide");
862
863 if (CPP_OPTION (pfile, wchar_precision) < CPP_OPTION (pfile, char_precision))
864 cpp_error (pfile, DL_FATAL,
865 "target wchar_t is narrower than target char");
866
867 if (CPP_OPTION (pfile, int_precision) < CPP_OPTION (pfile, char_precision))
868 cpp_error (pfile, DL_FATAL,
869 "target int is narrower than target char");
870
871 if (CPP_OPTION (pfile, wchar_precision) > BITS_PER_CPPCHAR_T)
872 cpp_error (pfile, DL_FATAL,
873 "CPP on this host cannot handle wide character constants over %lu bits, but the target requires %lu bits",
874 (unsigned long)BITS_PER_CPPCHAR_T,
875 (unsigned long)CPP_OPTION (pfile, wchar_precision));
876 }
877 #else
878 # define sanity_checks(PFILE)
879 #endif
880
881 /* This is called after options have been parsed, and partially
882 processed. Setup for processing input from the file named FNAME,
883 or stdin if it is the empty string. Return the original filename
884 on success (e.g. foo.i->foo.c), or NULL on failure. */
885 const char *
886 cpp_read_main_file (pfile, fname, table)
887 cpp_reader *pfile;
888 const char *fname;
889 hash_table *table;
890 {
891 sanity_checks (pfile);
892
893 /* The front ends don't set up the hash table until they have
894 finished processing the command line options, so initializing the
895 hashtable is deferred until now. */
896 _cpp_init_hashtable (pfile, table);
897
898 /* Set up the include search path now. */
899 if (! CPP_OPTION (pfile, no_standard_includes))
900 init_standard_includes (pfile);
901
902 merge_include_chains (pfile);
903
904 /* With -v, print the list of dirs to search. */
905 if (CPP_OPTION (pfile, verbose))
906 {
907 struct search_path *l;
908 fprintf (stderr, _("#include \"...\" search starts here:\n"));
909 for (l = CPP_OPTION (pfile, quote_include); l; l = l->next)
910 {
911 if (l == CPP_OPTION (pfile, bracket_include))
912 fprintf (stderr, _("#include <...> search starts here:\n"));
913 fprintf (stderr, " %s\n", l->name);
914 }
915 fprintf (stderr, _("End of search list.\n"));
916 }
917
918 if (CPP_OPTION (pfile, print_deps))
919 /* Set the default target (if there is none already). */
920 deps_add_default_target (pfile->deps, fname);
921
922 /* Open the main input file. */
923 if (!_cpp_read_file (pfile, fname))
924 return NULL;
925
926 /* Set this after cpp_post_options so the client can change the
927 option if it wishes, and after stacking the main file so we don't
928 trace the main file. */
929 pfile->line_maps.trace_includes = CPP_OPTION (pfile, print_include_names);
930
931 /* For foo.i, read the original filename foo.c now, for the benefit
932 of the front ends. */
933 if (CPP_OPTION (pfile, preprocessed))
934 read_original_filename (pfile);
935 /* Overlay an empty buffer to seed traditional preprocessing. */
936 else if (CPP_OPTION (pfile, traditional))
937 _cpp_overlay_buffer (pfile, U"", 0);
938
939 return pfile->map->to_file;
940 }
941
942 /* For preprocessed files, if the first tokens are of the form # NUM.
943 handle the directive so we know the original file name. This will
944 generate file_change callbacks, which the front ends must handle
945 appropriately given their state of initialization. */
946 static void
947 read_original_filename (pfile)
948 cpp_reader *pfile;
949 {
950 const cpp_token *token, *token1;
951
952 /* Lex ahead; if the first tokens are of the form # NUM, then
953 process the directive, otherwise back up. */
954 token = _cpp_lex_direct (pfile);
955 if (token->type == CPP_HASH)
956 {
957 token1 = _cpp_lex_direct (pfile);
958 _cpp_backup_tokens (pfile, 1);
959
960 /* If it's a #line directive, handle it. */
961 if (token1->type == CPP_NUMBER)
962 {
963 _cpp_handle_directive (pfile, token->flags & PREV_WHITE);
964 return;
965 }
966 }
967
968 /* Backup as if nothing happened. */
969 _cpp_backup_tokens (pfile, 1);
970 }
971
972 /* Handle pending command line options: -D, -U, -A, -imacros and
973 -include. This should be called after debugging has been properly
974 set up in the front ends. */
975 void
976 cpp_finish_options (pfile)
977 cpp_reader *pfile;
978 {
979 /* Install builtins and process command line macros etc. in the order
980 they appeared, but only if not already preprocessed. */
981 if (! CPP_OPTION (pfile, preprocessed))
982 {
983 struct pending_option *p;
984
985 _cpp_do_file_change (pfile, LC_RENAME, _("<built-in>"), 1, 0);
986 if (!CPP_OPTION (pfile, traditional) /* REMOVEME */)
987 init_builtins (pfile);
988 _cpp_do_file_change (pfile, LC_RENAME, _("<command line>"), 1, 0);
989 if (!CPP_OPTION (pfile, traditional) /* REMOVEME */)
990 for (p = CPP_OPTION (pfile, pending)->directive_head; p; p = p->next)
991 (*p->handler) (pfile, p->arg);
992
993 /* Scan -imacros files after -D, -U, but before -include.
994 pfile->next_include_file is NULL, so _cpp_pop_buffer does not
995 push -include files. */
996 for (p = CPP_OPTION (pfile, pending)->imacros_head; p; p = p->next)
997 if (push_include (pfile, p))
998 cpp_scan_nooutput (pfile);
999
1000 pfile->next_include_file = &CPP_OPTION (pfile, pending)->include_head;
1001 _cpp_maybe_push_include_file (pfile);
1002 }
1003
1004 free_chain (CPP_OPTION (pfile, pending)->imacros_head);
1005 free_chain (CPP_OPTION (pfile, pending)->directive_head);
1006 }
1007
1008 /* Push the next buffer on the stack given by -include, if any. */
1009 void
1010 _cpp_maybe_push_include_file (pfile)
1011 cpp_reader *pfile;
1012 {
1013 if (pfile->next_include_file)
1014 {
1015 struct pending_option *head = *pfile->next_include_file;
1016
1017 while (head && !push_include (pfile, head))
1018 head = head->next;
1019
1020 if (head)
1021 pfile->next_include_file = &head->next;
1022 else
1023 {
1024 /* All done; restore the line map from <command line>. */
1025 _cpp_do_file_change (pfile, LC_RENAME,
1026 pfile->line_maps.maps[0].to_file, 1, 0);
1027 /* Don't come back here again. */
1028 pfile->next_include_file = NULL;
1029 }
1030 }
1031 }
1032
1033 /* Use mkdeps.c to output dependency information. */
1034 static void
1035 output_deps (pfile)
1036 cpp_reader *pfile;
1037 {
1038 /* Stream on which to print the dependency information. */
1039 FILE *deps_stream = 0;
1040 const char *const deps_mode =
1041 CPP_OPTION (pfile, print_deps_append) ? "a" : "w";
1042
1043 if (CPP_OPTION (pfile, deps_file)[0] == '\0')
1044 deps_stream = stdout;
1045 else
1046 {
1047 deps_stream = fopen (CPP_OPTION (pfile, deps_file), deps_mode);
1048 if (deps_stream == 0)
1049 {
1050 cpp_errno (pfile, DL_ERROR, CPP_OPTION (pfile, deps_file));
1051 return;
1052 }
1053 }
1054
1055 deps_write (pfile->deps, deps_stream, 72);
1056
1057 if (CPP_OPTION (pfile, deps_phony_targets))
1058 deps_phony_targets (pfile->deps, deps_stream);
1059
1060 /* Don't close stdout. */
1061 if (deps_stream != stdout)
1062 {
1063 if (ferror (deps_stream) || fclose (deps_stream) != 0)
1064 cpp_error (pfile, DL_FATAL, "I/O error on output");
1065 }
1066 }
1067
1068 /* This is called at the end of preprocessing. It pops the
1069 last buffer and writes dependency output. It should also
1070 clear macro definitions, such that you could call cpp_start_read
1071 with a new filename to restart processing. */
1072 void
1073 cpp_finish (pfile)
1074 cpp_reader *pfile;
1075 {
1076 /* cpplex.c leaves the final buffer on the stack. This it so that
1077 it returns an unending stream of CPP_EOFs to the client. If we
1078 popped the buffer, we'd dereference a NULL buffer pointer and
1079 segfault. It's nice to allow the client to do worry-free excess
1080 cpp_get_token calls. */
1081 while (pfile->buffer)
1082 _cpp_pop_buffer (pfile);
1083
1084 /* Don't write the deps file if preprocessing has failed. */
1085 if (CPP_OPTION (pfile, print_deps) && pfile->errors == 0)
1086 output_deps (pfile);
1087
1088 /* Report on headers that could use multiple include guards. */
1089 if (CPP_OPTION (pfile, print_include_names))
1090 _cpp_report_missing_guards (pfile);
1091 }
1092
1093 /* Add a directive to be handled later in the initialization phase. */
1094 static void
1095 new_pending_directive (pend, text, handler)
1096 struct cpp_pending *pend;
1097 const char *text;
1098 cl_directive_handler handler;
1099 {
1100 struct pending_option *o = (struct pending_option *)
1101 xmalloc (sizeof (struct pending_option));
1102
1103 o->arg = text;
1104 o->next = NULL;
1105 o->handler = handler;
1106 APPEND (pend, directive, o);
1107 }
1108
1109 /* Irix6 "cc -n32" and OSF4 cc have problems with char foo[] = ("string");
1110 I.e. a const string initializer with parens around it. That is
1111 what N_("string") resolves to, so we make no_* be macros instead. */
1112 #define no_arg N_("argument missing after %s")
1113 #define no_ass N_("assertion missing after %s")
1114 #define no_dir N_("directory name missing after %s")
1115 #define no_fil N_("file name missing after %s")
1116 #define no_mac N_("macro name missing after %s")
1117 #define no_pth N_("path name missing after %s")
1118 #define no_num N_("number missing after %s")
1119 #define no_tgt N_("target missing after %s")
1120
1121 /* This is the list of all command line options, with the leading
1122 "-" removed. It must be sorted in ASCII collating order. */
1123 #define COMMAND_LINE_OPTIONS \
1124 DEF_OPT("$", 0, OPT_dollar) \
1125 DEF_OPT("-help", 0, OPT__help) \
1126 DEF_OPT("-target-help", 0, OPT_target__help) \
1127 DEF_OPT("-version", 0, OPT__version) \
1128 DEF_OPT("A", no_ass, OPT_A) \
1129 DEF_OPT("C", 0, OPT_C) \
1130 DEF_OPT("CC", 0, OPT_CC) \
1131 DEF_OPT("D", no_mac, OPT_D) \
1132 DEF_OPT("H", 0, OPT_H) \
1133 DEF_OPT("I", no_dir, OPT_I) \
1134 DEF_OPT("M", 0, OPT_M) \
1135 DEF_OPT("MD", no_fil, OPT_MD) \
1136 DEF_OPT("MF", no_fil, OPT_MF) \
1137 DEF_OPT("MG", 0, OPT_MG) \
1138 DEF_OPT("MM", 0, OPT_MM) \
1139 DEF_OPT("MMD", no_fil, OPT_MMD) \
1140 DEF_OPT("MP", 0, OPT_MP) \
1141 DEF_OPT("MQ", no_tgt, OPT_MQ) \
1142 DEF_OPT("MT", no_tgt, OPT_MT) \
1143 DEF_OPT("P", 0, OPT_P) \
1144 DEF_OPT("U", no_mac, OPT_U) \
1145 DEF_OPT("W", no_arg, OPT_W) /* arg optional */ \
1146 DEF_OPT("d", no_arg, OPT_d) \
1147 DEF_OPT("fno-operator-names", 0, OPT_fno_operator_names) \
1148 DEF_OPT("fno-preprocessed", 0, OPT_fno_preprocessed) \
1149 DEF_OPT("fno-show-column", 0, OPT_fno_show_column) \
1150 DEF_OPT("fpreprocessed", 0, OPT_fpreprocessed) \
1151 DEF_OPT("fshow-column", 0, OPT_fshow_column) \
1152 DEF_OPT("ftabstop=", no_num, OPT_ftabstop) \
1153 DEF_OPT("h", 0, OPT_h) \
1154 DEF_OPT("idirafter", no_dir, OPT_idirafter) \
1155 DEF_OPT("imacros", no_fil, OPT_imacros) \
1156 DEF_OPT("include", no_fil, OPT_include) \
1157 DEF_OPT("iprefix", no_pth, OPT_iprefix) \
1158 DEF_OPT("isystem", no_dir, OPT_isystem) \
1159 DEF_OPT("iwithprefix", no_dir, OPT_iwithprefix) \
1160 DEF_OPT("iwithprefixbefore", no_dir, OPT_iwithprefixbefore) \
1161 DEF_OPT("lang-asm", 0, OPT_lang_asm) \
1162 DEF_OPT("lang-c", 0, OPT_lang_c) \
1163 DEF_OPT("lang-c++", 0, OPT_lang_cplusplus) \
1164 DEF_OPT("lang-c89", 0, OPT_lang_c89) \
1165 DEF_OPT("lang-objc", 0, OPT_lang_objc) \
1166 DEF_OPT("nostdinc", 0, OPT_nostdinc) \
1167 DEF_OPT("nostdinc++", 0, OPT_nostdincplusplus) \
1168 DEF_OPT("o", no_fil, OPT_o) \
1169 DEF_OPT("pedantic", 0, OPT_pedantic) \
1170 DEF_OPT("pedantic-errors", 0, OPT_pedantic_errors) \
1171 DEF_OPT("remap", 0, OPT_remap) \
1172 DEF_OPT("std=c++98", 0, OPT_std_cplusplus98) \
1173 DEF_OPT("std=c89", 0, OPT_std_c89) \
1174 DEF_OPT("std=c99", 0, OPT_std_c99) \
1175 DEF_OPT("std=c9x", 0, OPT_std_c9x) \
1176 DEF_OPT("std=gnu89", 0, OPT_std_gnu89) \
1177 DEF_OPT("std=gnu99", 0, OPT_std_gnu99) \
1178 DEF_OPT("std=gnu9x", 0, OPT_std_gnu9x) \
1179 DEF_OPT("std=iso9899:1990", 0, OPT_std_iso9899_1990) \
1180 DEF_OPT("std=iso9899:199409", 0, OPT_std_iso9899_199409) \
1181 DEF_OPT("std=iso9899:1999", 0, OPT_std_iso9899_1999) \
1182 DEF_OPT("std=iso9899:199x", 0, OPT_std_iso9899_199x) \
1183 DEF_OPT("traditional-cpp", 0, OPT_traditional_cpp) \
1184 DEF_OPT("trigraphs", 0, OPT_trigraphs) \
1185 DEF_OPT("v", 0, OPT_v) \
1186 DEF_OPT("version", 0, OPT_version) \
1187 DEF_OPT("w", 0, OPT_w)
1188
1189 #define DEF_OPT(text, msg, code) code,
1190 enum opt_code
1191 {
1192 COMMAND_LINE_OPTIONS
1193 N_OPTS
1194 };
1195 #undef DEF_OPT
1196
1197 struct cl_option
1198 {
1199 const char *opt_text;
1200 const char *msg;
1201 size_t opt_len;
1202 enum opt_code opt_code;
1203 };
1204
1205 #define DEF_OPT(text, msg, code) { text, msg, sizeof(text) - 1, code },
1206 #ifdef HOST_EBCDIC
1207 static struct cl_option cl_options[] =
1208 #else
1209 static const struct cl_option cl_options[] =
1210 #endif
1211 {
1212 COMMAND_LINE_OPTIONS
1213 };
1214 #undef DEF_OPT
1215 #undef COMMAND_LINE_OPTIONS
1216
1217 /* Perform a binary search to find which, if any, option the given
1218 command-line matches. Returns its index in the option array,
1219 negative on failure. Complications arise since some options can be
1220 suffixed with an argument, and multiple complete matches can occur,
1221 e.g. -iwithprefix and -iwithprefixbefore. Moreover, we need to
1222 accept options beginning with -W that we do not recognise, but not
1223 to swallow any subsequent command line argument; this is handled as
1224 special cases in cpp_handle_option. */
1225 static int
1226 parse_option (input)
1227 const char *input;
1228 {
1229 unsigned int md, mn, mx;
1230 size_t opt_len;
1231 int comp;
1232
1233 mn = 0;
1234 mx = N_OPTS;
1235
1236 while (mx > mn)
1237 {
1238 md = (mn + mx) / 2;
1239
1240 opt_len = cl_options[md].opt_len;
1241 comp = memcmp (input, cl_options[md].opt_text, opt_len);
1242
1243 if (comp > 0)
1244 mn = md + 1;
1245 else if (comp < 0)
1246 mx = md;
1247 else
1248 {
1249 if (input[opt_len] == '\0')
1250 return md;
1251 /* We were passed more text. If the option takes an argument,
1252 we may match a later option or we may have been passed the
1253 argument. The longest possible option match succeeds.
1254 If the option takes no arguments we have not matched and
1255 continue the search (e.g. input="stdc++" match was "stdc"). */
1256 mn = md + 1;
1257 if (cl_options[md].msg)
1258 {
1259 /* Scan forwards. If we get an exact match, return it.
1260 Otherwise, return the longest option-accepting match.
1261 This loops no more than twice with current options. */
1262 mx = md;
1263 for (; mn < (unsigned int) N_OPTS; mn++)
1264 {
1265 opt_len = cl_options[mn].opt_len;
1266 if (memcmp (input, cl_options[mn].opt_text, opt_len))
1267 break;
1268 if (input[opt_len] == '\0')
1269 return mn;
1270 if (cl_options[mn].msg)
1271 mx = mn;
1272 }
1273 return mx;
1274 }
1275 }
1276 }
1277
1278 return -1;
1279 }
1280
1281 /* Handle one command-line option in (argc, argv).
1282 Can be called multiple times, to handle multiple sets of options.
1283 If ignore is non-zero, this will ignore unrecognized -W* options.
1284 Returns number of strings consumed. */
1285 int
1286 cpp_handle_option (pfile, argc, argv, ignore)
1287 cpp_reader *pfile;
1288 int argc;
1289 char **argv;
1290 int ignore;
1291 {
1292 int i = 0;
1293 struct cpp_pending *pend = CPP_OPTION (pfile, pending);
1294
1295 /* Interpret "-" or a non-option as a file name. */
1296 if (argv[i][0] != '-' || argv[i][1] == '\0')
1297 {
1298 if (CPP_OPTION (pfile, in_fname) == NULL)
1299 CPP_OPTION (pfile, in_fname) = argv[i];
1300 else if (CPP_OPTION (pfile, out_fname) == NULL)
1301 CPP_OPTION (pfile, out_fname) = argv[i];
1302 else
1303 cpp_error (pfile, DL_FATAL,
1304 "too many filenames. Type %s --help for usage info",
1305 progname);
1306 }
1307 else
1308 {
1309 enum opt_code opt_code;
1310 int opt_index;
1311 const char *arg = 0;
1312
1313 /* Skip over '-'. */
1314 opt_index = parse_option (&argv[i][1]);
1315 if (opt_index < 0)
1316 return i;
1317
1318 opt_code = cl_options[opt_index].opt_code;
1319 if (cl_options[opt_index].msg)
1320 {
1321 arg = &argv[i][cl_options[opt_index].opt_len + 1];
1322
1323 /* Yuk. Special case for -W as it must not swallow
1324 up any following argument. If this becomes common, add
1325 another field to the cl_options table. */
1326 if (arg[0] == '\0' && opt_code != OPT_W)
1327 {
1328 arg = argv[++i];
1329 if (!arg)
1330 {
1331 cpp_error (pfile, DL_FATAL,
1332 cl_options[opt_index].msg, argv[i - 1]);
1333 return argc;
1334 }
1335 }
1336 }
1337
1338 switch (opt_code)
1339 {
1340 case N_OPTS: /* Shut GCC up. */
1341 break;
1342 case OPT_fno_operator_names:
1343 CPP_OPTION (pfile, operator_names) = 0;
1344 break;
1345 case OPT_fpreprocessed:
1346 CPP_OPTION (pfile, preprocessed) = 1;
1347 break;
1348 case OPT_fno_preprocessed:
1349 CPP_OPTION (pfile, preprocessed) = 0;
1350 break;
1351 case OPT_fshow_column:
1352 CPP_OPTION (pfile, show_column) = 1;
1353 break;
1354 case OPT_fno_show_column:
1355 CPP_OPTION (pfile, show_column) = 0;
1356 break;
1357 case OPT_ftabstop:
1358 /* Silently ignore empty string, non-longs and silly values. */
1359 if (arg[0] != '\0')
1360 {
1361 char *endptr;
1362 long tabstop = strtol (arg, &endptr, 10);
1363 if (*endptr == '\0' && tabstop >= 1 && tabstop <= 100)
1364 CPP_OPTION (pfile, tabstop) = tabstop;
1365 }
1366 break;
1367 case OPT_w:
1368 CPP_OPTION (pfile, inhibit_warnings) = 1;
1369 break;
1370 case OPT_h:
1371 case OPT__help:
1372 print_help ();
1373 CPP_OPTION (pfile, help_only) = 1;
1374 break;
1375 case OPT_target__help:
1376 /* Print if any target specific options. cpplib has none, but
1377 make sure help_only gets set. */
1378 CPP_OPTION (pfile, help_only) = 1;
1379 break;
1380
1381 /* --version inhibits compilation, -version doesn't. -v means
1382 verbose and -version. Historical reasons, don't ask. */
1383 case OPT__version:
1384 CPP_OPTION (pfile, help_only) = 1;
1385 pfile->print_version = 1;
1386 break;
1387 case OPT_v:
1388 CPP_OPTION (pfile, verbose) = 1;
1389 pfile->print_version = 1;
1390 break;
1391 case OPT_version:
1392 pfile->print_version = 1;
1393 break;
1394
1395 case OPT_C:
1396 CPP_OPTION (pfile, discard_comments) = 0;
1397 break;
1398 case OPT_CC:
1399 CPP_OPTION (pfile, discard_comments) = 0;
1400 CPP_OPTION (pfile, discard_comments_in_macro_exp) = 0;
1401 break;
1402 case OPT_P:
1403 CPP_OPTION (pfile, no_line_commands) = 1;
1404 break;
1405 case OPT_dollar: /* Don't include $ in identifiers. */
1406 CPP_OPTION (pfile, dollars_in_ident) = 0;
1407 break;
1408 case OPT_H:
1409 CPP_OPTION (pfile, print_include_names) = 1;
1410 break;
1411 case OPT_D:
1412 new_pending_directive (pend, arg, cpp_define);
1413 break;
1414 case OPT_pedantic_errors:
1415 CPP_OPTION (pfile, pedantic_errors) = 1;
1416 /* fall through */
1417 case OPT_pedantic:
1418 CPP_OPTION (pfile, pedantic) = 1;
1419 CPP_OPTION (pfile, warn_endif_labels) = 1;
1420 break;
1421 case OPT_trigraphs:
1422 CPP_OPTION (pfile, trigraphs) = 1;
1423 break;
1424 case OPT_remap:
1425 CPP_OPTION (pfile, remap) = 1;
1426 break;
1427 case OPT_traditional_cpp:
1428 CPP_OPTION (pfile, traditional) = 1;
1429 break;
1430 case OPT_iprefix:
1431 CPP_OPTION (pfile, include_prefix) = arg;
1432 CPP_OPTION (pfile, include_prefix_len) = strlen (arg);
1433 break;
1434 case OPT_lang_c:
1435 set_lang (pfile, CLK_GNUC89);
1436 break;
1437 case OPT_lang_cplusplus:
1438 set_lang (pfile, CLK_GNUCXX);
1439 break;
1440 case OPT_lang_objc:
1441 CPP_OPTION (pfile, objc) = 1;
1442 break;
1443 case OPT_lang_asm:
1444 set_lang (pfile, CLK_ASM);
1445 break;
1446 case OPT_std_cplusplus98:
1447 set_lang (pfile, CLK_CXX98);
1448 break;
1449 case OPT_std_gnu89:
1450 set_lang (pfile, CLK_GNUC89);
1451 break;
1452 case OPT_std_gnu9x:
1453 case OPT_std_gnu99:
1454 set_lang (pfile, CLK_GNUC99);
1455 break;
1456 case OPT_std_iso9899_199409:
1457 set_lang (pfile, CLK_STDC94);
1458 break;
1459 case OPT_std_iso9899_1990:
1460 case OPT_std_c89:
1461 case OPT_lang_c89:
1462 set_lang (pfile, CLK_STDC89);
1463 break;
1464 case OPT_std_iso9899_199x:
1465 case OPT_std_iso9899_1999:
1466 case OPT_std_c9x:
1467 case OPT_std_c99:
1468 set_lang (pfile, CLK_STDC99);
1469 break;
1470 case OPT_nostdinc:
1471 /* -nostdinc causes no default include directories.
1472 You must specify all include-file directories with -I. */
1473 CPP_OPTION (pfile, no_standard_includes) = 1;
1474 break;
1475 case OPT_nostdincplusplus:
1476 /* -nostdinc++ causes no default C++-specific include directories. */
1477 CPP_OPTION (pfile, no_standard_cplusplus_includes) = 1;
1478 break;
1479 case OPT_o:
1480 if (CPP_OPTION (pfile, out_fname) == NULL)
1481 CPP_OPTION (pfile, out_fname) = arg;
1482 else
1483 {
1484 cpp_error (pfile, DL_FATAL, "output filename specified twice");
1485 return argc;
1486 }
1487 break;
1488 case OPT_d:
1489 /* Args to -d specify what parts of macros to dump.
1490 Silently ignore unrecognised options; they may
1491 be aimed at the compiler proper. */
1492 {
1493 char c;
1494
1495 while ((c = *arg++) != '\0')
1496 switch (c)
1497 {
1498 case 'M':
1499 CPP_OPTION (pfile, dump_macros) = dump_only;
1500 break;
1501 case 'N':
1502 CPP_OPTION (pfile, dump_macros) = dump_names;
1503 break;
1504 case 'D':
1505 CPP_OPTION (pfile, dump_macros) = dump_definitions;
1506 break;
1507 case 'I':
1508 CPP_OPTION (pfile, dump_includes) = 1;
1509 break;
1510 }
1511 }
1512 break;
1513
1514 case OPT_MG:
1515 CPP_OPTION (pfile, print_deps_missing_files) = 1;
1516 break;
1517 case OPT_M:
1518 /* When doing dependencies with -M or -MM, suppress normal
1519 preprocessed output, but still do -dM etc. as software
1520 depends on this. Preprocessed output occurs if -MD, -MMD
1521 or environment var dependency generation is used. */
1522 CPP_OPTION (pfile, print_deps) = 2;
1523 CPP_OPTION (pfile, no_output) = 1;
1524 break;
1525 case OPT_MM:
1526 CPP_OPTION (pfile, print_deps) = 1;
1527 CPP_OPTION (pfile, no_output) = 1;
1528 break;
1529 case OPT_MF:
1530 CPP_OPTION (pfile, deps_file) = arg;
1531 break;
1532 case OPT_MP:
1533 CPP_OPTION (pfile, deps_phony_targets) = 1;
1534 break;
1535 case OPT_MQ:
1536 case OPT_MT:
1537 /* Add a target. -MQ quotes for Make. */
1538 deps_add_target (pfile->deps, arg, opt_code == OPT_MQ);
1539 break;
1540
1541 case OPT_MD:
1542 CPP_OPTION (pfile, print_deps) = 2;
1543 CPP_OPTION (pfile, deps_file) = arg;
1544 break;
1545 case OPT_MMD:
1546 CPP_OPTION (pfile, print_deps) = 1;
1547 CPP_OPTION (pfile, deps_file) = arg;
1548 break;
1549
1550 case OPT_A:
1551 if (arg[0] == '-')
1552 {
1553 /* -A with an argument beginning with '-' acts as
1554 #unassert on whatever immediately follows the '-'.
1555 If "-" is the whole argument, we eliminate all
1556 predefined macros and assertions, including those
1557 that were specified earlier on the command line.
1558 That way we can get rid of any that were passed
1559 automatically in from GCC. */
1560
1561 if (arg[1] == '\0')
1562 {
1563 free_chain (pend->directive_head);
1564 pend->directive_head = NULL;
1565 pend->directive_tail = NULL;
1566 }
1567 else
1568 new_pending_directive (pend, arg + 1, cpp_unassert);
1569 }
1570 else
1571 new_pending_directive (pend, arg, cpp_assert);
1572 break;
1573 case OPT_U:
1574 new_pending_directive (pend, arg, cpp_undef);
1575 break;
1576 case OPT_I: /* Add directory to path for includes. */
1577 if (!strcmp (arg, "-"))
1578 {
1579 /* -I- means:
1580 Use the preceding -I directories for #include "..."
1581 but not #include <...>.
1582 Don't search the directory of the present file
1583 for #include "...". (Note that -I. -I- is not the same as
1584 the default setup; -I. uses the compiler's working dir.) */
1585 if (! CPP_OPTION (pfile, ignore_srcdir))
1586 {
1587 pend->quote_head = pend->brack_head;
1588 pend->quote_tail = pend->brack_tail;
1589 pend->brack_head = 0;
1590 pend->brack_tail = 0;
1591 CPP_OPTION (pfile, ignore_srcdir) = 1;
1592 }
1593 else
1594 {
1595 cpp_error (pfile, DL_FATAL, "-I- specified twice");
1596 return argc;
1597 }
1598 }
1599 else
1600 append_include_chain (pfile, xstrdup (arg), BRACKET, 0);
1601 break;
1602 case OPT_isystem:
1603 /* Add directory to beginning of system include path, as a system
1604 include directory. */
1605 append_include_chain (pfile, xstrdup (arg), SYSTEM, 0);
1606 break;
1607 case OPT_include:
1608 case OPT_imacros:
1609 {
1610 struct pending_option *o = (struct pending_option *)
1611 xmalloc (sizeof (struct pending_option));
1612 o->arg = arg;
1613 o->next = NULL;
1614
1615 if (opt_code == OPT_include)
1616 APPEND (pend, include, o);
1617 else
1618 APPEND (pend, imacros, o);
1619 }
1620 break;
1621 case OPT_iwithprefix:
1622 /* Add directory to end of path for includes,
1623 with the default prefix at the front of its name. */
1624 /* fall through */
1625 case OPT_iwithprefixbefore:
1626 /* Add directory to main path for includes,
1627 with the default prefix at the front of its name. */
1628 {
1629 char *fname;
1630 int len;
1631
1632 len = strlen (arg);
1633
1634 if (CPP_OPTION (pfile, include_prefix) != 0)
1635 {
1636 size_t ipl = CPP_OPTION (pfile, include_prefix_len);
1637 fname = xmalloc (ipl + len + 1);
1638 memcpy (fname, CPP_OPTION (pfile, include_prefix), ipl);
1639 memcpy (fname + ipl, arg, len + 1);
1640 }
1641 else if (cpp_GCC_INCLUDE_DIR_len)
1642 {
1643 fname = xmalloc (cpp_GCC_INCLUDE_DIR_len + len + 1);
1644 memcpy (fname, cpp_GCC_INCLUDE_DIR, cpp_GCC_INCLUDE_DIR_len);
1645 memcpy (fname + cpp_GCC_INCLUDE_DIR_len, arg, len + 1);
1646 }
1647 else
1648 fname = xstrdup (arg);
1649
1650 append_include_chain (pfile, fname,
1651 opt_code == OPT_iwithprefix ? SYSTEM: BRACKET, 0);
1652 }
1653 break;
1654 case OPT_idirafter:
1655 /* Add directory to end of path for includes. */
1656 append_include_chain (pfile, xstrdup (arg), AFTER, 0);
1657 break;
1658 case OPT_W:
1659 /* Silently ignore unrecognised options. */
1660 if (!strcmp (argv[i], "-Wall"))
1661 {
1662 CPP_OPTION (pfile, warn_trigraphs) = 1;
1663 CPP_OPTION (pfile, warn_comments) = 1;
1664 }
1665 else if (!strcmp (argv[i], "-Wtraditional"))
1666 CPP_OPTION (pfile, warn_traditional) = 1;
1667 else if (!strcmp (argv[i], "-Wtrigraphs"))
1668 CPP_OPTION (pfile, warn_trigraphs) = 1;
1669 else if (!strcmp (argv[i], "-Wcomment"))
1670 CPP_OPTION (pfile, warn_comments) = 1;
1671 else if (!strcmp (argv[i], "-Wcomments"))
1672 CPP_OPTION (pfile, warn_comments) = 1;
1673 else if (!strcmp (argv[i], "-Wundef"))
1674 CPP_OPTION (pfile, warn_undef) = 1;
1675 else if (!strcmp (argv[i], "-Wimport"))
1676 CPP_OPTION (pfile, warn_import) = 1;
1677 else if (!strcmp (argv[i], "-Werror"))
1678 CPP_OPTION (pfile, warnings_are_errors) = 1;
1679 else if (!strcmp (argv[i], "-Wsystem-headers"))
1680 CPP_OPTION (pfile, warn_system_headers) = 1;
1681 else if (!strcmp (argv[i], "-Wendif-labels"))
1682 CPP_OPTION (pfile, warn_endif_labels) = 1;
1683 else if (!strcmp (argv[i], "-Wno-traditional"))
1684 CPP_OPTION (pfile, warn_traditional) = 0;
1685 else if (!strcmp (argv[i], "-Wno-trigraphs"))
1686 CPP_OPTION (pfile, warn_trigraphs) = 0;
1687 else if (!strcmp (argv[i], "-Wno-comment"))
1688 CPP_OPTION (pfile, warn_comments) = 0;
1689 else if (!strcmp (argv[i], "-Wno-comments"))
1690 CPP_OPTION (pfile, warn_comments) = 0;
1691 else if (!strcmp (argv[i], "-Wno-undef"))
1692 CPP_OPTION (pfile, warn_undef) = 0;
1693 else if (!strcmp (argv[i], "-Wno-import"))
1694 CPP_OPTION (pfile, warn_import) = 0;
1695 else if (!strcmp (argv[i], "-Wno-error"))
1696 CPP_OPTION (pfile, warnings_are_errors) = 0;
1697 else if (!strcmp (argv[i], "-Wno-system-headers"))
1698 CPP_OPTION (pfile, warn_system_headers) = 0;
1699 else if (!strcmp (argv[i], "-Wno-endif-labels"))
1700 CPP_OPTION (pfile, warn_endif_labels) = 0;
1701 else if (! ignore)
1702 return i;
1703 break;
1704 }
1705 }
1706 return i + 1;
1707 }
1708
1709 /* Handle command-line options in (argc, argv).
1710 Can be called multiple times, to handle multiple sets of options.
1711 Returns if an unrecognized option is seen.
1712 Returns number of strings consumed. */
1713 int
1714 cpp_handle_options (pfile, argc, argv)
1715 cpp_reader *pfile;
1716 int argc;
1717 char **argv;
1718 {
1719 int i;
1720 int strings_processed;
1721
1722 for (i = 0; i < argc; i += strings_processed)
1723 {
1724 strings_processed = cpp_handle_option (pfile, argc - i, argv + i, 1);
1725 if (strings_processed == 0)
1726 break;
1727 }
1728
1729 return i;
1730 }
1731
1732 /* Extra processing when all options are parsed, after all calls to
1733 cpp_handle_option[s]. Consistency checks etc. */
1734 void
1735 cpp_post_options (pfile)
1736 cpp_reader *pfile;
1737 {
1738 if (pfile->print_version)
1739 {
1740 fprintf (stderr, _("GNU CPP version %s (cpplib)"), version_string);
1741 #ifdef TARGET_VERSION
1742 TARGET_VERSION;
1743 #endif
1744 fputc ('\n', stderr);
1745 }
1746
1747 /* Canonicalize in_fname and out_fname. We guarantee they are not
1748 NULL, and that the empty string represents stdin / stdout. */
1749 if (CPP_OPTION (pfile, in_fname) == NULL
1750 || !strcmp (CPP_OPTION (pfile, in_fname), "-"))
1751 CPP_OPTION (pfile, in_fname) = "";
1752
1753 if (CPP_OPTION (pfile, out_fname) == NULL
1754 || !strcmp (CPP_OPTION (pfile, out_fname), "-"))
1755 CPP_OPTION (pfile, out_fname) = "";
1756
1757 /* -Wtraditional is not useful in C++ mode. */
1758 if (CPP_OPTION (pfile, cplusplus))
1759 CPP_OPTION (pfile, warn_traditional) = 0;
1760
1761 /* Permanently disable macro expansion if we are rescanning
1762 preprocessed text. Read preprocesed source in ISO mode. */
1763 if (CPP_OPTION (pfile, preprocessed))
1764 {
1765 pfile->state.prevent_expansion = 1;
1766 CPP_OPTION (pfile, traditional) = 0;
1767 }
1768
1769 /* Traditional CPP does not accurately track column information. */
1770 if (CPP_OPTION (pfile, traditional))
1771 CPP_OPTION (pfile, show_column) = 0;
1772
1773 /* -dM makes no normal output. This is set here so that -dM -dD
1774 works as expected. */
1775 if (CPP_OPTION (pfile, dump_macros) == dump_only)
1776 CPP_OPTION (pfile, no_output) = 1;
1777
1778 /* Disable -dD, -dN and -dI if we should make no normal output
1779 (such as with -M). Allow -M -dM since some software relies on
1780 this. */
1781 if (CPP_OPTION (pfile, no_output))
1782 {
1783 if (CPP_OPTION (pfile, dump_macros) != dump_only)
1784 CPP_OPTION (pfile, dump_macros) = dump_none;
1785 CPP_OPTION (pfile, dump_includes) = 0;
1786 }
1787
1788 /* We need to do this after option processing and before
1789 cpp_start_read, as cppmain.c relies on the options->no_output to
1790 set its callbacks correctly before calling cpp_start_read. */
1791 init_dependency_output (pfile);
1792
1793 /* After checking the environment variables, check if -M or -MM has
1794 not been specified, but other -M options have. */
1795 if (CPP_OPTION (pfile, print_deps) == 0 &&
1796 (CPP_OPTION (pfile, print_deps_missing_files)
1797 || CPP_OPTION (pfile, deps_file)
1798 || CPP_OPTION (pfile, deps_phony_targets)))
1799 cpp_error (pfile, DL_FATAL,
1800 "you must additionally specify either -M or -MM");
1801 }
1802
1803 /* Set up dependency-file output. On exit, if print_deps is non-zero
1804 then deps_file is not NULL; stdout is the empty string. */
1805 static void
1806 init_dependency_output (pfile)
1807 cpp_reader *pfile;
1808 {
1809 char *spec, *s, *output_file;
1810
1811 /* Either of two environment variables can specify output of deps.
1812 Its value is either "OUTPUT_FILE" or "OUTPUT_FILE DEPS_TARGET",
1813 where OUTPUT_FILE is the file to write deps info to
1814 and DEPS_TARGET is the target to mention in the deps. */
1815
1816 if (CPP_OPTION (pfile, print_deps) == 0)
1817 {
1818 spec = getenv ("DEPENDENCIES_OUTPUT");
1819 if (spec)
1820 CPP_OPTION (pfile, print_deps) = 1;
1821 else
1822 {
1823 spec = getenv ("SUNPRO_DEPENDENCIES");
1824 if (spec)
1825 CPP_OPTION (pfile, print_deps) = 2;
1826 else
1827 return;
1828 }
1829
1830 /* Find the space before the DEPS_TARGET, if there is one. */
1831 s = strchr (spec, ' ');
1832 if (s)
1833 {
1834 /* Let the caller perform MAKE quoting. */
1835 deps_add_target (pfile->deps, s + 1, 0);
1836 output_file = (char *) xmalloc (s - spec + 1);
1837 memcpy (output_file, spec, s - spec);
1838 output_file[s - spec] = 0;
1839 }
1840 else
1841 output_file = spec;
1842
1843 /* Command line -MF overrides environment variables and default. */
1844 if (CPP_OPTION (pfile, deps_file) == 0)
1845 CPP_OPTION (pfile, deps_file) = output_file;
1846
1847 CPP_OPTION (pfile, print_deps_append) = 1;
1848 }
1849 else if (CPP_OPTION (pfile, deps_file) == 0)
1850 /* If -M or -MM was seen without -MF, default output to wherever
1851 was specified with -o. out_fname is non-NULL here. */
1852 CPP_OPTION (pfile, deps_file) = CPP_OPTION (pfile, out_fname);
1853 }
1854
1855 /* Handle --help output. */
1856 static void
1857 print_help ()
1858 {
1859 /* To keep the lines from getting too long for some compilers, limit
1860 to about 500 characters (6 lines) per chunk. */
1861 fputs (_("\
1862 Switches:\n\
1863 -include <file> Include the contents of <file> before other files\n\
1864 -imacros <file> Accept definition of macros in <file>\n\
1865 -iprefix <path> Specify <path> as a prefix for next two options\n\
1866 -iwithprefix <dir> Add <dir> to the end of the system include path\n\
1867 -iwithprefixbefore <dir> Add <dir> to the end of the main include path\n\
1868 -isystem <dir> Add <dir> to the start of the system include path\n\
1869 "), stdout);
1870 fputs (_("\
1871 -idirafter <dir> Add <dir> to the end of the system include path\n\
1872 -I <dir> Add <dir> to the end of the main include path\n\
1873 -I- Fine-grained include path control; see info docs\n\
1874 -nostdinc Do not search system include directories\n\
1875 (dirs specified with -isystem will still be used)\n\
1876 -nostdinc++ Do not search system include directories for C++\n\
1877 -o <file> Put output into <file>\n\
1878 "), stdout);
1879 fputs (_("\
1880 -pedantic Issue all warnings demanded by strict ISO C\n\
1881 -pedantic-errors Issue -pedantic warnings as errors instead\n\
1882 -trigraphs Support ISO C trigraphs\n\
1883 -lang-c Assume that the input sources are in C\n\
1884 -lang-c89 Assume that the input sources are in C89\n\
1885 "), stdout);
1886 fputs (_("\
1887 -lang-c++ Assume that the input sources are in C++\n\
1888 -lang-objc Assume that the input sources are in ObjectiveC\n\
1889 -lang-asm Assume that the input sources are in assembler\n\
1890 "), stdout);
1891 fputs (_("\
1892 -std=<std name> Specify the conformance standard; one of:\n\
1893 gnu89, gnu99, c89, c99, iso9899:1990,\n\
1894 iso9899:199409, iso9899:1999\n\
1895 -w Inhibit warning messages\n\
1896 -Wtrigraphs Warn if trigraphs are encountered\n\
1897 -Wno-trigraphs Do not warn about trigraphs\n\
1898 -Wcomment{s} Warn if one comment starts inside another\n\
1899 "), stdout);
1900 fputs (_("\
1901 -Wno-comment{s} Do not warn about comments\n\
1902 -Wtraditional Warn about features not present in traditional C\n\
1903 -Wno-traditional Do not warn about traditional C\n\
1904 -Wundef Warn if an undefined macro is used by #if\n\
1905 -Wno-undef Do not warn about testing undefined macros\n\
1906 -Wimport Warn about the use of the #import directive\n\
1907 "), stdout);
1908 fputs (_("\
1909 -Wno-import Do not warn about the use of #import\n\
1910 -Werror Treat all warnings as errors\n\
1911 -Wno-error Do not treat warnings as errors\n\
1912 -Wsystem-headers Do not suppress warnings from system headers\n\
1913 -Wno-system-headers Suppress warnings from system headers\n\
1914 -Wall Enable all preprocessor warnings\n\
1915 "), stdout);
1916 fputs (_("\
1917 -M Generate make dependencies\n\
1918 -MM As -M, but ignore system header files\n\
1919 -MD Generate make dependencies and compile\n\
1920 -MMD As -MD, but ignore system header files\n\
1921 -MF <file> Write dependency output to the given file\n\
1922 -MG Treat missing header file as generated files\n\
1923 "), stdout);
1924 fputs (_("\
1925 -MP Generate phony targets for all headers\n\
1926 -MQ <target> Add a MAKE-quoted target\n\
1927 -MT <target> Add an unquoted target\n\
1928 "), stdout);
1929 fputs (_("\
1930 -D<macro> Define a <macro> with string '1' as its value\n\
1931 -D<macro>=<val> Define a <macro> with <val> as its value\n\
1932 -A<question>=<answer> Assert the <answer> to <question>\n\
1933 -A-<question>=<answer> Disable the <answer> to <question>\n\
1934 -U<macro> Undefine <macro> \n\
1935 -v Display the version number\n\
1936 "), stdout);
1937 fputs (_("\
1938 -H Print the name of header files as they are used\n\
1939 -C Do not discard comments\n\
1940 -dM Display a list of macro definitions active at end\n\
1941 -dD Preserve macro definitions in output\n\
1942 -dN As -dD except that only the names are preserved\n\
1943 -dI Include #include directives in the output\n\
1944 "), stdout);
1945 fputs (_("\
1946 -fpreprocessed Treat the input file as already preprocessed\n\
1947 -ftabstop=<number> Distance between tab stops for column reporting\n\
1948 -P Do not generate #line directives\n\
1949 -$ Do not allow '$' in identifiers\n\
1950 -remap Remap file names when including files\n\
1951 --version Display version information\n\
1952 -h or --help Display this information\n\
1953 "), stdout);
1954 }
This page took 0.125572 seconds and 5 git commands to generate.