2002-05-04 David S. Miller <davem@redhat.com>
[official-gcc.git] / gcc / cppinit.c
blob9e7241a4ea313b2e8923cee019a85fd44328acec
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
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.
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.
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. */
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 #include "except.h" /* for USING_SJLJ_EXCEPTIONS */
33 /* Predefined symbols, built-in macros, and the default include path. */
35 #ifndef GET_ENV_PATH_LIST
36 #define GET_ENV_PATH_LIST(VAR,NAME) do { (VAR) = getenv (NAME); } while (0)
37 #endif
39 /* Windows does not natively support inodes, and neither does MSDOS.
40 Cygwin's emulation can generate non-unique inodes, so don't use it.
41 VMS has non-numeric inodes. */
42 #ifdef VMS
43 # define INO_T_EQ(A, B) (!memcmp (&(A), &(B), sizeof (A)))
44 # define INO_T_COPY(DEST, SRC) memcpy(&(DEST), &(SRC), sizeof (SRC))
45 #else
46 # if (defined _WIN32 && ! defined (_UWIN)) || defined __MSDOS__
47 # define INO_T_EQ(A, B) 0
48 # else
49 # define INO_T_EQ(A, B) ((A) == (B))
50 # endif
51 # define INO_T_COPY(DEST, SRC) (DEST) = (SRC)
52 #endif
54 /* Internal structures and prototypes. */
56 /* A `struct pending_option' remembers one -D, -A, -U, -include, or
57 -imacros switch. */
58 typedef void (* cl_directive_handler) PARAMS ((cpp_reader *, const char *));
59 struct pending_option
61 struct pending_option *next;
62 const char *arg;
63 cl_directive_handler handler;
66 /* The `pending' structure accumulates all the options that are not
67 actually processed until we hit cpp_read_main_file. It consists of
68 several lists, one for each type of option. We keep both head and
69 tail pointers for quick insertion. */
70 struct cpp_pending
72 struct pending_option *directive_head, *directive_tail;
74 struct search_path *quote_head, *quote_tail;
75 struct search_path *brack_head, *brack_tail;
76 struct search_path *systm_head, *systm_tail;
77 struct search_path *after_head, *after_tail;
79 struct pending_option *imacros_head, *imacros_tail;
80 struct pending_option *include_head, *include_tail;
83 #ifdef __STDC__
84 #define APPEND(pend, list, elt) \
85 do { if (!(pend)->list##_head) (pend)->list##_head = (elt); \
86 else (pend)->list##_tail->next = (elt); \
87 (pend)->list##_tail = (elt); \
88 } while (0)
89 #else
90 #define APPEND(pend, list, elt) \
91 do { if (!(pend)->list/**/_head) (pend)->list/**/_head = (elt); \
92 else (pend)->list/**/_tail->next = (elt); \
93 (pend)->list/**/_tail = (elt); \
94 } while (0)
95 #endif
97 static void print_help PARAMS ((void));
98 static void path_include PARAMS ((cpp_reader *,
99 char *, int));
100 static void init_library PARAMS ((void));
101 static void init_builtins PARAMS ((cpp_reader *));
102 static void append_include_chain PARAMS ((cpp_reader *,
103 char *, int, int));
104 static struct search_path * remove_dup_dir PARAMS ((cpp_reader *,
105 struct search_path *));
106 static struct search_path * remove_dup_dirs PARAMS ((cpp_reader *,
107 struct search_path *));
108 static void merge_include_chains PARAMS ((cpp_reader *));
109 static bool push_include PARAMS ((cpp_reader *,
110 struct pending_option *));
111 static void free_chain PARAMS ((struct pending_option *));
112 static void set_lang PARAMS ((cpp_reader *, enum c_lang));
113 static void init_dependency_output PARAMS ((cpp_reader *));
114 static void init_standard_includes PARAMS ((cpp_reader *));
115 static void read_original_filename PARAMS ((cpp_reader *));
116 static void new_pending_directive PARAMS ((struct cpp_pending *,
117 const char *,
118 cl_directive_handler));
119 static void output_deps PARAMS ((cpp_reader *));
120 static int parse_option PARAMS ((const char *));
122 /* Fourth argument to append_include_chain: chain to use.
123 Note it's never asked to append to the quote chain. */
124 enum { BRACKET = 0, SYSTEM, AFTER };
126 /* If we have designated initializers (GCC >2.7) these tables can be
127 initialized, constant data. Otherwise, they have to be filled in at
128 runtime. */
129 #if HAVE_DESIGNATED_INITIALIZERS
131 #define init_trigraph_map() /* Nothing. */
132 #define TRIGRAPH_MAP \
133 __extension__ const uchar _cpp_trigraph_map[UCHAR_MAX + 1] = {
135 #define END };
136 #define s(p, v) [p] = v,
138 #else
140 #define TRIGRAPH_MAP uchar _cpp_trigraph_map[UCHAR_MAX + 1] = { 0 }; \
141 static void init_trigraph_map PARAMS ((void)) { \
142 unsigned char *x = _cpp_trigraph_map;
144 #define END }
145 #define s(p, v) x[p] = v;
147 #endif
149 TRIGRAPH_MAP
150 s('=', '#') s(')', ']') s('!', '|')
151 s('(', '[') s('\'', '^') s('>', '}')
152 s('/', '\\') s('<', '{') s('-', '~')
155 #undef s
156 #undef END
157 #undef TRIGRAPH_MAP
159 /* Given a colon-separated list of file names PATH,
160 add all the names to the search path for include files. */
161 static void
162 path_include (pfile, list, path)
163 cpp_reader *pfile;
164 char *list;
165 int path;
167 char *p, *q, *name;
169 p = list;
173 /* Find the end of this name. */
174 q = p;
175 while (*q != 0 && *q != PATH_SEPARATOR) q++;
176 if (q == p)
178 /* An empty name in the path stands for the current directory. */
179 name = (char *) xmalloc (2);
180 name[0] = '.';
181 name[1] = 0;
183 else
185 /* Otherwise use the directory that is named. */
186 name = (char *) xmalloc (q - p + 1);
187 memcpy (name, p, q - p);
188 name[q - p] = 0;
191 append_include_chain (pfile, name, path, 0);
193 /* Advance past this name. */
194 if (*q == 0)
195 break;
196 p = q + 1;
198 while (1);
201 /* Append DIR to include path PATH. DIR must be allocated on the
202 heap; this routine takes responsibility for freeing it. CXX_AWARE
203 is non-zero if the header contains extern "C" guards for C++,
204 otherwise it is zero. */
205 static void
206 append_include_chain (pfile, dir, path, cxx_aware)
207 cpp_reader *pfile;
208 char *dir;
209 int path;
210 int cxx_aware ATTRIBUTE_UNUSED;
212 struct cpp_pending *pend = CPP_OPTION (pfile, pending);
213 struct search_path *new;
214 struct stat st;
215 unsigned int len;
217 if (*dir == '\0')
219 free (dir);
220 dir = xstrdup (".");
222 _cpp_simplify_pathname (dir);
224 if (stat (dir, &st))
226 /* Dirs that don't exist are silently ignored. */
227 if (errno != ENOENT)
228 cpp_errno (pfile, DL_ERROR, dir);
229 else if (CPP_OPTION (pfile, verbose))
230 fprintf (stderr, _("ignoring nonexistent directory \"%s\"\n"), dir);
231 free (dir);
232 return;
235 if (!S_ISDIR (st.st_mode))
237 cpp_error_with_line (pfile, DL_ERROR, 0, 0, "%s: Not a directory", dir);
238 free (dir);
239 return;
242 len = strlen (dir);
243 if (len > pfile->max_include_len)
244 pfile->max_include_len = len;
246 new = (struct search_path *) xmalloc (sizeof (struct search_path));
247 new->name = dir;
248 new->len = len;
249 INO_T_COPY (new->ino, st.st_ino);
250 new->dev = st.st_dev;
251 /* Both systm and after include file lists should be treated as system
252 include files since these two lists are really just a concatenation
253 of one "system" list. */
254 if (path == SYSTEM || path == AFTER)
255 #ifdef NO_IMPLICIT_EXTERN_C
256 new->sysp = 1;
257 #else
258 new->sysp = cxx_aware ? 1 : 2;
259 #endif
260 else
261 new->sysp = 0;
262 new->name_map = NULL;
263 new->next = NULL;
265 switch (path)
267 case BRACKET: APPEND (pend, brack, new); break;
268 case SYSTEM: APPEND (pend, systm, new); break;
269 case AFTER: APPEND (pend, after, new); break;
273 /* Handle a duplicated include path. PREV is the link in the chain
274 before the duplicate. The duplicate is removed from the chain and
275 freed. Returns PREV. */
276 static struct search_path *
277 remove_dup_dir (pfile, prev)
278 cpp_reader *pfile;
279 struct search_path *prev;
281 struct search_path *cur = prev->next;
283 if (CPP_OPTION (pfile, verbose))
284 fprintf (stderr, _("ignoring duplicate directory \"%s\"\n"), cur->name);
286 prev->next = cur->next;
287 free ((PTR) cur->name);
288 free (cur);
290 return prev;
293 /* Remove duplicate directories from a chain. Returns the tail of the
294 chain, or NULL if the chain is empty. This algorithm is quadratic
295 in the number of -I switches, which is acceptable since there
296 aren't usually that many of them. */
297 static struct search_path *
298 remove_dup_dirs (pfile, head)
299 cpp_reader *pfile;
300 struct search_path *head;
302 struct search_path *prev = NULL, *cur, *other;
304 for (cur = head; cur; cur = cur->next)
306 for (other = head; other != cur; other = other->next)
307 if (INO_T_EQ (cur->ino, other->ino) && cur->dev == other->dev)
309 if (cur->sysp && !other->sysp)
311 cpp_error (pfile, DL_WARNING,
312 "changing search order for system directory \"%s\"",
313 cur->name);
314 if (strcmp (cur->name, other->name))
315 cpp_error (pfile, DL_WARNING,
316 " as it is the same as non-system directory \"%s\"",
317 other->name);
318 else
319 cpp_error (pfile, DL_WARNING,
320 " as it has already been specified as a non-system directory");
322 cur = remove_dup_dir (pfile, prev);
323 break;
325 prev = cur;
328 return prev;
331 /* Merge the four include chains together in the order quote, bracket,
332 system, after. Remove duplicate dirs (as determined by
333 INO_T_EQ()). The system_include and after_include chains are never
334 referred to again after this function; all access is through the
335 bracket_include path. */
336 static void
337 merge_include_chains (pfile)
338 cpp_reader *pfile;
340 struct search_path *quote, *brack, *systm, *qtail;
342 struct cpp_pending *pend = CPP_OPTION (pfile, pending);
344 quote = pend->quote_head;
345 brack = pend->brack_head;
346 systm = pend->systm_head;
347 qtail = pend->quote_tail;
349 /* Paste together bracket, system, and after include chains. */
350 if (systm)
351 pend->systm_tail->next = pend->after_head;
352 else
353 systm = pend->after_head;
355 if (brack)
356 pend->brack_tail->next = systm;
357 else
358 brack = systm;
360 /* This is a bit tricky. First we drop dupes from the quote-include
361 list. Then we drop dupes from the bracket-include list.
362 Finally, if qtail and brack are the same directory, we cut out
363 brack and move brack up to point to qtail.
365 We can't just merge the lists and then uniquify them because
366 then we may lose directories from the <> search path that should
367 be there; consider -Ifoo -Ibar -I- -Ifoo -Iquux. It is however
368 safe to treat -Ibar -Ifoo -I- -Ifoo -Iquux as if written
369 -Ibar -I- -Ifoo -Iquux. */
371 remove_dup_dirs (pfile, brack);
372 qtail = remove_dup_dirs (pfile, quote);
374 if (quote)
376 qtail->next = brack;
378 /* If brack == qtail, remove brack as it's simpler. */
379 if (brack && INO_T_EQ (qtail->ino, brack->ino)
380 && qtail->dev == brack->dev)
381 brack = remove_dup_dir (pfile, qtail);
383 else
384 quote = brack;
386 CPP_OPTION (pfile, quote_include) = quote;
387 CPP_OPTION (pfile, bracket_include) = brack;
390 /* A set of booleans indicating what CPP features each source language
391 requires. */
392 struct lang_flags
394 char c99;
395 char objc;
396 char cplusplus;
397 char extended_numbers;
398 char trigraphs;
399 char dollars_in_ident;
400 char cplusplus_comments;
401 char digraphs;
404 /* ??? Enable $ in identifiers in assembly? */
405 static const struct lang_flags lang_defaults[] =
406 { /* c99 objc c++ xnum trig dollar c++comm digr */
407 /* GNUC89 */ { 0, 0, 0, 1, 0, 1, 1, 1 },
408 /* GNUC99 */ { 1, 0, 0, 1, 0, 1, 1, 1 },
409 /* STDC89 */ { 0, 0, 0, 0, 1, 0, 0, 0 },
410 /* STDC94 */ { 0, 0, 0, 0, 1, 0, 0, 1 },
411 /* STDC99 */ { 1, 0, 0, 1, 1, 0, 1, 1 },
412 /* GNUCXX */ { 0, 0, 1, 1, 0, 1, 1, 1 },
413 /* CXX98 */ { 0, 0, 1, 1, 1, 0, 1, 1 },
414 /* OBJC */ { 0, 1, 0, 1, 0, 1, 1, 1 },
415 /* OBJCXX */ { 0, 1, 1, 1, 0, 1, 1, 1 },
416 /* ASM */ { 0, 0, 0, 1, 0, 0, 1, 0 }
419 /* Sets internal flags correctly for a given language. */
420 static void
421 set_lang (pfile, lang)
422 cpp_reader *pfile;
423 enum c_lang lang;
425 const struct lang_flags *l = &lang_defaults[(int) lang];
427 CPP_OPTION (pfile, lang) = lang;
429 CPP_OPTION (pfile, c99) = l->c99;
430 CPP_OPTION (pfile, objc) = l->objc;
431 CPP_OPTION (pfile, cplusplus) = l->cplusplus;
432 CPP_OPTION (pfile, extended_numbers) = l->extended_numbers;
433 CPP_OPTION (pfile, trigraphs) = l->trigraphs;
434 CPP_OPTION (pfile, dollars_in_ident) = l->dollars_in_ident;
435 CPP_OPTION (pfile, cplusplus_comments) = l->cplusplus_comments;
436 CPP_OPTION (pfile, digraphs) = l->digraphs;
439 #ifdef HOST_EBCDIC
440 static int opt_comp PARAMS ((const void *, const void *));
442 /* Run-time sorting of options array. */
443 static int
444 opt_comp (p1, p2)
445 const void *p1, *p2;
447 return strcmp (((struct cl_option *) p1)->opt_text,
448 ((struct cl_option *) p2)->opt_text);
450 #endif
452 /* init initializes library global state. It might not need to
453 do anything depending on the platform and compiler. */
454 static void
455 init_library ()
457 static int initialized = 0;
459 if (! initialized)
461 initialized = 1;
463 #ifdef HOST_EBCDIC
464 /* For non-ASCII hosts, the cl_options array needs to be sorted at
465 runtime. */
466 qsort (cl_options, N_OPTS, sizeof (struct cl_option), opt_comp);
467 #endif
469 /* Set up the trigraph map. This doesn't need to do anything if
470 we were compiled with a compiler that supports C99 designated
471 initializers. */
472 init_trigraph_map ();
476 /* Initialize a cpp_reader structure. */
477 cpp_reader *
478 cpp_create_reader (lang)
479 enum c_lang lang;
481 cpp_reader *pfile;
483 /* Initialise this instance of the library if it hasn't been already. */
484 init_library ();
486 pfile = (cpp_reader *) xcalloc (1, sizeof (cpp_reader));
488 set_lang (pfile, lang);
489 CPP_OPTION (pfile, warn_import) = 1;
490 CPP_OPTION (pfile, discard_comments) = 1;
491 CPP_OPTION (pfile, discard_comments_in_macro_exp) = 1;
492 CPP_OPTION (pfile, show_column) = 1;
493 CPP_OPTION (pfile, tabstop) = 8;
494 CPP_OPTION (pfile, operator_names) = 1;
495 CPP_OPTION (pfile, warn_endif_labels) = 1;
496 #if DEFAULT_SIGNED_CHAR
497 CPP_OPTION (pfile, signed_char) = 1;
498 #else
499 CPP_OPTION (pfile, signed_char) = 0;
500 #endif
502 CPP_OPTION (pfile, pending) =
503 (struct cpp_pending *) xcalloc (1, sizeof (struct cpp_pending));
505 /* CPP arithmetic done to existing rules for now. */
506 #define BITS_PER_HOST_WIDEST_INT (CHAR_BIT * sizeof (HOST_WIDEST_INT))
507 CPP_OPTION (pfile, precision) = BITS_PER_HOST_WIDEST_INT;
508 #ifndef MAX_CHAR_TYPE_SIZE
509 #define MAX_CHAR_TYPE_SIZE CHAR_TYPE_SIZE
510 #endif
511 CPP_OPTION (pfile, char_precision) = MAX_CHAR_TYPE_SIZE;
512 CPP_OPTION (pfile, wchar_precision) = MAX_WCHAR_TYPE_SIZE;
514 /* It's simplest to just create this struct whether or not it will
515 be needed. */
516 pfile->deps = deps_init ();
518 /* Initialise the line map. Start at logical line 1, so we can use
519 a line number of zero for special states. */
520 init_line_maps (&pfile->line_maps);
521 pfile->line = 1;
523 /* Initialize lexer state. */
524 pfile->state.save_comments = ! CPP_OPTION (pfile, discard_comments);
526 /* Set up static tokens. */
527 pfile->date.type = CPP_EOF;
528 pfile->avoid_paste.type = CPP_PADDING;
529 pfile->avoid_paste.val.source = NULL;
530 pfile->eof.type = CPP_EOF;
531 pfile->eof.flags = 0;
533 /* Create a token buffer for the lexer. */
534 _cpp_init_tokenrun (&pfile->base_run, 250);
535 pfile->cur_run = &pfile->base_run;
536 pfile->cur_token = pfile->base_run.base;
538 /* Initialise the base context. */
539 pfile->context = &pfile->base_context;
540 pfile->base_context.macro = 0;
541 pfile->base_context.prev = pfile->base_context.next = 0;
543 /* Aligned and unaligned storage. */
544 pfile->a_buff = _cpp_get_buff (pfile, 0);
545 pfile->u_buff = _cpp_get_buff (pfile, 0);
547 /* The expression parser stack. */
548 _cpp_expand_op_stack (pfile);
550 /* Initialise the buffer obstack. */
551 gcc_obstack_init (&pfile->buffer_ob);
553 _cpp_init_includes (pfile);
555 return pfile;
558 /* Free resources used by PFILE. Accessing PFILE after this function
559 returns leads to undefined behaviour. Returns the error count. */
561 cpp_destroy (pfile)
562 cpp_reader *pfile;
564 int result;
565 struct search_path *dir, *dirn;
566 cpp_context *context, *contextn;
567 tokenrun *run, *runn;
569 free_chain (CPP_OPTION (pfile, pending)->include_head);
570 free (CPP_OPTION (pfile, pending));
571 free (pfile->op_stack);
573 while (CPP_BUFFER (pfile) != NULL)
574 _cpp_pop_buffer (pfile);
576 if (pfile->macro_buffer)
578 free ((PTR) pfile->macro_buffer);
579 pfile->macro_buffer = NULL;
580 pfile->macro_buffer_len = 0;
583 deps_free (pfile->deps);
584 obstack_free (&pfile->buffer_ob, 0);
586 _cpp_destroy_hashtable (pfile);
587 _cpp_cleanup_includes (pfile);
589 _cpp_free_buff (pfile->a_buff);
590 _cpp_free_buff (pfile->u_buff);
591 _cpp_free_buff (pfile->free_buffs);
593 for (run = &pfile->base_run; run; run = runn)
595 runn = run->next;
596 free (run->base);
597 if (run != &pfile->base_run)
598 free (run);
601 for (dir = CPP_OPTION (pfile, quote_include); dir; dir = dirn)
603 dirn = dir->next;
604 free ((PTR) dir->name);
605 free (dir);
608 for (context = pfile->base_context.next; context; context = contextn)
610 contextn = context->next;
611 free (context);
614 free_line_maps (&pfile->line_maps);
616 result = pfile->errors;
617 free (pfile);
619 return result;
623 /* This structure defines one built-in identifier. A node will be
624 entered in the hash table under the name NAME, with value VALUE (if
625 any). If flags has OPERATOR, the node's operator field is used; if
626 flags has BUILTIN the node's builtin field is used. Macros that are
627 known at build time should not be flagged BUILTIN, as then they do
628 not appear in macro dumps with e.g. -dM or -dD.
630 Two values are not compile time constants, so we tag
631 them in the FLAGS field instead:
632 VERS value is the global version_string, quoted
633 ULP value is the global user_label_prefix
635 Also, macros with CPLUS set in the flags field are entered only for C++. */
636 struct builtin
638 const uchar *name;
639 const char *value;
640 unsigned char builtin;
641 unsigned char operator;
642 unsigned short flags;
643 unsigned short len;
645 #define VERS 0x01
646 #define ULP 0x02
647 #define CPLUS 0x04
648 #define BUILTIN 0x08
649 #define OPERATOR 0x10
651 #define B(n, t) { U n, 0, t, 0, BUILTIN, sizeof n - 1 }
652 #define C(n, v) { U n, v, 0, 0, 0, sizeof n - 1 }
653 #define X(n, f) { U n, 0, 0, 0, f, sizeof n - 1 }
654 #define O(n, c, f) { U n, 0, 0, c, OPERATOR | f, sizeof n - 1 }
655 static const struct builtin builtin_array[] =
657 B("__TIME__", BT_TIME),
658 B("__DATE__", BT_DATE),
659 B("__FILE__", BT_FILE),
660 B("__BASE_FILE__", BT_BASE_FILE),
661 B("__LINE__", BT_SPECLINE),
662 B("__INCLUDE_LEVEL__", BT_INCLUDE_LEVEL),
663 B("_Pragma", BT_PRAGMA),
665 X("__VERSION__", VERS),
666 X("__USER_LABEL_PREFIX__", ULP),
667 C("__REGISTER_PREFIX__", REGISTER_PREFIX),
668 C("__HAVE_BUILTIN_SETJMP__", "1"),
669 #if USING_SJLJ_EXCEPTIONS
670 /* libgcc needs to know this. */
671 C("__USING_SJLJ_EXCEPTIONS__","1"),
672 #endif
673 #ifndef NO_BUILTIN_SIZE_TYPE
674 C("__SIZE_TYPE__", SIZE_TYPE),
675 #endif
676 #ifndef NO_BUILTIN_PTRDIFF_TYPE
677 C("__PTRDIFF_TYPE__", PTRDIFF_TYPE),
678 #endif
679 #ifndef NO_BUILTIN_WCHAR_TYPE
680 C("__WCHAR_TYPE__", WCHAR_TYPE),
681 #endif
682 #ifndef NO_BUILTIN_WINT_TYPE
683 C("__WINT_TYPE__", WINT_TYPE),
684 #endif
685 #ifdef STDC_0_IN_SYSTEM_HEADERS
686 B("__STDC__", BT_STDC),
687 #else
688 C("__STDC__", "1"),
689 #endif
691 /* Named operators known to the preprocessor. These cannot be #defined
692 and always have their stated meaning. They are treated like normal
693 identifiers except for the type code and the meaning. Most of them
694 are only for C++ (but see iso646.h). */
695 O("and", CPP_AND_AND, CPLUS),
696 O("and_eq", CPP_AND_EQ, CPLUS),
697 O("bitand", CPP_AND, CPLUS),
698 O("bitor", CPP_OR, CPLUS),
699 O("compl", CPP_COMPL, CPLUS),
700 O("not", CPP_NOT, CPLUS),
701 O("not_eq", CPP_NOT_EQ, CPLUS),
702 O("or", CPP_OR_OR, CPLUS),
703 O("or_eq", CPP_OR_EQ, CPLUS),
704 O("xor", CPP_XOR, CPLUS),
705 O("xor_eq", CPP_XOR_EQ, CPLUS)
707 #undef B
708 #undef C
709 #undef X
710 #undef O
711 #define builtin_array_end (builtin_array + ARRAY_SIZE (builtin_array))
713 /* Subroutine of cpp_read_main_file; reads the builtins table above and
714 enters them, and language-specific macros, into the hash table. */
715 static void
716 init_builtins (pfile)
717 cpp_reader *pfile;
719 const struct builtin *b;
721 for(b = builtin_array; b < builtin_array_end; b++)
723 if ((b->flags & CPLUS) && ! CPP_OPTION (pfile, cplusplus))
724 continue;
726 if ((b->flags & OPERATOR) && ! CPP_OPTION (pfile, operator_names))
727 continue;
729 if (b->flags & (OPERATOR | BUILTIN))
731 cpp_hashnode *hp = cpp_lookup (pfile, b->name, b->len);
732 if (b->flags & OPERATOR)
734 hp->flags |= NODE_OPERATOR;
735 hp->value.operator = b->operator;
737 else
739 hp->type = NT_MACRO;
740 hp->flags |= NODE_BUILTIN | NODE_WARN;
741 hp->value.builtin = b->builtin;
744 else /* A standard macro of some kind. */
746 const char *val;
747 char *str;
749 if (b->flags & VERS)
751 /* Allocate enough space for 'name "value"\n\0'. */
752 str = alloca (b->len + strlen (version_string) + 5);
753 sprintf (str, "%s \"%s\"\n", b->name, version_string);
755 else
757 if (b->flags & ULP)
758 val = CPP_OPTION (pfile, user_label_prefix);
759 else
760 val = b->value;
762 /* Allocate enough space for "name value\n\0". */
763 str = alloca (b->len + strlen (val) + 3);
764 sprintf(str, "%s %s\n", b->name, val);
767 _cpp_define_builtin (pfile, str);
771 if (CPP_OPTION (pfile, cplusplus))
772 _cpp_define_builtin (pfile, "__cplusplus 1");
774 if (CPP_OPTION (pfile, objc))
775 _cpp_define_builtin (pfile, "__OBJC__ 1");
777 if (CPP_OPTION (pfile, lang) == CLK_STDC94)
778 _cpp_define_builtin (pfile, "__STDC_VERSION__ 199409L");
779 else if (CPP_OPTION (pfile, c99))
780 _cpp_define_builtin (pfile, "__STDC_VERSION__ 199901L");
782 if (CPP_OPTION (pfile, signed_char) == 0)
783 _cpp_define_builtin (pfile, "__CHAR_UNSIGNED__ 1");
785 if (CPP_OPTION (pfile, lang) == CLK_STDC89
786 || CPP_OPTION (pfile, lang) == CLK_STDC94
787 || CPP_OPTION (pfile, lang) == CLK_STDC99)
788 _cpp_define_builtin (pfile, "__STRICT_ANSI__ 1");
789 else if (CPP_OPTION (pfile, lang) == CLK_ASM)
790 _cpp_define_builtin (pfile, "__ASSEMBLER__ 1");
792 if (pfile->cb.register_builtins)
793 (*pfile->cb.register_builtins) (pfile);
795 #undef BUILTIN
796 #undef OPERATOR
797 #undef VERS
798 #undef ULP
799 #undef CPLUS
800 #undef builtin_array_end
802 /* And another subroutine. This one sets up the standard include path. */
803 static void
804 init_standard_includes (pfile)
805 cpp_reader *pfile;
807 char *path;
808 const struct default_include *p;
809 const char *specd_prefix = CPP_OPTION (pfile, include_prefix);
811 /* Several environment variables may add to the include search path.
812 CPATH specifies an additional list of directories to be searched
813 as if specified with -I, while C_INCLUDE_PATH, CPLUS_INCLUDE_PATH,
814 etc. specify an additional list of directories to be searched as
815 if specified with -isystem, for the language indicated. */
817 GET_ENV_PATH_LIST (path, "CPATH");
818 if (path != 0 && *path != 0)
819 path_include (pfile, path, BRACKET);
821 switch ((CPP_OPTION (pfile, objc) << 1) + CPP_OPTION (pfile, cplusplus))
823 case 0:
824 GET_ENV_PATH_LIST (path, "C_INCLUDE_PATH");
825 break;
826 case 1:
827 GET_ENV_PATH_LIST (path, "CPLUS_INCLUDE_PATH");
828 break;
829 case 2:
830 GET_ENV_PATH_LIST (path, "OBJC_INCLUDE_PATH");
831 break;
832 case 3:
833 GET_ENV_PATH_LIST (path, "OBJCPLUS_INCLUDE_PATH");
834 break;
836 if (path != 0 && *path != 0)
837 path_include (pfile, path, SYSTEM);
839 /* Search "translated" versions of GNU directories.
840 These have /usr/local/lib/gcc... replaced by specd_prefix. */
841 if (specd_prefix != 0 && cpp_GCC_INCLUDE_DIR_len)
843 /* Remove the `include' from /usr/local/lib/gcc.../include.
844 GCC_INCLUDE_DIR will always end in /include. */
845 int default_len = cpp_GCC_INCLUDE_DIR_len;
846 char *default_prefix = (char *) alloca (default_len + 1);
847 int specd_len = strlen (specd_prefix);
849 memcpy (default_prefix, cpp_GCC_INCLUDE_DIR, default_len);
850 default_prefix[default_len] = '\0';
852 for (p = cpp_include_defaults; p->fname; p++)
854 /* Some standard dirs are only for C++. */
855 if (!p->cplusplus
856 || (CPP_OPTION (pfile, cplusplus)
857 && !CPP_OPTION (pfile, no_standard_cplusplus_includes)))
859 /* Does this dir start with the prefix? */
860 if (!memcmp (p->fname, default_prefix, default_len))
862 /* Yes; change prefix and add to search list. */
863 int flen = strlen (p->fname);
864 int this_len = specd_len + flen - default_len;
865 char *str = (char *) xmalloc (this_len + 1);
866 memcpy (str, specd_prefix, specd_len);
867 memcpy (str + specd_len,
868 p->fname + default_len,
869 flen - default_len + 1);
871 append_include_chain (pfile, str, SYSTEM, p->cxx_aware);
877 /* Search ordinary names for GNU include directories. */
878 for (p = cpp_include_defaults; p->fname; p++)
880 /* Some standard dirs are only for C++. */
881 if (!p->cplusplus
882 || (CPP_OPTION (pfile, cplusplus)
883 && !CPP_OPTION (pfile, no_standard_cplusplus_includes)))
885 char *str = update_path (p->fname, p->component);
886 append_include_chain (pfile, str, SYSTEM, p->cxx_aware);
891 /* Pushes a command line -imacro and -include file indicated by P onto
892 the buffer stack. Returns non-zero if successful. */
893 static bool
894 push_include (pfile, p)
895 cpp_reader *pfile;
896 struct pending_option *p;
898 cpp_token header;
900 /* Later: maybe update this to use the #include "" search path
901 if cpp_read_file fails. */
902 header.type = CPP_STRING;
903 header.val.str.text = (const unsigned char *) p->arg;
904 header.val.str.len = strlen (p->arg);
905 /* Make the command line directive take up a line. */
906 pfile->line++;
908 return _cpp_execute_include (pfile, &header, IT_CMDLINE);
911 /* Frees a pending_option chain. */
912 static void
913 free_chain (head)
914 struct pending_option *head;
916 struct pending_option *next;
918 while (head)
920 next = head->next;
921 free (head);
922 head = next;
926 /* This is called after options have been parsed, and partially
927 processed. Setup for processing input from the file named FNAME,
928 or stdin if it is the empty string. Return the original filename
929 on success (e.g. foo.i->foo.c), or NULL on failure. */
930 const char *
931 cpp_read_main_file (pfile, fname, table)
932 cpp_reader *pfile;
933 const char *fname;
934 hash_table *table;
936 /* The front ends don't set up the hash table until they have
937 finished processing the command line options, so initializing the
938 hashtable is deferred until now. */
939 _cpp_init_hashtable (pfile, table);
941 /* Set up the include search path now. */
942 if (! CPP_OPTION (pfile, no_standard_includes))
943 init_standard_includes (pfile);
945 merge_include_chains (pfile);
947 /* With -v, print the list of dirs to search. */
948 if (CPP_OPTION (pfile, verbose))
950 struct search_path *l;
951 fprintf (stderr, _("#include \"...\" search starts here:\n"));
952 for (l = CPP_OPTION (pfile, quote_include); l; l = l->next)
954 if (l == CPP_OPTION (pfile, bracket_include))
955 fprintf (stderr, _("#include <...> search starts here:\n"));
956 fprintf (stderr, " %s\n", l->name);
958 fprintf (stderr, _("End of search list.\n"));
961 if (CPP_OPTION (pfile, print_deps))
962 /* Set the default target (if there is none already). */
963 deps_add_default_target (pfile->deps, fname);
965 /* Open the main input file. */
966 if (!_cpp_read_file (pfile, fname))
967 return NULL;
969 /* Set this after cpp_post_options so the client can change the
970 option if it wishes, and after stacking the main file so we don't
971 trace the main file. */
972 pfile->line_maps.trace_includes = CPP_OPTION (pfile, print_include_names);
974 /* For foo.i, read the original filename foo.c now, for the benefit
975 of the front ends. */
976 if (CPP_OPTION (pfile, preprocessed))
977 read_original_filename (pfile);
979 return pfile->map->to_file;
982 /* For preprocessed files, if the first tokens are of the form # NUM.
983 handle the directive so we know the original file name. This will
984 generate file_change callbacks, which the front ends must handle
985 appropriately given their state of initialization. */
986 static void
987 read_original_filename (pfile)
988 cpp_reader *pfile;
990 const cpp_token *token, *token1;
992 /* Lex ahead; if the first tokens are of the form # NUM, then
993 process the directive, otherwise back up. */
994 token = _cpp_lex_direct (pfile);
995 if (token->type == CPP_HASH)
997 token1 = _cpp_lex_direct (pfile);
998 _cpp_backup_tokens (pfile, 1);
1000 /* If it's a #line directive, handle it. */
1001 if (token1->type == CPP_NUMBER)
1003 _cpp_handle_directive (pfile, token->flags & PREV_WHITE);
1004 return;
1008 /* Backup as if nothing happened. */
1009 _cpp_backup_tokens (pfile, 1);
1012 /* Handle pending command line options: -D, -U, -A, -imacros and
1013 -include. This should be called after debugging has been properly
1014 set up in the front ends. */
1015 void
1016 cpp_finish_options (pfile)
1017 cpp_reader *pfile;
1019 /* Install builtins and process command line macros etc. in the order
1020 they appeared, but only if not already preprocessed. */
1021 if (! CPP_OPTION (pfile, preprocessed))
1023 struct pending_option *p;
1025 _cpp_do_file_change (pfile, LC_RENAME, _("<built-in>"), 1, 0);
1026 init_builtins (pfile);
1027 _cpp_do_file_change (pfile, LC_RENAME, _("<command line>"), 1, 0);
1028 for (p = CPP_OPTION (pfile, pending)->directive_head; p; p = p->next)
1029 (*p->handler) (pfile, p->arg);
1031 /* Scan -imacros files after -D, -U, but before -include.
1032 pfile->next_include_file is NULL, so _cpp_pop_buffer does not
1033 push -include files. */
1034 for (p = CPP_OPTION (pfile, pending)->imacros_head; p; p = p->next)
1035 if (push_include (pfile, p))
1036 cpp_scan_nooutput (pfile);
1038 pfile->next_include_file = &CPP_OPTION (pfile, pending)->include_head;
1039 _cpp_maybe_push_include_file (pfile);
1042 free_chain (CPP_OPTION (pfile, pending)->imacros_head);
1043 free_chain (CPP_OPTION (pfile, pending)->directive_head);
1046 /* Push the next buffer on the stack given by -include, if any. */
1047 void
1048 _cpp_maybe_push_include_file (pfile)
1049 cpp_reader *pfile;
1051 if (pfile->next_include_file)
1053 struct pending_option *head = *pfile->next_include_file;
1055 while (head && !push_include (pfile, head))
1056 head = head->next;
1058 if (head)
1059 pfile->next_include_file = &head->next;
1060 else
1062 /* All done; restore the line map from <command line>. */
1063 _cpp_do_file_change (pfile, LC_RENAME,
1064 pfile->line_maps.maps[0].to_file, 1, 0);
1065 /* Don't come back here again. */
1066 pfile->next_include_file = NULL;
1071 /* Use mkdeps.c to output dependency information. */
1072 static void
1073 output_deps (pfile)
1074 cpp_reader *pfile;
1076 /* Stream on which to print the dependency information. */
1077 FILE *deps_stream = 0;
1078 const char *const deps_mode =
1079 CPP_OPTION (pfile, print_deps_append) ? "a" : "w";
1081 if (CPP_OPTION (pfile, deps_file)[0] == '\0')
1082 deps_stream = stdout;
1083 else
1085 deps_stream = fopen (CPP_OPTION (pfile, deps_file), deps_mode);
1086 if (deps_stream == 0)
1088 cpp_errno (pfile, DL_ERROR, CPP_OPTION (pfile, deps_file));
1089 return;
1093 deps_write (pfile->deps, deps_stream, 72);
1095 if (CPP_OPTION (pfile, deps_phony_targets))
1096 deps_phony_targets (pfile->deps, deps_stream);
1098 /* Don't close stdout. */
1099 if (deps_stream != stdout)
1101 if (ferror (deps_stream) || fclose (deps_stream) != 0)
1102 cpp_error (pfile, DL_FATAL, "I/O error on output");
1106 /* This is called at the end of preprocessing. It pops the
1107 last buffer and writes dependency output. It should also
1108 clear macro definitions, such that you could call cpp_start_read
1109 with a new filename to restart processing. */
1110 void
1111 cpp_finish (pfile)
1112 cpp_reader *pfile;
1114 /* cpplex.c leaves the final buffer on the stack. This it so that
1115 it returns an unending stream of CPP_EOFs to the client. If we
1116 popped the buffer, we'd dereference a NULL buffer pointer and
1117 segfault. It's nice to allow the client to do worry-free excess
1118 cpp_get_token calls. */
1119 while (pfile->buffer)
1120 _cpp_pop_buffer (pfile);
1122 /* Don't write the deps file if preprocessing has failed. */
1123 if (CPP_OPTION (pfile, print_deps) && pfile->errors == 0)
1124 output_deps (pfile);
1126 /* Report on headers that could use multiple include guards. */
1127 if (CPP_OPTION (pfile, print_include_names))
1128 _cpp_report_missing_guards (pfile);
1131 /* Add a directive to be handled later in the initialization phase. */
1132 static void
1133 new_pending_directive (pend, text, handler)
1134 struct cpp_pending *pend;
1135 const char *text;
1136 cl_directive_handler handler;
1138 struct pending_option *o = (struct pending_option *)
1139 xmalloc (sizeof (struct pending_option));
1141 o->arg = text;
1142 o->next = NULL;
1143 o->handler = handler;
1144 APPEND (pend, directive, o);
1147 /* Irix6 "cc -n32" and OSF4 cc have problems with char foo[] = ("string");
1148 I.e. a const string initializer with parens around it. That is
1149 what N_("string") resolves to, so we make no_* be macros instead. */
1150 #define no_arg N_("argument missing after %s")
1151 #define no_ass N_("assertion missing after %s")
1152 #define no_dir N_("directory name missing after %s")
1153 #define no_fil N_("file name missing after %s")
1154 #define no_mac N_("macro name missing after %s")
1155 #define no_pth N_("path name missing after %s")
1156 #define no_num N_("number missing after %s")
1157 #define no_tgt N_("target missing after %s")
1159 /* This is the list of all command line options, with the leading
1160 "-" removed. It must be sorted in ASCII collating order. */
1161 #define COMMAND_LINE_OPTIONS \
1162 DEF_OPT("$", 0, OPT_dollar) \
1163 DEF_OPT("+", 0, OPT_plus) \
1164 DEF_OPT("-help", 0, OPT__help) \
1165 DEF_OPT("-target-help", 0, OPT_target__help) \
1166 DEF_OPT("-version", 0, OPT__version) \
1167 DEF_OPT("A", no_ass, OPT_A) \
1168 DEF_OPT("C", 0, OPT_C) \
1169 DEF_OPT("CC", 0, OPT_CC) \
1170 DEF_OPT("D", no_mac, OPT_D) \
1171 DEF_OPT("H", 0, OPT_H) \
1172 DEF_OPT("I", no_dir, OPT_I) \
1173 DEF_OPT("M", 0, OPT_M) \
1174 DEF_OPT("MD", no_fil, OPT_MD) \
1175 DEF_OPT("MF", no_fil, OPT_MF) \
1176 DEF_OPT("MG", 0, OPT_MG) \
1177 DEF_OPT("MM", 0, OPT_MM) \
1178 DEF_OPT("MMD", no_fil, OPT_MMD) \
1179 DEF_OPT("MP", 0, OPT_MP) \
1180 DEF_OPT("MQ", no_tgt, OPT_MQ) \
1181 DEF_OPT("MT", no_tgt, OPT_MT) \
1182 DEF_OPT("P", 0, OPT_P) \
1183 DEF_OPT("U", no_mac, OPT_U) \
1184 DEF_OPT("W", no_arg, OPT_W) /* arg optional */ \
1185 DEF_OPT("d", no_arg, OPT_d) \
1186 DEF_OPT("fleading-underscore", 0, OPT_fleading_underscore) \
1187 DEF_OPT("fno-leading-underscore", 0, OPT_fno_leading_underscore) \
1188 DEF_OPT("fno-operator-names", 0, OPT_fno_operator_names) \
1189 DEF_OPT("fno-preprocessed", 0, OPT_fno_preprocessed) \
1190 DEF_OPT("fno-show-column", 0, OPT_fno_show_column) \
1191 DEF_OPT("fpreprocessed", 0, OPT_fpreprocessed) \
1192 DEF_OPT("fshow-column", 0, OPT_fshow_column) \
1193 DEF_OPT("fsigned-char", 0, OPT_fsigned_char) \
1194 DEF_OPT("ftabstop=", no_num, OPT_ftabstop) \
1195 DEF_OPT("funsigned-char", 0, OPT_funsigned_char) \
1196 DEF_OPT("h", 0, OPT_h) \
1197 DEF_OPT("idirafter", no_dir, OPT_idirafter) \
1198 DEF_OPT("imacros", no_fil, OPT_imacros) \
1199 DEF_OPT("include", no_fil, OPT_include) \
1200 DEF_OPT("iprefix", no_pth, OPT_iprefix) \
1201 DEF_OPT("isystem", no_dir, OPT_isystem) \
1202 DEF_OPT("iwithprefix", no_dir, OPT_iwithprefix) \
1203 DEF_OPT("iwithprefixbefore", no_dir, OPT_iwithprefixbefore) \
1204 DEF_OPT("lang-asm", 0, OPT_lang_asm) \
1205 DEF_OPT("lang-c", 0, OPT_lang_c) \
1206 DEF_OPT("lang-c++", 0, OPT_lang_cplusplus) \
1207 DEF_OPT("lang-c89", 0, OPT_lang_c89) \
1208 DEF_OPT("lang-objc", 0, OPT_lang_objc) \
1209 DEF_OPT("lang-objc++", 0, OPT_lang_objcplusplus) \
1210 DEF_OPT("nostdinc", 0, OPT_nostdinc) \
1211 DEF_OPT("nostdinc++", 0, OPT_nostdincplusplus) \
1212 DEF_OPT("o", no_fil, OPT_o) \
1213 DEF_OPT("pedantic", 0, OPT_pedantic) \
1214 DEF_OPT("pedantic-errors", 0, OPT_pedantic_errors) \
1215 DEF_OPT("remap", 0, OPT_remap) \
1216 DEF_OPT("std=c++98", 0, OPT_std_cplusplus98) \
1217 DEF_OPT("std=c89", 0, OPT_std_c89) \
1218 DEF_OPT("std=c99", 0, OPT_std_c99) \
1219 DEF_OPT("std=c9x", 0, OPT_std_c9x) \
1220 DEF_OPT("std=gnu89", 0, OPT_std_gnu89) \
1221 DEF_OPT("std=gnu99", 0, OPT_std_gnu99) \
1222 DEF_OPT("std=gnu9x", 0, OPT_std_gnu9x) \
1223 DEF_OPT("std=iso9899:1990", 0, OPT_std_iso9899_1990) \
1224 DEF_OPT("std=iso9899:199409", 0, OPT_std_iso9899_199409) \
1225 DEF_OPT("std=iso9899:1999", 0, OPT_std_iso9899_1999) \
1226 DEF_OPT("std=iso9899:199x", 0, OPT_std_iso9899_199x) \
1227 DEF_OPT("trigraphs", 0, OPT_trigraphs) \
1228 DEF_OPT("v", 0, OPT_v) \
1229 DEF_OPT("version", 0, OPT_version) \
1230 DEF_OPT("w", 0, OPT_w)
1232 #define DEF_OPT(text, msg, code) code,
1233 enum opt_code
1235 COMMAND_LINE_OPTIONS
1236 N_OPTS
1238 #undef DEF_OPT
1240 struct cl_option
1242 const char *opt_text;
1243 const char *msg;
1244 size_t opt_len;
1245 enum opt_code opt_code;
1248 #define DEF_OPT(text, msg, code) { text, msg, sizeof(text) - 1, code },
1249 #ifdef HOST_EBCDIC
1250 static struct cl_option cl_options[] =
1251 #else
1252 static const struct cl_option cl_options[] =
1253 #endif
1255 COMMAND_LINE_OPTIONS
1257 #undef DEF_OPT
1258 #undef COMMAND_LINE_OPTIONS
1260 /* Perform a binary search to find which, if any, option the given
1261 command-line matches. Returns its index in the option array,
1262 negative on failure. Complications arise since some options can be
1263 suffixed with an argument, and multiple complete matches can occur,
1264 e.g. -iwithprefix and -iwithprefixbefore. Moreover, we need to
1265 accept options beginning with -W that we do not recognise, but not
1266 to swallow any subsequent command line argument; this is handled as
1267 special cases in cpp_handle_option. */
1268 static int
1269 parse_option (input)
1270 const char *input;
1272 unsigned int md, mn, mx;
1273 size_t opt_len;
1274 int comp;
1276 mn = 0;
1277 mx = N_OPTS;
1279 while (mx > mn)
1281 md = (mn + mx) / 2;
1283 opt_len = cl_options[md].opt_len;
1284 comp = memcmp (input, cl_options[md].opt_text, opt_len);
1286 if (comp > 0)
1287 mn = md + 1;
1288 else if (comp < 0)
1289 mx = md;
1290 else
1292 if (input[opt_len] == '\0')
1293 return md;
1294 /* We were passed more text. If the option takes an argument,
1295 we may match a later option or we may have been passed the
1296 argument. The longest possible option match succeeds.
1297 If the option takes no arguments we have not matched and
1298 continue the search (e.g. input="stdc++" match was "stdc"). */
1299 mn = md + 1;
1300 if (cl_options[md].msg)
1302 /* Scan forwards. If we get an exact match, return it.
1303 Otherwise, return the longest option-accepting match.
1304 This loops no more than twice with current options. */
1305 mx = md;
1306 for (; mn < (unsigned int) N_OPTS; mn++)
1308 opt_len = cl_options[mn].opt_len;
1309 if (memcmp (input, cl_options[mn].opt_text, opt_len))
1310 break;
1311 if (input[opt_len] == '\0')
1312 return mn;
1313 if (cl_options[mn].msg)
1314 mx = mn;
1316 return mx;
1321 return -1;
1324 /* Handle one command-line option in (argc, argv).
1325 Can be called multiple times, to handle multiple sets of options.
1326 If ignore is non-zero, this will ignore unrecognized -W* options.
1327 Returns number of strings consumed. */
1329 cpp_handle_option (pfile, argc, argv, ignore)
1330 cpp_reader *pfile;
1331 int argc;
1332 char **argv;
1333 int ignore;
1335 int i = 0;
1336 struct cpp_pending *pend = CPP_OPTION (pfile, pending);
1338 /* Interpret "-" or a non-option as a file name. */
1339 if (argv[i][0] != '-' || argv[i][1] == '\0')
1341 if (CPP_OPTION (pfile, in_fname) == NULL)
1342 CPP_OPTION (pfile, in_fname) = argv[i];
1343 else if (CPP_OPTION (pfile, out_fname) == NULL)
1344 CPP_OPTION (pfile, out_fname) = argv[i];
1345 else
1346 cpp_error (pfile, DL_FATAL,
1347 "too many filenames. Type %s --help for usage info",
1348 progname);
1350 else
1352 enum opt_code opt_code;
1353 int opt_index;
1354 const char *arg = 0;
1356 /* Skip over '-'. */
1357 opt_index = parse_option (&argv[i][1]);
1358 if (opt_index < 0)
1359 return i;
1361 opt_code = cl_options[opt_index].opt_code;
1362 if (cl_options[opt_index].msg)
1364 arg = &argv[i][cl_options[opt_index].opt_len + 1];
1366 /* Yuk. Special case for -W as it must not swallow
1367 up any following argument. If this becomes common, add
1368 another field to the cl_options table. */
1369 if (arg[0] == '\0' && opt_code != OPT_W)
1371 arg = argv[++i];
1372 if (!arg)
1374 cpp_error (pfile, DL_FATAL,
1375 cl_options[opt_index].msg, argv[i - 1]);
1376 return argc;
1381 switch (opt_code)
1383 case N_OPTS: /* Shut GCC up. */
1384 break;
1385 case OPT_fleading_underscore:
1386 CPP_OPTION (pfile, user_label_prefix) = "_";
1387 break;
1388 case OPT_fno_leading_underscore:
1389 CPP_OPTION (pfile, user_label_prefix) = "";
1390 break;
1391 case OPT_fno_operator_names:
1392 CPP_OPTION (pfile, operator_names) = 0;
1393 break;
1394 case OPT_fpreprocessed:
1395 CPP_OPTION (pfile, preprocessed) = 1;
1396 break;
1397 case OPT_fno_preprocessed:
1398 CPP_OPTION (pfile, preprocessed) = 0;
1399 break;
1400 case OPT_fshow_column:
1401 CPP_OPTION (pfile, show_column) = 1;
1402 break;
1403 case OPT_fno_show_column:
1404 CPP_OPTION (pfile, show_column) = 0;
1405 break;
1406 case OPT_fsigned_char:
1407 CPP_OPTION (pfile, signed_char) = 1;
1408 break;
1409 case OPT_funsigned_char:
1410 CPP_OPTION (pfile, signed_char) = 0;
1411 break;
1412 case OPT_ftabstop:
1413 /* Silently ignore empty string, non-longs and silly values. */
1414 if (arg[0] != '\0')
1416 char *endptr;
1417 long tabstop = strtol (arg, &endptr, 10);
1418 if (*endptr == '\0' && tabstop >= 1 && tabstop <= 100)
1419 CPP_OPTION (pfile, tabstop) = tabstop;
1421 break;
1422 case OPT_w:
1423 CPP_OPTION (pfile, inhibit_warnings) = 1;
1424 break;
1425 case OPT_h:
1426 case OPT__help:
1427 print_help ();
1428 CPP_OPTION (pfile, help_only) = 1;
1429 break;
1430 case OPT_target__help:
1431 /* Print if any target specific options. cpplib has none, but
1432 make sure help_only gets set. */
1433 CPP_OPTION (pfile, help_only) = 1;
1434 break;
1436 /* --version inhibits compilation, -version doesn't. -v means
1437 verbose and -version. Historical reasons, don't ask. */
1438 case OPT__version:
1439 CPP_OPTION (pfile, help_only) = 1;
1440 pfile->print_version = 1;
1441 break;
1442 case OPT_v:
1443 CPP_OPTION (pfile, verbose) = 1;
1444 pfile->print_version = 1;
1445 break;
1446 case OPT_version:
1447 pfile->print_version = 1;
1448 break;
1450 case OPT_C:
1451 CPP_OPTION (pfile, discard_comments) = 0;
1452 break;
1453 case OPT_CC:
1454 CPP_OPTION (pfile, discard_comments) = 0;
1455 CPP_OPTION (pfile, discard_comments_in_macro_exp) = 0;
1456 break;
1457 case OPT_P:
1458 CPP_OPTION (pfile, no_line_commands) = 1;
1459 break;
1460 case OPT_dollar: /* Don't include $ in identifiers. */
1461 CPP_OPTION (pfile, dollars_in_ident) = 0;
1462 break;
1463 case OPT_H:
1464 CPP_OPTION (pfile, print_include_names) = 1;
1465 break;
1466 case OPT_D:
1467 new_pending_directive (pend, arg, cpp_define);
1468 break;
1469 case OPT_pedantic_errors:
1470 CPP_OPTION (pfile, pedantic_errors) = 1;
1471 /* fall through */
1472 case OPT_pedantic:
1473 CPP_OPTION (pfile, pedantic) = 1;
1474 CPP_OPTION (pfile, warn_endif_labels) = 1;
1475 break;
1476 case OPT_trigraphs:
1477 CPP_OPTION (pfile, trigraphs) = 1;
1478 break;
1479 case OPT_plus:
1480 CPP_OPTION (pfile, cplusplus) = 1;
1481 CPP_OPTION (pfile, cplusplus_comments) = 1;
1482 break;
1483 case OPT_remap:
1484 CPP_OPTION (pfile, remap) = 1;
1485 break;
1486 case OPT_iprefix:
1487 CPP_OPTION (pfile, include_prefix) = arg;
1488 CPP_OPTION (pfile, include_prefix_len) = strlen (arg);
1489 break;
1490 case OPT_lang_c:
1491 set_lang (pfile, CLK_GNUC89);
1492 break;
1493 case OPT_lang_cplusplus:
1494 set_lang (pfile, CLK_GNUCXX);
1495 break;
1496 case OPT_lang_objc:
1497 set_lang (pfile, CLK_OBJC);
1498 break;
1499 case OPT_lang_objcplusplus:
1500 set_lang (pfile, CLK_OBJCXX);
1501 break;
1502 case OPT_lang_asm:
1503 set_lang (pfile, CLK_ASM);
1504 break;
1505 case OPT_std_cplusplus98:
1506 set_lang (pfile, CLK_CXX98);
1507 break;
1508 case OPT_std_gnu89:
1509 set_lang (pfile, CLK_GNUC89);
1510 break;
1511 case OPT_std_gnu9x:
1512 case OPT_std_gnu99:
1513 set_lang (pfile, CLK_GNUC99);
1514 break;
1515 case OPT_std_iso9899_199409:
1516 set_lang (pfile, CLK_STDC94);
1517 break;
1518 case OPT_std_iso9899_1990:
1519 case OPT_std_c89:
1520 case OPT_lang_c89:
1521 set_lang (pfile, CLK_STDC89);
1522 break;
1523 case OPT_std_iso9899_199x:
1524 case OPT_std_iso9899_1999:
1525 case OPT_std_c9x:
1526 case OPT_std_c99:
1527 set_lang (pfile, CLK_STDC99);
1528 break;
1529 case OPT_nostdinc:
1530 /* -nostdinc causes no default include directories.
1531 You must specify all include-file directories with -I. */
1532 CPP_OPTION (pfile, no_standard_includes) = 1;
1533 break;
1534 case OPT_nostdincplusplus:
1535 /* -nostdinc++ causes no default C++-specific include directories. */
1536 CPP_OPTION (pfile, no_standard_cplusplus_includes) = 1;
1537 break;
1538 case OPT_o:
1539 if (CPP_OPTION (pfile, out_fname) == NULL)
1540 CPP_OPTION (pfile, out_fname) = arg;
1541 else
1543 cpp_error (pfile, DL_FATAL, "output filename specified twice");
1544 return argc;
1546 break;
1547 case OPT_d:
1548 /* Args to -d specify what parts of macros to dump.
1549 Silently ignore unrecognised options; they may
1550 be aimed at the compiler proper. */
1552 char c;
1554 while ((c = *arg++) != '\0')
1555 switch (c)
1557 case 'M':
1558 CPP_OPTION (pfile, dump_macros) = dump_only;
1559 break;
1560 case 'N':
1561 CPP_OPTION (pfile, dump_macros) = dump_names;
1562 break;
1563 case 'D':
1564 CPP_OPTION (pfile, dump_macros) = dump_definitions;
1565 break;
1566 case 'I':
1567 CPP_OPTION (pfile, dump_includes) = 1;
1568 break;
1571 break;
1573 case OPT_MG:
1574 CPP_OPTION (pfile, print_deps_missing_files) = 1;
1575 break;
1576 case OPT_M:
1577 /* When doing dependencies with -M or -MM, suppress normal
1578 preprocessed output, but still do -dM etc. as software
1579 depends on this. Preprocessed output occurs if -MD, -MMD
1580 or environment var dependency generation is used. */
1581 CPP_OPTION (pfile, print_deps) = 2;
1582 CPP_OPTION (pfile, no_output) = 1;
1583 break;
1584 case OPT_MM:
1585 CPP_OPTION (pfile, print_deps) = 1;
1586 CPP_OPTION (pfile, no_output) = 1;
1587 break;
1588 case OPT_MF:
1589 CPP_OPTION (pfile, deps_file) = arg;
1590 break;
1591 case OPT_MP:
1592 CPP_OPTION (pfile, deps_phony_targets) = 1;
1593 break;
1594 case OPT_MQ:
1595 case OPT_MT:
1596 /* Add a target. -MQ quotes for Make. */
1597 deps_add_target (pfile->deps, arg, opt_code == OPT_MQ);
1598 break;
1600 case OPT_MD:
1601 CPP_OPTION (pfile, print_deps) = 2;
1602 CPP_OPTION (pfile, deps_file) = arg;
1603 break;
1604 case OPT_MMD:
1605 CPP_OPTION (pfile, print_deps) = 1;
1606 CPP_OPTION (pfile, deps_file) = arg;
1607 break;
1609 case OPT_A:
1610 if (arg[0] == '-')
1612 /* -A with an argument beginning with '-' acts as
1613 #unassert on whatever immediately follows the '-'.
1614 If "-" is the whole argument, we eliminate all
1615 predefined macros and assertions, including those
1616 that were specified earlier on the command line.
1617 That way we can get rid of any that were passed
1618 automatically in from GCC. */
1620 if (arg[1] == '\0')
1622 free_chain (pend->directive_head);
1623 pend->directive_head = NULL;
1624 pend->directive_tail = NULL;
1626 else
1627 new_pending_directive (pend, arg + 1, cpp_unassert);
1629 else
1630 new_pending_directive (pend, arg, cpp_assert);
1631 break;
1632 case OPT_U:
1633 new_pending_directive (pend, arg, cpp_undef);
1634 break;
1635 case OPT_I: /* Add directory to path for includes. */
1636 if (!strcmp (arg, "-"))
1638 /* -I- means:
1639 Use the preceding -I directories for #include "..."
1640 but not #include <...>.
1641 Don't search the directory of the present file
1642 for #include "...". (Note that -I. -I- is not the same as
1643 the default setup; -I. uses the compiler's working dir.) */
1644 if (! CPP_OPTION (pfile, ignore_srcdir))
1646 pend->quote_head = pend->brack_head;
1647 pend->quote_tail = pend->brack_tail;
1648 pend->brack_head = 0;
1649 pend->brack_tail = 0;
1650 CPP_OPTION (pfile, ignore_srcdir) = 1;
1652 else
1654 cpp_error (pfile, DL_FATAL, "-I- specified twice");
1655 return argc;
1658 else
1659 append_include_chain (pfile, xstrdup (arg), BRACKET, 0);
1660 break;
1661 case OPT_isystem:
1662 /* Add directory to beginning of system include path, as a system
1663 include directory. */
1664 append_include_chain (pfile, xstrdup (arg), SYSTEM, 0);
1665 break;
1666 case OPT_include:
1667 case OPT_imacros:
1669 struct pending_option *o = (struct pending_option *)
1670 xmalloc (sizeof (struct pending_option));
1671 o->arg = arg;
1672 o->next = NULL;
1674 if (opt_code == OPT_include)
1675 APPEND (pend, include, o);
1676 else
1677 APPEND (pend, imacros, o);
1679 break;
1680 case OPT_iwithprefix:
1681 /* Add directory to end of path for includes,
1682 with the default prefix at the front of its name. */
1683 /* fall through */
1684 case OPT_iwithprefixbefore:
1685 /* Add directory to main path for includes,
1686 with the default prefix at the front of its name. */
1688 char *fname;
1689 int len;
1691 len = strlen (arg);
1693 if (CPP_OPTION (pfile, include_prefix) != 0)
1695 size_t ipl = CPP_OPTION (pfile, include_prefix_len);
1696 fname = xmalloc (ipl + len + 1);
1697 memcpy (fname, CPP_OPTION (pfile, include_prefix), ipl);
1698 memcpy (fname + ipl, arg, len + 1);
1700 else if (cpp_GCC_INCLUDE_DIR_len)
1702 fname = xmalloc (cpp_GCC_INCLUDE_DIR_len + len + 1);
1703 memcpy (fname, cpp_GCC_INCLUDE_DIR, cpp_GCC_INCLUDE_DIR_len);
1704 memcpy (fname + cpp_GCC_INCLUDE_DIR_len, arg, len + 1);
1706 else
1707 fname = xstrdup (arg);
1709 append_include_chain (pfile, fname,
1710 opt_code == OPT_iwithprefix ? SYSTEM: BRACKET, 0);
1712 break;
1713 case OPT_idirafter:
1714 /* Add directory to end of path for includes. */
1715 append_include_chain (pfile, xstrdup (arg), AFTER, 0);
1716 break;
1717 case OPT_W:
1718 /* Silently ignore unrecognised options. */
1719 if (!strcmp (argv[i], "-Wall"))
1721 CPP_OPTION (pfile, warn_trigraphs) = 1;
1722 CPP_OPTION (pfile, warn_comments) = 1;
1724 else if (!strcmp (argv[i], "-Wtraditional"))
1725 CPP_OPTION (pfile, warn_traditional) = 1;
1726 else if (!strcmp (argv[i], "-Wtrigraphs"))
1727 CPP_OPTION (pfile, warn_trigraphs) = 1;
1728 else if (!strcmp (argv[i], "-Wcomment"))
1729 CPP_OPTION (pfile, warn_comments) = 1;
1730 else if (!strcmp (argv[i], "-Wcomments"))
1731 CPP_OPTION (pfile, warn_comments) = 1;
1732 else if (!strcmp (argv[i], "-Wundef"))
1733 CPP_OPTION (pfile, warn_undef) = 1;
1734 else if (!strcmp (argv[i], "-Wimport"))
1735 CPP_OPTION (pfile, warn_import) = 1;
1736 else if (!strcmp (argv[i], "-Werror"))
1737 CPP_OPTION (pfile, warnings_are_errors) = 1;
1738 else if (!strcmp (argv[i], "-Wsystem-headers"))
1739 CPP_OPTION (pfile, warn_system_headers) = 1;
1740 else if (!strcmp (argv[i], "-Wendif-labels"))
1741 CPP_OPTION (pfile, warn_endif_labels) = 1;
1742 else if (!strcmp (argv[i], "-Wno-traditional"))
1743 CPP_OPTION (pfile, warn_traditional) = 0;
1744 else if (!strcmp (argv[i], "-Wno-trigraphs"))
1745 CPP_OPTION (pfile, warn_trigraphs) = 0;
1746 else if (!strcmp (argv[i], "-Wno-comment"))
1747 CPP_OPTION (pfile, warn_comments) = 0;
1748 else if (!strcmp (argv[i], "-Wno-comments"))
1749 CPP_OPTION (pfile, warn_comments) = 0;
1750 else if (!strcmp (argv[i], "-Wno-undef"))
1751 CPP_OPTION (pfile, warn_undef) = 0;
1752 else if (!strcmp (argv[i], "-Wno-import"))
1753 CPP_OPTION (pfile, warn_import) = 0;
1754 else if (!strcmp (argv[i], "-Wno-error"))
1755 CPP_OPTION (pfile, warnings_are_errors) = 0;
1756 else if (!strcmp (argv[i], "-Wno-system-headers"))
1757 CPP_OPTION (pfile, warn_system_headers) = 0;
1758 else if (!strcmp (argv[i], "-Wno-endif-labels"))
1759 CPP_OPTION (pfile, warn_endif_labels) = 0;
1760 else if (! ignore)
1761 return i;
1762 break;
1765 return i + 1;
1768 /* Handle command-line options in (argc, argv).
1769 Can be called multiple times, to handle multiple sets of options.
1770 Returns if an unrecognized option is seen.
1771 Returns number of strings consumed. */
1773 cpp_handle_options (pfile, argc, argv)
1774 cpp_reader *pfile;
1775 int argc;
1776 char **argv;
1778 int i;
1779 int strings_processed;
1781 for (i = 0; i < argc; i += strings_processed)
1783 strings_processed = cpp_handle_option (pfile, argc - i, argv + i, 1);
1784 if (strings_processed == 0)
1785 break;
1788 return i;
1791 /* Sanity-checks are dependent on command-line options, so it is
1792 called as a subroutine of cpp_post_options (). */
1793 #if ENABLE_CHECKING
1794 static void sanity_checks PARAMS ((cpp_reader *));
1795 static void sanity_checks (pfile)
1796 cpp_reader *pfile;
1798 cppchar_t test = 0;
1799 size_t max_prec;
1801 /* Sanity checks for CPP arithmetic. */
1802 test--;
1803 if (test < 1)
1804 cpp_error (pfile, DL_FATAL, "cppchar_t must be an unsigned type");
1806 if (CPP_OPTION (pfile, precision) > BITS_PER_HOST_WIDEST_INT)
1807 cpp_error (pfile, DL_FATAL,
1808 "preprocessor arithmetic has maximum precision of %u bits; target requires %u bits",
1809 BITS_PER_HOST_WIDEST_INT, CPP_OPTION (pfile, precision));
1811 max_prec = CPP_OPTION (pfile, char_precision);
1812 if (max_prec < CPP_OPTION (pfile, wchar_precision))
1813 max_prec = CPP_OPTION (pfile, wchar_precision);
1814 if (max_prec > BITS_PER_CPPCHAR_T)
1815 cpp_error (pfile, DL_FATAL,
1816 "CPP on this host cannot handle (wide) character constants over %u bits, but the target requires %u bits",
1817 BITS_PER_CPPCHAR_T, max_prec);
1819 #else
1820 # define sanity_checks(PFILE)
1821 #endif
1823 /* Extra processing when all options are parsed, after all calls to
1824 cpp_handle_option[s]. Consistency checks etc. */
1825 void
1826 cpp_post_options (pfile)
1827 cpp_reader *pfile;
1829 sanity_checks (pfile);
1831 if (pfile->print_version)
1833 fprintf (stderr, _("GNU CPP version %s (cpplib)"), version_string);
1834 #ifdef TARGET_VERSION
1835 TARGET_VERSION;
1836 #endif
1837 fputc ('\n', stderr);
1840 /* Canonicalize in_fname and out_fname. We guarantee they are not
1841 NULL, and that the empty string represents stdin / stdout. */
1842 if (CPP_OPTION (pfile, in_fname) == NULL
1843 || !strcmp (CPP_OPTION (pfile, in_fname), "-"))
1844 CPP_OPTION (pfile, in_fname) = "";
1846 if (CPP_OPTION (pfile, out_fname) == NULL
1847 || !strcmp (CPP_OPTION (pfile, out_fname), "-"))
1848 CPP_OPTION (pfile, out_fname) = "";
1850 /* -Wtraditional is not useful in C++ mode. */
1851 if (CPP_OPTION (pfile, cplusplus))
1852 CPP_OPTION (pfile, warn_traditional) = 0;
1854 /* Set this if it hasn't been set already. */
1855 if (CPP_OPTION (pfile, user_label_prefix) == NULL)
1856 CPP_OPTION (pfile, user_label_prefix) = USER_LABEL_PREFIX;
1858 /* Permanently disable macro expansion if we are rescanning
1859 preprocessed text. */
1860 if (CPP_OPTION (pfile, preprocessed))
1861 pfile->state.prevent_expansion = 1;
1863 /* -dM makes no normal output. This is set here so that -dM -dD
1864 works as expected. */
1865 if (CPP_OPTION (pfile, dump_macros) == dump_only)
1866 CPP_OPTION (pfile, no_output) = 1;
1868 /* Disable -dD, -dN and -dI if we should make no normal output
1869 (such as with -M). Allow -M -dM since some software relies on
1870 this. */
1871 if (CPP_OPTION (pfile, no_output))
1873 if (CPP_OPTION (pfile, dump_macros) != dump_only)
1874 CPP_OPTION (pfile, dump_macros) = dump_none;
1875 CPP_OPTION (pfile, dump_includes) = 0;
1878 /* We need to do this after option processing and before
1879 cpp_start_read, as cppmain.c relies on the options->no_output to
1880 set its callbacks correctly before calling cpp_start_read. */
1881 init_dependency_output (pfile);
1883 /* After checking the environment variables, check if -M or -MM has
1884 not been specified, but other -M options have. */
1885 if (CPP_OPTION (pfile, print_deps) == 0 &&
1886 (CPP_OPTION (pfile, print_deps_missing_files)
1887 || CPP_OPTION (pfile, deps_file)
1888 || CPP_OPTION (pfile, deps_phony_targets)))
1889 cpp_error (pfile, DL_FATAL,
1890 "you must additionally specify either -M or -MM");
1893 /* Set up dependency-file output. On exit, if print_deps is non-zero
1894 then deps_file is not NULL; stdout is the empty string. */
1895 static void
1896 init_dependency_output (pfile)
1897 cpp_reader *pfile;
1899 char *spec, *s, *output_file;
1901 /* Either of two environment variables can specify output of deps.
1902 Its value is either "OUTPUT_FILE" or "OUTPUT_FILE DEPS_TARGET",
1903 where OUTPUT_FILE is the file to write deps info to
1904 and DEPS_TARGET is the target to mention in the deps. */
1906 if (CPP_OPTION (pfile, print_deps) == 0)
1908 spec = getenv ("DEPENDENCIES_OUTPUT");
1909 if (spec)
1910 CPP_OPTION (pfile, print_deps) = 1;
1911 else
1913 spec = getenv ("SUNPRO_DEPENDENCIES");
1914 if (spec)
1915 CPP_OPTION (pfile, print_deps) = 2;
1916 else
1917 return;
1920 /* Find the space before the DEPS_TARGET, if there is one. */
1921 s = strchr (spec, ' ');
1922 if (s)
1924 /* Let the caller perform MAKE quoting. */
1925 deps_add_target (pfile->deps, s + 1, 0);
1926 output_file = (char *) xmalloc (s - spec + 1);
1927 memcpy (output_file, spec, s - spec);
1928 output_file[s - spec] = 0;
1930 else
1931 output_file = spec;
1933 /* Command line -MF overrides environment variables and default. */
1934 if (CPP_OPTION (pfile, deps_file) == 0)
1935 CPP_OPTION (pfile, deps_file) = output_file;
1937 CPP_OPTION (pfile, print_deps_append) = 1;
1939 else if (CPP_OPTION (pfile, deps_file) == 0)
1940 /* If -M or -MM was seen without -MF, default output to wherever
1941 was specified with -o. out_fname is non-NULL here. */
1942 CPP_OPTION (pfile, deps_file) = CPP_OPTION (pfile, out_fname);
1945 /* Handle --help output. */
1946 static void
1947 print_help ()
1949 /* To keep the lines from getting too long for some compilers, limit
1950 to about 500 characters (6 lines) per chunk. */
1951 fputs (_("\
1952 Switches:\n\
1953 -include <file> Include the contents of <file> before other files\n\
1954 -imacros <file> Accept definition of macros in <file>\n\
1955 -iprefix <path> Specify <path> as a prefix for next two options\n\
1956 -iwithprefix <dir> Add <dir> to the end of the system include path\n\
1957 -iwithprefixbefore <dir> Add <dir> to the end of the main include path\n\
1958 -isystem <dir> Add <dir> to the start of the system include path\n\
1959 "), stdout);
1960 fputs (_("\
1961 -idirafter <dir> Add <dir> to the end of the system include path\n\
1962 -I <dir> Add <dir> to the end of the main include path\n\
1963 -I- Fine-grained include path control; see info docs\n\
1964 -nostdinc Do not search system include directories\n\
1965 (dirs specified with -isystem will still be used)\n\
1966 -nostdinc++ Do not search system include directories for C++\n\
1967 -o <file> Put output into <file>\n\
1968 "), stdout);
1969 fputs (_("\
1970 -pedantic Issue all warnings demanded by strict ISO C\n\
1971 -pedantic-errors Issue -pedantic warnings as errors instead\n\
1972 -trigraphs Support ISO C trigraphs\n\
1973 -lang-c Assume that the input sources are in C\n\
1974 -lang-c89 Assume that the input sources are in C89\n\
1975 "), stdout);
1976 fputs (_("\
1977 -lang-c++ Assume that the input sources are in C++\n\
1978 -lang-objc Assume that the input sources are in ObjectiveC\n\
1979 -lang-objc++ Assume that the input sources are in ObjectiveC++\n\
1980 -lang-asm Assume that the input sources are in assembler\n\
1981 "), stdout);
1982 fputs (_("\
1983 -std=<std name> Specify the conformance standard; one of:\n\
1984 gnu89, gnu99, c89, c99, iso9899:1990,\n\
1985 iso9899:199409, iso9899:1999\n\
1986 -+ Allow parsing of C++ style features\n\
1987 -w Inhibit warning messages\n\
1988 -Wtrigraphs Warn if trigraphs are encountered\n\
1989 -Wno-trigraphs Do not warn about trigraphs\n\
1990 -Wcomment{s} Warn if one comment starts inside another\n\
1991 "), stdout);
1992 fputs (_("\
1993 -Wno-comment{s} Do not warn about comments\n\
1994 -Wtraditional Warn about features not present in traditional C\n\
1995 -Wno-traditional Do not warn about traditional C\n\
1996 -Wundef Warn if an undefined macro is used by #if\n\
1997 -Wno-undef Do not warn about testing undefined macros\n\
1998 -Wimport Warn about the use of the #import directive\n\
1999 "), stdout);
2000 fputs (_("\
2001 -Wno-import Do not warn about the use of #import\n\
2002 -Werror Treat all warnings as errors\n\
2003 -Wno-error Do not treat warnings as errors\n\
2004 -Wsystem-headers Do not suppress warnings from system headers\n\
2005 -Wno-system-headers Suppress warnings from system headers\n\
2006 -Wall Enable all preprocessor warnings\n\
2007 "), stdout);
2008 fputs (_("\
2009 -M Generate make dependencies\n\
2010 -MM As -M, but ignore system header files\n\
2011 -MD Generate make dependencies and compile\n\
2012 -MMD As -MD, but ignore system header files\n\
2013 -MF <file> Write dependency output to the given file\n\
2014 -MG Treat missing header file as generated files\n\
2015 "), stdout);
2016 fputs (_("\
2017 -MP Generate phony targets for all headers\n\
2018 -MQ <target> Add a MAKE-quoted target\n\
2019 -MT <target> Add an unquoted target\n\
2020 "), stdout);
2021 fputs (_("\
2022 -D<macro> Define a <macro> with string '1' as its value\n\
2023 -D<macro>=<val> Define a <macro> with <val> as its value\n\
2024 -A<question>=<answer> Assert the <answer> to <question>\n\
2025 -A-<question>=<answer> Disable the <answer> to <question>\n\
2026 -U<macro> Undefine <macro> \n\
2027 -v Display the version number\n\
2028 "), stdout);
2029 fputs (_("\
2030 -H Print the name of header files as they are used\n\
2031 -C Do not discard comments\n\
2032 -dM Display a list of macro definitions active at end\n\
2033 -dD Preserve macro definitions in output\n\
2034 -dN As -dD except that only the names are preserved\n\
2035 -dI Include #include directives in the output\n\
2036 "), stdout);
2037 fputs (_("\
2038 -fpreprocessed Treat the input file as already preprocessed\n\
2039 -ftabstop=<number> Distance between tab stops for column reporting\n\
2040 -P Do not generate #line directives\n\
2041 -$ Do not allow '$' in identifiers\n\
2042 -remap Remap file names when including files\n\
2043 --version Display version information\n\
2044 -h or --help Display this information\n\
2045 "), stdout);