]> gcc.gnu.org Git - gcc.git/blob - gcc/cppinit.c
Daily bump.
[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) = !DEFAULT_SIGNED_CHAR;
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
698 if (CPP_OPTION (pfile, objc))
699 _cpp_define_builtin (pfile, "__OBJC__ 1");
700
701 if (CPP_OPTION (pfile, lang) == CLK_STDC94)
702 _cpp_define_builtin (pfile, "__STDC_VERSION__ 199409L");
703 else if (CPP_OPTION (pfile, c99))
704 _cpp_define_builtin (pfile, "__STDC_VERSION__ 199901L");
705
706 if (CPP_OPTION (pfile, unsigned_char))
707 _cpp_define_builtin (pfile, "__CHAR_UNSIGNED__ 1");
708
709 if (CPP_OPTION (pfile, lang) == CLK_STDC89
710 || CPP_OPTION (pfile, lang) == CLK_STDC94
711 || CPP_OPTION (pfile, lang) == CLK_STDC99)
712 _cpp_define_builtin (pfile, "__STRICT_ANSI__ 1");
713 else if (CPP_OPTION (pfile, lang) == CLK_ASM)
714 _cpp_define_builtin (pfile, "__ASSEMBLER__ 1");
715
716 if (pfile->cb.register_builtins)
717 (*pfile->cb.register_builtins) (pfile);
718 }
719
720 /* And another subroutine. This one sets up the standard include path. */
721 static void
722 init_standard_includes (pfile)
723 cpp_reader *pfile;
724 {
725 char *path;
726 const struct default_include *p;
727 const char *specd_prefix = CPP_OPTION (pfile, include_prefix);
728
729 /* Several environment variables may add to the include search path.
730 CPATH specifies an additional list of directories to be searched
731 as if specified with -I, while C_INCLUDE_PATH, CPLUS_INCLUDE_PATH,
732 etc. specify an additional list of directories to be searched as
733 if specified with -isystem, for the language indicated. */
734
735 GET_ENV_PATH_LIST (path, "CPATH");
736 if (path != 0 && *path != 0)
737 path_include (pfile, path, BRACKET);
738
739 switch ((CPP_OPTION (pfile, objc) << 1) + CPP_OPTION (pfile, cplusplus))
740 {
741 case 0:
742 GET_ENV_PATH_LIST (path, "C_INCLUDE_PATH");
743 break;
744 case 1:
745 GET_ENV_PATH_LIST (path, "CPLUS_INCLUDE_PATH");
746 break;
747 case 2:
748 GET_ENV_PATH_LIST (path, "OBJC_INCLUDE_PATH");
749 break;
750 case 3:
751 GET_ENV_PATH_LIST (path, "OBJCPLUS_INCLUDE_PATH");
752 break;
753 }
754 if (path != 0 && *path != 0)
755 path_include (pfile, path, SYSTEM);
756
757 /* Search "translated" versions of GNU directories.
758 These have /usr/local/lib/gcc... replaced by specd_prefix. */
759 if (specd_prefix != 0 && cpp_GCC_INCLUDE_DIR_len)
760 {
761 /* Remove the `include' from /usr/local/lib/gcc.../include.
762 GCC_INCLUDE_DIR will always end in /include. */
763 int default_len = cpp_GCC_INCLUDE_DIR_len;
764 char *default_prefix = (char *) alloca (default_len + 1);
765 int specd_len = strlen (specd_prefix);
766
767 memcpy (default_prefix, cpp_GCC_INCLUDE_DIR, default_len);
768 default_prefix[default_len] = '\0';
769
770 for (p = cpp_include_defaults; p->fname; p++)
771 {
772 /* Some standard dirs are only for C++. */
773 if (!p->cplusplus
774 || (CPP_OPTION (pfile, cplusplus)
775 && !CPP_OPTION (pfile, no_standard_cplusplus_includes)))
776 {
777 /* Does this dir start with the prefix? */
778 if (!memcmp (p->fname, default_prefix, default_len))
779 {
780 /* Yes; change prefix and add to search list. */
781 int flen = strlen (p->fname);
782 int this_len = specd_len + flen - default_len;
783 char *str = (char *) xmalloc (this_len + 1);
784 memcpy (str, specd_prefix, specd_len);
785 memcpy (str + specd_len,
786 p->fname + default_len,
787 flen - default_len + 1);
788
789 append_include_chain (pfile, str, SYSTEM, p->cxx_aware);
790 }
791 }
792 }
793 }
794
795 /* Search ordinary names for GNU include directories. */
796 for (p = cpp_include_defaults; p->fname; p++)
797 {
798 /* Some standard dirs are only for C++. */
799 if (!p->cplusplus
800 || (CPP_OPTION (pfile, cplusplus)
801 && !CPP_OPTION (pfile, no_standard_cplusplus_includes)))
802 {
803 char *str = update_path (p->fname, p->component);
804 append_include_chain (pfile, str, SYSTEM, p->cxx_aware);
805 }
806 }
807 }
808
809 /* Pushes a command line -imacro and -include file indicated by P onto
810 the buffer stack. Returns non-zero if successful. */
811 static bool
812 push_include (pfile, p)
813 cpp_reader *pfile;
814 struct pending_option *p;
815 {
816 cpp_token header;
817
818 /* Later: maybe update this to use the #include "" search path
819 if cpp_read_file fails. */
820 header.type = CPP_STRING;
821 header.val.str.text = (const unsigned char *) p->arg;
822 header.val.str.len = strlen (p->arg);
823 /* Make the command line directive take up a line. */
824 pfile->line++;
825
826 return _cpp_execute_include (pfile, &header, IT_CMDLINE);
827 }
828
829 /* Frees a pending_option chain. */
830 static void
831 free_chain (head)
832 struct pending_option *head;
833 {
834 struct pending_option *next;
835
836 while (head)
837 {
838 next = head->next;
839 free (head);
840 head = next;
841 }
842 }
843
844 /* Sanity-checks are dependent on command-line options, so it is
845 called as a subroutine of cpp_read_main_file (). */
846 #if ENABLE_CHECKING
847 static void sanity_checks PARAMS ((cpp_reader *));
848 static void sanity_checks (pfile)
849 cpp_reader *pfile;
850 {
851 cppchar_t test = 0;
852
853 /* Sanity checks for assumptions about CPP arithmetic and target
854 type precisions made by cpplib. */
855 test--;
856 if (test < 1)
857 cpp_error (pfile, DL_FATAL, "cppchar_t must be an unsigned type");
858
859 if (CPP_OPTION (pfile, precision) > BITS_PER_HOST_WIDEST_INT)
860 cpp_error (pfile, DL_FATAL,
861 "preprocessor arithmetic has maximum precision of %u bits; target requires %u bits",
862 BITS_PER_HOST_WIDEST_INT, CPP_OPTION (pfile, precision));
863
864 if (CPP_OPTION (pfile, precision) < CPP_OPTION (pfile, int_precision))
865 cpp_error (pfile, DL_FATAL,
866 "CPP arithmetic must be at least as precise as a target int");
867
868 if (CPP_OPTION (pfile, char_precision) < 8)
869 cpp_error (pfile, DL_FATAL, "target char is less than 8 bits wide");
870
871 if (CPP_OPTION (pfile, wchar_precision) < CPP_OPTION (pfile, char_precision))
872 cpp_error (pfile, DL_FATAL,
873 "target wchar_t is narrower than target char");
874
875 if (CPP_OPTION (pfile, int_precision) < CPP_OPTION (pfile, char_precision))
876 cpp_error (pfile, DL_FATAL,
877 "target int is narrower than target char");
878
879 if (CPP_OPTION (pfile, wchar_precision) > BITS_PER_CPPCHAR_T)
880 cpp_error (pfile, DL_FATAL,
881 "CPP on this host cannot handle wide character constants over %u bits, but the target requires %u bits",
882 BITS_PER_CPPCHAR_T, CPP_OPTION (pfile, wchar_precision));
883 }
884 #else
885 # define sanity_checks(PFILE)
886 #endif
887
888 /* This is called after options have been parsed, and partially
889 processed. Setup for processing input from the file named FNAME,
890 or stdin if it is the empty string. Return the original filename
891 on success (e.g. foo.i->foo.c), or NULL on failure. */
892 const char *
893 cpp_read_main_file (pfile, fname, table)
894 cpp_reader *pfile;
895 const char *fname;
896 hash_table *table;
897 {
898 sanity_checks (pfile);
899
900 /* The front ends don't set up the hash table until they have
901 finished processing the command line options, so initializing the
902 hashtable is deferred until now. */
903 _cpp_init_hashtable (pfile, table);
904
905 /* Set up the include search path now. */
906 if (! CPP_OPTION (pfile, no_standard_includes))
907 init_standard_includes (pfile);
908
909 merge_include_chains (pfile);
910
911 /* With -v, print the list of dirs to search. */
912 if (CPP_OPTION (pfile, verbose))
913 {
914 struct search_path *l;
915 fprintf (stderr, _("#include \"...\" search starts here:\n"));
916 for (l = CPP_OPTION (pfile, quote_include); l; l = l->next)
917 {
918 if (l == CPP_OPTION (pfile, bracket_include))
919 fprintf (stderr, _("#include <...> search starts here:\n"));
920 fprintf (stderr, " %s\n", l->name);
921 }
922 fprintf (stderr, _("End of search list.\n"));
923 }
924
925 if (CPP_OPTION (pfile, print_deps))
926 /* Set the default target (if there is none already). */
927 deps_add_default_target (pfile->deps, fname);
928
929 /* Open the main input file. */
930 if (!_cpp_read_file (pfile, fname))
931 return NULL;
932
933 /* Set this after cpp_post_options so the client can change the
934 option if it wishes, and after stacking the main file so we don't
935 trace the main file. */
936 pfile->line_maps.trace_includes = CPP_OPTION (pfile, print_include_names);
937
938 /* For foo.i, read the original filename foo.c now, for the benefit
939 of the front ends. */
940 if (CPP_OPTION (pfile, preprocessed))
941 read_original_filename (pfile);
942 /* Overlay an empty buffer to seed traditional preprocessing. */
943 else if (CPP_OPTION (pfile, traditional))
944 _cpp_overlay_buffer (pfile, U"", 0);
945
946 return pfile->map->to_file;
947 }
948
949 /* For preprocessed files, if the first tokens are of the form # NUM.
950 handle the directive so we know the original file name. This will
951 generate file_change callbacks, which the front ends must handle
952 appropriately given their state of initialization. */
953 static void
954 read_original_filename (pfile)
955 cpp_reader *pfile;
956 {
957 const cpp_token *token, *token1;
958
959 /* Lex ahead; if the first tokens are of the form # NUM, then
960 process the directive, otherwise back up. */
961 token = _cpp_lex_direct (pfile);
962 if (token->type == CPP_HASH)
963 {
964 token1 = _cpp_lex_direct (pfile);
965 _cpp_backup_tokens (pfile, 1);
966
967 /* If it's a #line directive, handle it. */
968 if (token1->type == CPP_NUMBER)
969 {
970 _cpp_handle_directive (pfile, token->flags & PREV_WHITE);
971 return;
972 }
973 }
974
975 /* Backup as if nothing happened. */
976 _cpp_backup_tokens (pfile, 1);
977 }
978
979 /* Handle pending command line options: -D, -U, -A, -imacros and
980 -include. This should be called after debugging has been properly
981 set up in the front ends. */
982 void
983 cpp_finish_options (pfile)
984 cpp_reader *pfile;
985 {
986 /* Install builtins and process command line macros etc. in the order
987 they appeared, but only if not already preprocessed. */
988 if (! CPP_OPTION (pfile, preprocessed))
989 {
990 struct pending_option *p;
991
992 _cpp_do_file_change (pfile, LC_RENAME, _("<built-in>"), 1, 0);
993 if (!CPP_OPTION (pfile, traditional) /* REMOVEME */)
994 init_builtins (pfile);
995 _cpp_do_file_change (pfile, LC_RENAME, _("<command line>"), 1, 0);
996 if (!CPP_OPTION (pfile, traditional) /* REMOVEME */)
997 for (p = CPP_OPTION (pfile, pending)->directive_head; p; p = p->next)
998 (*p->handler) (pfile, p->arg);
999
1000 /* Scan -imacros files after -D, -U, but before -include.
1001 pfile->next_include_file is NULL, so _cpp_pop_buffer does not
1002 push -include files. */
1003 for (p = CPP_OPTION (pfile, pending)->imacros_head; p; p = p->next)
1004 if (push_include (pfile, p))
1005 cpp_scan_nooutput (pfile);
1006
1007 pfile->next_include_file = &CPP_OPTION (pfile, pending)->include_head;
1008 _cpp_maybe_push_include_file (pfile);
1009 }
1010
1011 free_chain (CPP_OPTION (pfile, pending)->imacros_head);
1012 free_chain (CPP_OPTION (pfile, pending)->directive_head);
1013 }
1014
1015 /* Push the next buffer on the stack given by -include, if any. */
1016 void
1017 _cpp_maybe_push_include_file (pfile)
1018 cpp_reader *pfile;
1019 {
1020 if (pfile->next_include_file)
1021 {
1022 struct pending_option *head = *pfile->next_include_file;
1023
1024 while (head && !push_include (pfile, head))
1025 head = head->next;
1026
1027 if (head)
1028 pfile->next_include_file = &head->next;
1029 else
1030 {
1031 /* All done; restore the line map from <command line>. */
1032 _cpp_do_file_change (pfile, LC_RENAME,
1033 pfile->line_maps.maps[0].to_file, 1, 0);
1034 /* Don't come back here again. */
1035 pfile->next_include_file = NULL;
1036 }
1037 }
1038 }
1039
1040 /* Use mkdeps.c to output dependency information. */
1041 static void
1042 output_deps (pfile)
1043 cpp_reader *pfile;
1044 {
1045 /* Stream on which to print the dependency information. */
1046 FILE *deps_stream = 0;
1047 const char *const deps_mode =
1048 CPP_OPTION (pfile, print_deps_append) ? "a" : "w";
1049
1050 if (CPP_OPTION (pfile, deps_file)[0] == '\0')
1051 deps_stream = stdout;
1052 else
1053 {
1054 deps_stream = fopen (CPP_OPTION (pfile, deps_file), deps_mode);
1055 if (deps_stream == 0)
1056 {
1057 cpp_errno (pfile, DL_ERROR, CPP_OPTION (pfile, deps_file));
1058 return;
1059 }
1060 }
1061
1062 deps_write (pfile->deps, deps_stream, 72);
1063
1064 if (CPP_OPTION (pfile, deps_phony_targets))
1065 deps_phony_targets (pfile->deps, deps_stream);
1066
1067 /* Don't close stdout. */
1068 if (deps_stream != stdout)
1069 {
1070 if (ferror (deps_stream) || fclose (deps_stream) != 0)
1071 cpp_error (pfile, DL_FATAL, "I/O error on output");
1072 }
1073 }
1074
1075 /* This is called at the end of preprocessing. It pops the
1076 last buffer and writes dependency output. It should also
1077 clear macro definitions, such that you could call cpp_start_read
1078 with a new filename to restart processing. */
1079 void
1080 cpp_finish (pfile)
1081 cpp_reader *pfile;
1082 {
1083 /* cpplex.c leaves the final buffer on the stack. This it so that
1084 it returns an unending stream of CPP_EOFs to the client. If we
1085 popped the buffer, we'd dereference a NULL buffer pointer and
1086 segfault. It's nice to allow the client to do worry-free excess
1087 cpp_get_token calls. */
1088 while (pfile->buffer)
1089 _cpp_pop_buffer (pfile);
1090
1091 /* Don't write the deps file if preprocessing has failed. */
1092 if (CPP_OPTION (pfile, print_deps) && pfile->errors == 0)
1093 output_deps (pfile);
1094
1095 /* Report on headers that could use multiple include guards. */
1096 if (CPP_OPTION (pfile, print_include_names))
1097 _cpp_report_missing_guards (pfile);
1098 }
1099
1100 /* Add a directive to be handled later in the initialization phase. */
1101 static void
1102 new_pending_directive (pend, text, handler)
1103 struct cpp_pending *pend;
1104 const char *text;
1105 cl_directive_handler handler;
1106 {
1107 struct pending_option *o = (struct pending_option *)
1108 xmalloc (sizeof (struct pending_option));
1109
1110 o->arg = text;
1111 o->next = NULL;
1112 o->handler = handler;
1113 APPEND (pend, directive, o);
1114 }
1115
1116 /* Irix6 "cc -n32" and OSF4 cc have problems with char foo[] = ("string");
1117 I.e. a const string initializer with parens around it. That is
1118 what N_("string") resolves to, so we make no_* be macros instead. */
1119 #define no_arg N_("argument missing after %s")
1120 #define no_ass N_("assertion missing after %s")
1121 #define no_dir N_("directory name missing after %s")
1122 #define no_fil N_("file name missing after %s")
1123 #define no_mac N_("macro name missing after %s")
1124 #define no_pth N_("path name missing after %s")
1125 #define no_num N_("number missing after %s")
1126 #define no_tgt N_("target missing after %s")
1127
1128 /* This is the list of all command line options, with the leading
1129 "-" removed. It must be sorted in ASCII collating order. */
1130 #define COMMAND_LINE_OPTIONS \
1131 DEF_OPT("$", 0, OPT_dollar) \
1132 DEF_OPT("-help", 0, OPT__help) \
1133 DEF_OPT("-target-help", 0, OPT_target__help) \
1134 DEF_OPT("-version", 0, OPT__version) \
1135 DEF_OPT("A", no_ass, OPT_A) \
1136 DEF_OPT("C", 0, OPT_C) \
1137 DEF_OPT("CC", 0, OPT_CC) \
1138 DEF_OPT("D", no_mac, OPT_D) \
1139 DEF_OPT("H", 0, OPT_H) \
1140 DEF_OPT("I", no_dir, OPT_I) \
1141 DEF_OPT("M", 0, OPT_M) \
1142 DEF_OPT("MD", no_fil, OPT_MD) \
1143 DEF_OPT("MF", no_fil, OPT_MF) \
1144 DEF_OPT("MG", 0, OPT_MG) \
1145 DEF_OPT("MM", 0, OPT_MM) \
1146 DEF_OPT("MMD", no_fil, OPT_MMD) \
1147 DEF_OPT("MP", 0, OPT_MP) \
1148 DEF_OPT("MQ", no_tgt, OPT_MQ) \
1149 DEF_OPT("MT", no_tgt, OPT_MT) \
1150 DEF_OPT("P", 0, OPT_P) \
1151 DEF_OPT("U", no_mac, OPT_U) \
1152 DEF_OPT("W", no_arg, OPT_W) /* arg optional */ \
1153 DEF_OPT("d", no_arg, OPT_d) \
1154 DEF_OPT("fno-operator-names", 0, OPT_fno_operator_names) \
1155 DEF_OPT("fno-preprocessed", 0, OPT_fno_preprocessed) \
1156 DEF_OPT("fno-show-column", 0, OPT_fno_show_column) \
1157 DEF_OPT("fpreprocessed", 0, OPT_fpreprocessed) \
1158 DEF_OPT("fshow-column", 0, OPT_fshow_column) \
1159 DEF_OPT("fsigned-char", 0, OPT_fsigned_char) \
1160 DEF_OPT("ftabstop=", no_num, OPT_ftabstop) \
1161 DEF_OPT("funsigned-char", 0, OPT_funsigned_char) \
1162 DEF_OPT("h", 0, OPT_h) \
1163 DEF_OPT("idirafter", no_dir, OPT_idirafter) \
1164 DEF_OPT("imacros", no_fil, OPT_imacros) \
1165 DEF_OPT("include", no_fil, OPT_include) \
1166 DEF_OPT("iprefix", no_pth, OPT_iprefix) \
1167 DEF_OPT("isystem", no_dir, OPT_isystem) \
1168 DEF_OPT("iwithprefix", no_dir, OPT_iwithprefix) \
1169 DEF_OPT("iwithprefixbefore", no_dir, OPT_iwithprefixbefore) \
1170 DEF_OPT("lang-asm", 0, OPT_lang_asm) \
1171 DEF_OPT("lang-c", 0, OPT_lang_c) \
1172 DEF_OPT("lang-c++", 0, OPT_lang_cplusplus) \
1173 DEF_OPT("lang-c89", 0, OPT_lang_c89) \
1174 DEF_OPT("lang-objc", 0, OPT_lang_objc) \
1175 DEF_OPT("nostdinc", 0, OPT_nostdinc) \
1176 DEF_OPT("nostdinc++", 0, OPT_nostdincplusplus) \
1177 DEF_OPT("o", no_fil, OPT_o) \
1178 DEF_OPT("pedantic", 0, OPT_pedantic) \
1179 DEF_OPT("pedantic-errors", 0, OPT_pedantic_errors) \
1180 DEF_OPT("remap", 0, OPT_remap) \
1181 DEF_OPT("std=c++98", 0, OPT_std_cplusplus98) \
1182 DEF_OPT("std=c89", 0, OPT_std_c89) \
1183 DEF_OPT("std=c99", 0, OPT_std_c99) \
1184 DEF_OPT("std=c9x", 0, OPT_std_c9x) \
1185 DEF_OPT("std=gnu89", 0, OPT_std_gnu89) \
1186 DEF_OPT("std=gnu99", 0, OPT_std_gnu99) \
1187 DEF_OPT("std=gnu9x", 0, OPT_std_gnu9x) \
1188 DEF_OPT("std=iso9899:1990", 0, OPT_std_iso9899_1990) \
1189 DEF_OPT("std=iso9899:199409", 0, OPT_std_iso9899_199409) \
1190 DEF_OPT("std=iso9899:1999", 0, OPT_std_iso9899_1999) \
1191 DEF_OPT("std=iso9899:199x", 0, OPT_std_iso9899_199x) \
1192 DEF_OPT("traditional-cpp", 0, OPT_traditional_cpp) \
1193 DEF_OPT("trigraphs", 0, OPT_trigraphs) \
1194 DEF_OPT("v", 0, OPT_v) \
1195 DEF_OPT("version", 0, OPT_version) \
1196 DEF_OPT("w", 0, OPT_w)
1197
1198 #define DEF_OPT(text, msg, code) code,
1199 enum opt_code
1200 {
1201 COMMAND_LINE_OPTIONS
1202 N_OPTS
1203 };
1204 #undef DEF_OPT
1205
1206 struct cl_option
1207 {
1208 const char *opt_text;
1209 const char *msg;
1210 size_t opt_len;
1211 enum opt_code opt_code;
1212 };
1213
1214 #define DEF_OPT(text, msg, code) { text, msg, sizeof(text) - 1, code },
1215 #ifdef HOST_EBCDIC
1216 static struct cl_option cl_options[] =
1217 #else
1218 static const struct cl_option cl_options[] =
1219 #endif
1220 {
1221 COMMAND_LINE_OPTIONS
1222 };
1223 #undef DEF_OPT
1224 #undef COMMAND_LINE_OPTIONS
1225
1226 /* Perform a binary search to find which, if any, option the given
1227 command-line matches. Returns its index in the option array,
1228 negative on failure. Complications arise since some options can be
1229 suffixed with an argument, and multiple complete matches can occur,
1230 e.g. -iwithprefix and -iwithprefixbefore. Moreover, we need to
1231 accept options beginning with -W that we do not recognise, but not
1232 to swallow any subsequent command line argument; this is handled as
1233 special cases in cpp_handle_option. */
1234 static int
1235 parse_option (input)
1236 const char *input;
1237 {
1238 unsigned int md, mn, mx;
1239 size_t opt_len;
1240 int comp;
1241
1242 mn = 0;
1243 mx = N_OPTS;
1244
1245 while (mx > mn)
1246 {
1247 md = (mn + mx) / 2;
1248
1249 opt_len = cl_options[md].opt_len;
1250 comp = memcmp (input, cl_options[md].opt_text, opt_len);
1251
1252 if (comp > 0)
1253 mn = md + 1;
1254 else if (comp < 0)
1255 mx = md;
1256 else
1257 {
1258 if (input[opt_len] == '\0')
1259 return md;
1260 /* We were passed more text. If the option takes an argument,
1261 we may match a later option or we may have been passed the
1262 argument. The longest possible option match succeeds.
1263 If the option takes no arguments we have not matched and
1264 continue the search (e.g. input="stdc++" match was "stdc"). */
1265 mn = md + 1;
1266 if (cl_options[md].msg)
1267 {
1268 /* Scan forwards. If we get an exact match, return it.
1269 Otherwise, return the longest option-accepting match.
1270 This loops no more than twice with current options. */
1271 mx = md;
1272 for (; mn < (unsigned int) N_OPTS; mn++)
1273 {
1274 opt_len = cl_options[mn].opt_len;
1275 if (memcmp (input, cl_options[mn].opt_text, opt_len))
1276 break;
1277 if (input[opt_len] == '\0')
1278 return mn;
1279 if (cl_options[mn].msg)
1280 mx = mn;
1281 }
1282 return mx;
1283 }
1284 }
1285 }
1286
1287 return -1;
1288 }
1289
1290 /* Handle one command-line option in (argc, argv).
1291 Can be called multiple times, to handle multiple sets of options.
1292 If ignore is non-zero, this will ignore unrecognized -W* options.
1293 Returns number of strings consumed. */
1294 int
1295 cpp_handle_option (pfile, argc, argv, ignore)
1296 cpp_reader *pfile;
1297 int argc;
1298 char **argv;
1299 int ignore;
1300 {
1301 int i = 0;
1302 struct cpp_pending *pend = CPP_OPTION (pfile, pending);
1303
1304 /* Interpret "-" or a non-option as a file name. */
1305 if (argv[i][0] != '-' || argv[i][1] == '\0')
1306 {
1307 if (CPP_OPTION (pfile, in_fname) == NULL)
1308 CPP_OPTION (pfile, in_fname) = argv[i];
1309 else if (CPP_OPTION (pfile, out_fname) == NULL)
1310 CPP_OPTION (pfile, out_fname) = argv[i];
1311 else
1312 cpp_error (pfile, DL_FATAL,
1313 "too many filenames. Type %s --help for usage info",
1314 progname);
1315 }
1316 else
1317 {
1318 enum opt_code opt_code;
1319 int opt_index;
1320 const char *arg = 0;
1321
1322 /* Skip over '-'. */
1323 opt_index = parse_option (&argv[i][1]);
1324 if (opt_index < 0)
1325 return i;
1326
1327 opt_code = cl_options[opt_index].opt_code;
1328 if (cl_options[opt_index].msg)
1329 {
1330 arg = &argv[i][cl_options[opt_index].opt_len + 1];
1331
1332 /* Yuk. Special case for -W as it must not swallow
1333 up any following argument. If this becomes common, add
1334 another field to the cl_options table. */
1335 if (arg[0] == '\0' && opt_code != OPT_W)
1336 {
1337 arg = argv[++i];
1338 if (!arg)
1339 {
1340 cpp_error (pfile, DL_FATAL,
1341 cl_options[opt_index].msg, argv[i - 1]);
1342 return argc;
1343 }
1344 }
1345 }
1346
1347 switch (opt_code)
1348 {
1349 case N_OPTS: /* Shut GCC up. */
1350 break;
1351 case OPT_fno_operator_names:
1352 CPP_OPTION (pfile, operator_names) = 0;
1353 break;
1354 case OPT_fpreprocessed:
1355 CPP_OPTION (pfile, preprocessed) = 1;
1356 break;
1357 case OPT_fno_preprocessed:
1358 CPP_OPTION (pfile, preprocessed) = 0;
1359 break;
1360 case OPT_fshow_column:
1361 CPP_OPTION (pfile, show_column) = 1;
1362 break;
1363 case OPT_fno_show_column:
1364 CPP_OPTION (pfile, show_column) = 0;
1365 break;
1366 case OPT_fsigned_char:
1367 CPP_OPTION (pfile, unsigned_char) = 0;
1368 break;
1369 case OPT_funsigned_char:
1370 CPP_OPTION (pfile, unsigned_char) = 1;
1371 break;
1372 case OPT_ftabstop:
1373 /* Silently ignore empty string, non-longs and silly values. */
1374 if (arg[0] != '\0')
1375 {
1376 char *endptr;
1377 long tabstop = strtol (arg, &endptr, 10);
1378 if (*endptr == '\0' && tabstop >= 1 && tabstop <= 100)
1379 CPP_OPTION (pfile, tabstop) = tabstop;
1380 }
1381 break;
1382 case OPT_w:
1383 CPP_OPTION (pfile, inhibit_warnings) = 1;
1384 break;
1385 case OPT_h:
1386 case OPT__help:
1387 print_help ();
1388 CPP_OPTION (pfile, help_only) = 1;
1389 break;
1390 case OPT_target__help:
1391 /* Print if any target specific options. cpplib has none, but
1392 make sure help_only gets set. */
1393 CPP_OPTION (pfile, help_only) = 1;
1394 break;
1395
1396 /* --version inhibits compilation, -version doesn't. -v means
1397 verbose and -version. Historical reasons, don't ask. */
1398 case OPT__version:
1399 CPP_OPTION (pfile, help_only) = 1;
1400 pfile->print_version = 1;
1401 break;
1402 case OPT_v:
1403 CPP_OPTION (pfile, verbose) = 1;
1404 pfile->print_version = 1;
1405 break;
1406 case OPT_version:
1407 pfile->print_version = 1;
1408 break;
1409
1410 case OPT_C:
1411 CPP_OPTION (pfile, discard_comments) = 0;
1412 break;
1413 case OPT_CC:
1414 CPP_OPTION (pfile, discard_comments) = 0;
1415 CPP_OPTION (pfile, discard_comments_in_macro_exp) = 0;
1416 break;
1417 case OPT_P:
1418 CPP_OPTION (pfile, no_line_commands) = 1;
1419 break;
1420 case OPT_dollar: /* Don't include $ in identifiers. */
1421 CPP_OPTION (pfile, dollars_in_ident) = 0;
1422 break;
1423 case OPT_H:
1424 CPP_OPTION (pfile, print_include_names) = 1;
1425 break;
1426 case OPT_D:
1427 new_pending_directive (pend, arg, cpp_define);
1428 break;
1429 case OPT_pedantic_errors:
1430 CPP_OPTION (pfile, pedantic_errors) = 1;
1431 /* fall through */
1432 case OPT_pedantic:
1433 CPP_OPTION (pfile, pedantic) = 1;
1434 CPP_OPTION (pfile, warn_endif_labels) = 1;
1435 break;
1436 case OPT_trigraphs:
1437 CPP_OPTION (pfile, trigraphs) = 1;
1438 break;
1439 case OPT_remap:
1440 CPP_OPTION (pfile, remap) = 1;
1441 break;
1442 case OPT_traditional_cpp:
1443 CPP_OPTION (pfile, traditional) = 1;
1444 break;
1445 case OPT_iprefix:
1446 CPP_OPTION (pfile, include_prefix) = arg;
1447 CPP_OPTION (pfile, include_prefix_len) = strlen (arg);
1448 break;
1449 case OPT_lang_c:
1450 set_lang (pfile, CLK_GNUC89);
1451 break;
1452 case OPT_lang_cplusplus:
1453 set_lang (pfile, CLK_GNUCXX);
1454 break;
1455 case OPT_lang_objc:
1456 CPP_OPTION (pfile, objc) = 1;
1457 break;
1458 case OPT_lang_asm:
1459 set_lang (pfile, CLK_ASM);
1460 break;
1461 case OPT_std_cplusplus98:
1462 set_lang (pfile, CLK_CXX98);
1463 break;
1464 case OPT_std_gnu89:
1465 set_lang (pfile, CLK_GNUC89);
1466 break;
1467 case OPT_std_gnu9x:
1468 case OPT_std_gnu99:
1469 set_lang (pfile, CLK_GNUC99);
1470 break;
1471 case OPT_std_iso9899_199409:
1472 set_lang (pfile, CLK_STDC94);
1473 break;
1474 case OPT_std_iso9899_1990:
1475 case OPT_std_c89:
1476 case OPT_lang_c89:
1477 set_lang (pfile, CLK_STDC89);
1478 break;
1479 case OPT_std_iso9899_199x:
1480 case OPT_std_iso9899_1999:
1481 case OPT_std_c9x:
1482 case OPT_std_c99:
1483 set_lang (pfile, CLK_STDC99);
1484 break;
1485 case OPT_nostdinc:
1486 /* -nostdinc causes no default include directories.
1487 You must specify all include-file directories with -I. */
1488 CPP_OPTION (pfile, no_standard_includes) = 1;
1489 break;
1490 case OPT_nostdincplusplus:
1491 /* -nostdinc++ causes no default C++-specific include directories. */
1492 CPP_OPTION (pfile, no_standard_cplusplus_includes) = 1;
1493 break;
1494 case OPT_o:
1495 if (CPP_OPTION (pfile, out_fname) == NULL)
1496 CPP_OPTION (pfile, out_fname) = arg;
1497 else
1498 {
1499 cpp_error (pfile, DL_FATAL, "output filename specified twice");
1500 return argc;
1501 }
1502 break;
1503 case OPT_d:
1504 /* Args to -d specify what parts of macros to dump.
1505 Silently ignore unrecognised options; they may
1506 be aimed at the compiler proper. */
1507 {
1508 char c;
1509
1510 while ((c = *arg++) != '\0')
1511 switch (c)
1512 {
1513 case 'M':
1514 CPP_OPTION (pfile, dump_macros) = dump_only;
1515 break;
1516 case 'N':
1517 CPP_OPTION (pfile, dump_macros) = dump_names;
1518 break;
1519 case 'D':
1520 CPP_OPTION (pfile, dump_macros) = dump_definitions;
1521 break;
1522 case 'I':
1523 CPP_OPTION (pfile, dump_includes) = 1;
1524 break;
1525 }
1526 }
1527 break;
1528
1529 case OPT_MG:
1530 CPP_OPTION (pfile, print_deps_missing_files) = 1;
1531 break;
1532 case OPT_M:
1533 /* When doing dependencies with -M or -MM, suppress normal
1534 preprocessed output, but still do -dM etc. as software
1535 depends on this. Preprocessed output occurs if -MD, -MMD
1536 or environment var dependency generation is used. */
1537 CPP_OPTION (pfile, print_deps) = 2;
1538 CPP_OPTION (pfile, no_output) = 1;
1539 break;
1540 case OPT_MM:
1541 CPP_OPTION (pfile, print_deps) = 1;
1542 CPP_OPTION (pfile, no_output) = 1;
1543 break;
1544 case OPT_MF:
1545 CPP_OPTION (pfile, deps_file) = arg;
1546 break;
1547 case OPT_MP:
1548 CPP_OPTION (pfile, deps_phony_targets) = 1;
1549 break;
1550 case OPT_MQ:
1551 case OPT_MT:
1552 /* Add a target. -MQ quotes for Make. */
1553 deps_add_target (pfile->deps, arg, opt_code == OPT_MQ);
1554 break;
1555
1556 case OPT_MD:
1557 CPP_OPTION (pfile, print_deps) = 2;
1558 CPP_OPTION (pfile, deps_file) = arg;
1559 break;
1560 case OPT_MMD:
1561 CPP_OPTION (pfile, print_deps) = 1;
1562 CPP_OPTION (pfile, deps_file) = arg;
1563 break;
1564
1565 case OPT_A:
1566 if (arg[0] == '-')
1567 {
1568 /* -A with an argument beginning with '-' acts as
1569 #unassert on whatever immediately follows the '-'.
1570 If "-" is the whole argument, we eliminate all
1571 predefined macros and assertions, including those
1572 that were specified earlier on the command line.
1573 That way we can get rid of any that were passed
1574 automatically in from GCC. */
1575
1576 if (arg[1] == '\0')
1577 {
1578 free_chain (pend->directive_head);
1579 pend->directive_head = NULL;
1580 pend->directive_tail = NULL;
1581 }
1582 else
1583 new_pending_directive (pend, arg + 1, cpp_unassert);
1584 }
1585 else
1586 new_pending_directive (pend, arg, cpp_assert);
1587 break;
1588 case OPT_U:
1589 new_pending_directive (pend, arg, cpp_undef);
1590 break;
1591 case OPT_I: /* Add directory to path for includes. */
1592 if (!strcmp (arg, "-"))
1593 {
1594 /* -I- means:
1595 Use the preceding -I directories for #include "..."
1596 but not #include <...>.
1597 Don't search the directory of the present file
1598 for #include "...". (Note that -I. -I- is not the same as
1599 the default setup; -I. uses the compiler's working dir.) */
1600 if (! CPP_OPTION (pfile, ignore_srcdir))
1601 {
1602 pend->quote_head = pend->brack_head;
1603 pend->quote_tail = pend->brack_tail;
1604 pend->brack_head = 0;
1605 pend->brack_tail = 0;
1606 CPP_OPTION (pfile, ignore_srcdir) = 1;
1607 }
1608 else
1609 {
1610 cpp_error (pfile, DL_FATAL, "-I- specified twice");
1611 return argc;
1612 }
1613 }
1614 else
1615 append_include_chain (pfile, xstrdup (arg), BRACKET, 0);
1616 break;
1617 case OPT_isystem:
1618 /* Add directory to beginning of system include path, as a system
1619 include directory. */
1620 append_include_chain (pfile, xstrdup (arg), SYSTEM, 0);
1621 break;
1622 case OPT_include:
1623 case OPT_imacros:
1624 {
1625 struct pending_option *o = (struct pending_option *)
1626 xmalloc (sizeof (struct pending_option));
1627 o->arg = arg;
1628 o->next = NULL;
1629
1630 if (opt_code == OPT_include)
1631 APPEND (pend, include, o);
1632 else
1633 APPEND (pend, imacros, o);
1634 }
1635 break;
1636 case OPT_iwithprefix:
1637 /* Add directory to end of path for includes,
1638 with the default prefix at the front of its name. */
1639 /* fall through */
1640 case OPT_iwithprefixbefore:
1641 /* Add directory to main path for includes,
1642 with the default prefix at the front of its name. */
1643 {
1644 char *fname;
1645 int len;
1646
1647 len = strlen (arg);
1648
1649 if (CPP_OPTION (pfile, include_prefix) != 0)
1650 {
1651 size_t ipl = CPP_OPTION (pfile, include_prefix_len);
1652 fname = xmalloc (ipl + len + 1);
1653 memcpy (fname, CPP_OPTION (pfile, include_prefix), ipl);
1654 memcpy (fname + ipl, arg, len + 1);
1655 }
1656 else if (cpp_GCC_INCLUDE_DIR_len)
1657 {
1658 fname = xmalloc (cpp_GCC_INCLUDE_DIR_len + len + 1);
1659 memcpy (fname, cpp_GCC_INCLUDE_DIR, cpp_GCC_INCLUDE_DIR_len);
1660 memcpy (fname + cpp_GCC_INCLUDE_DIR_len, arg, len + 1);
1661 }
1662 else
1663 fname = xstrdup (arg);
1664
1665 append_include_chain (pfile, fname,
1666 opt_code == OPT_iwithprefix ? SYSTEM: BRACKET, 0);
1667 }
1668 break;
1669 case OPT_idirafter:
1670 /* Add directory to end of path for includes. */
1671 append_include_chain (pfile, xstrdup (arg), AFTER, 0);
1672 break;
1673 case OPT_W:
1674 /* Silently ignore unrecognised options. */
1675 if (!strcmp (argv[i], "-Wall"))
1676 {
1677 CPP_OPTION (pfile, warn_trigraphs) = 1;
1678 CPP_OPTION (pfile, warn_comments) = 1;
1679 }
1680 else if (!strcmp (argv[i], "-Wtraditional"))
1681 CPP_OPTION (pfile, warn_traditional) = 1;
1682 else if (!strcmp (argv[i], "-Wtrigraphs"))
1683 CPP_OPTION (pfile, warn_trigraphs) = 1;
1684 else if (!strcmp (argv[i], "-Wcomment"))
1685 CPP_OPTION (pfile, warn_comments) = 1;
1686 else if (!strcmp (argv[i], "-Wcomments"))
1687 CPP_OPTION (pfile, warn_comments) = 1;
1688 else if (!strcmp (argv[i], "-Wundef"))
1689 CPP_OPTION (pfile, warn_undef) = 1;
1690 else if (!strcmp (argv[i], "-Wimport"))
1691 CPP_OPTION (pfile, warn_import) = 1;
1692 else if (!strcmp (argv[i], "-Werror"))
1693 CPP_OPTION (pfile, warnings_are_errors) = 1;
1694 else if (!strcmp (argv[i], "-Wsystem-headers"))
1695 CPP_OPTION (pfile, warn_system_headers) = 1;
1696 else if (!strcmp (argv[i], "-Wendif-labels"))
1697 CPP_OPTION (pfile, warn_endif_labels) = 1;
1698 else if (!strcmp (argv[i], "-Wno-traditional"))
1699 CPP_OPTION (pfile, warn_traditional) = 0;
1700 else if (!strcmp (argv[i], "-Wno-trigraphs"))
1701 CPP_OPTION (pfile, warn_trigraphs) = 0;
1702 else if (!strcmp (argv[i], "-Wno-comment"))
1703 CPP_OPTION (pfile, warn_comments) = 0;
1704 else if (!strcmp (argv[i], "-Wno-comments"))
1705 CPP_OPTION (pfile, warn_comments) = 0;
1706 else if (!strcmp (argv[i], "-Wno-undef"))
1707 CPP_OPTION (pfile, warn_undef) = 0;
1708 else if (!strcmp (argv[i], "-Wno-import"))
1709 CPP_OPTION (pfile, warn_import) = 0;
1710 else if (!strcmp (argv[i], "-Wno-error"))
1711 CPP_OPTION (pfile, warnings_are_errors) = 0;
1712 else if (!strcmp (argv[i], "-Wno-system-headers"))
1713 CPP_OPTION (pfile, warn_system_headers) = 0;
1714 else if (!strcmp (argv[i], "-Wno-endif-labels"))
1715 CPP_OPTION (pfile, warn_endif_labels) = 0;
1716 else if (! ignore)
1717 return i;
1718 break;
1719 }
1720 }
1721 return i + 1;
1722 }
1723
1724 /* Handle command-line options in (argc, argv).
1725 Can be called multiple times, to handle multiple sets of options.
1726 Returns if an unrecognized option is seen.
1727 Returns number of strings consumed. */
1728 int
1729 cpp_handle_options (pfile, argc, argv)
1730 cpp_reader *pfile;
1731 int argc;
1732 char **argv;
1733 {
1734 int i;
1735 int strings_processed;
1736
1737 for (i = 0; i < argc; i += strings_processed)
1738 {
1739 strings_processed = cpp_handle_option (pfile, argc - i, argv + i, 1);
1740 if (strings_processed == 0)
1741 break;
1742 }
1743
1744 return i;
1745 }
1746
1747 /* Extra processing when all options are parsed, after all calls to
1748 cpp_handle_option[s]. Consistency checks etc. */
1749 void
1750 cpp_post_options (pfile)
1751 cpp_reader *pfile;
1752 {
1753 if (pfile->print_version)
1754 {
1755 fprintf (stderr, _("GNU CPP version %s (cpplib)"), version_string);
1756 #ifdef TARGET_VERSION
1757 TARGET_VERSION;
1758 #endif
1759 fputc ('\n', stderr);
1760 }
1761
1762 /* Canonicalize in_fname and out_fname. We guarantee they are not
1763 NULL, and that the empty string represents stdin / stdout. */
1764 if (CPP_OPTION (pfile, in_fname) == NULL
1765 || !strcmp (CPP_OPTION (pfile, in_fname), "-"))
1766 CPP_OPTION (pfile, in_fname) = "";
1767
1768 if (CPP_OPTION (pfile, out_fname) == NULL
1769 || !strcmp (CPP_OPTION (pfile, out_fname), "-"))
1770 CPP_OPTION (pfile, out_fname) = "";
1771
1772 /* -Wtraditional is not useful in C++ mode. */
1773 if (CPP_OPTION (pfile, cplusplus))
1774 CPP_OPTION (pfile, warn_traditional) = 0;
1775
1776 /* Permanently disable macro expansion if we are rescanning
1777 preprocessed text. */
1778 if (CPP_OPTION (pfile, preprocessed))
1779 pfile->state.prevent_expansion = 1;
1780
1781 /* -dM makes no normal output. This is set here so that -dM -dD
1782 works as expected. */
1783 if (CPP_OPTION (pfile, dump_macros) == dump_only)
1784 CPP_OPTION (pfile, no_output) = 1;
1785
1786 /* Disable -dD, -dN and -dI if we should make no normal output
1787 (such as with -M). Allow -M -dM since some software relies on
1788 this. */
1789 if (CPP_OPTION (pfile, no_output))
1790 {
1791 if (CPP_OPTION (pfile, dump_macros) != dump_only)
1792 CPP_OPTION (pfile, dump_macros) = dump_none;
1793 CPP_OPTION (pfile, dump_includes) = 0;
1794 }
1795
1796 /* We need to do this after option processing and before
1797 cpp_start_read, as cppmain.c relies on the options->no_output to
1798 set its callbacks correctly before calling cpp_start_read. */
1799 init_dependency_output (pfile);
1800
1801 /* After checking the environment variables, check if -M or -MM has
1802 not been specified, but other -M options have. */
1803 if (CPP_OPTION (pfile, print_deps) == 0 &&
1804 (CPP_OPTION (pfile, print_deps_missing_files)
1805 || CPP_OPTION (pfile, deps_file)
1806 || CPP_OPTION (pfile, deps_phony_targets)))
1807 cpp_error (pfile, DL_FATAL,
1808 "you must additionally specify either -M or -MM");
1809 }
1810
1811 /* Set up dependency-file output. On exit, if print_deps is non-zero
1812 then deps_file is not NULL; stdout is the empty string. */
1813 static void
1814 init_dependency_output (pfile)
1815 cpp_reader *pfile;
1816 {
1817 char *spec, *s, *output_file;
1818
1819 /* Either of two environment variables can specify output of deps.
1820 Its value is either "OUTPUT_FILE" or "OUTPUT_FILE DEPS_TARGET",
1821 where OUTPUT_FILE is the file to write deps info to
1822 and DEPS_TARGET is the target to mention in the deps. */
1823
1824 if (CPP_OPTION (pfile, print_deps) == 0)
1825 {
1826 spec = getenv ("DEPENDENCIES_OUTPUT");
1827 if (spec)
1828 CPP_OPTION (pfile, print_deps) = 1;
1829 else
1830 {
1831 spec = getenv ("SUNPRO_DEPENDENCIES");
1832 if (spec)
1833 CPP_OPTION (pfile, print_deps) = 2;
1834 else
1835 return;
1836 }
1837
1838 /* Find the space before the DEPS_TARGET, if there is one. */
1839 s = strchr (spec, ' ');
1840 if (s)
1841 {
1842 /* Let the caller perform MAKE quoting. */
1843 deps_add_target (pfile->deps, s + 1, 0);
1844 output_file = (char *) xmalloc (s - spec + 1);
1845 memcpy (output_file, spec, s - spec);
1846 output_file[s - spec] = 0;
1847 }
1848 else
1849 output_file = spec;
1850
1851 /* Command line -MF overrides environment variables and default. */
1852 if (CPP_OPTION (pfile, deps_file) == 0)
1853 CPP_OPTION (pfile, deps_file) = output_file;
1854
1855 CPP_OPTION (pfile, print_deps_append) = 1;
1856 }
1857 else if (CPP_OPTION (pfile, deps_file) == 0)
1858 /* If -M or -MM was seen without -MF, default output to wherever
1859 was specified with -o. out_fname is non-NULL here. */
1860 CPP_OPTION (pfile, deps_file) = CPP_OPTION (pfile, out_fname);
1861 }
1862
1863 /* Handle --help output. */
1864 static void
1865 print_help ()
1866 {
1867 /* To keep the lines from getting too long for some compilers, limit
1868 to about 500 characters (6 lines) per chunk. */
1869 fputs (_("\
1870 Switches:\n\
1871 -include <file> Include the contents of <file> before other files\n\
1872 -imacros <file> Accept definition of macros in <file>\n\
1873 -iprefix <path> Specify <path> as a prefix for next two options\n\
1874 -iwithprefix <dir> Add <dir> to the end of the system include path\n\
1875 -iwithprefixbefore <dir> Add <dir> to the end of the main include path\n\
1876 -isystem <dir> Add <dir> to the start of the system include path\n\
1877 "), stdout);
1878 fputs (_("\
1879 -idirafter <dir> Add <dir> to the end of the system include path\n\
1880 -I <dir> Add <dir> to the end of the main include path\n\
1881 -I- Fine-grained include path control; see info docs\n\
1882 -nostdinc Do not search system include directories\n\
1883 (dirs specified with -isystem will still be used)\n\
1884 -nostdinc++ Do not search system include directories for C++\n\
1885 -o <file> Put output into <file>\n\
1886 "), stdout);
1887 fputs (_("\
1888 -pedantic Issue all warnings demanded by strict ISO C\n\
1889 -pedantic-errors Issue -pedantic warnings as errors instead\n\
1890 -trigraphs Support ISO C trigraphs\n\
1891 -lang-c Assume that the input sources are in C\n\
1892 -lang-c89 Assume that the input sources are in C89\n\
1893 "), stdout);
1894 fputs (_("\
1895 -lang-c++ Assume that the input sources are in C++\n\
1896 -lang-objc Assume that the input sources are in ObjectiveC\n\
1897 -lang-asm Assume that the input sources are in assembler\n\
1898 "), stdout);
1899 fputs (_("\
1900 -std=<std name> Specify the conformance standard; one of:\n\
1901 gnu89, gnu99, c89, c99, iso9899:1990,\n\
1902 iso9899:199409, iso9899:1999\n\
1903 -w Inhibit warning messages\n\
1904 -Wtrigraphs Warn if trigraphs are encountered\n\
1905 -Wno-trigraphs Do not warn about trigraphs\n\
1906 -Wcomment{s} Warn if one comment starts inside another\n\
1907 "), stdout);
1908 fputs (_("\
1909 -Wno-comment{s} Do not warn about comments\n\
1910 -Wtraditional Warn about features not present in traditional C\n\
1911 -Wno-traditional Do not warn about traditional C\n\
1912 -Wundef Warn if an undefined macro is used by #if\n\
1913 -Wno-undef Do not warn about testing undefined macros\n\
1914 -Wimport Warn about the use of the #import directive\n\
1915 "), stdout);
1916 fputs (_("\
1917 -Wno-import Do not warn about the use of #import\n\
1918 -Werror Treat all warnings as errors\n\
1919 -Wno-error Do not treat warnings as errors\n\
1920 -Wsystem-headers Do not suppress warnings from system headers\n\
1921 -Wno-system-headers Suppress warnings from system headers\n\
1922 -Wall Enable all preprocessor warnings\n\
1923 "), stdout);
1924 fputs (_("\
1925 -M Generate make dependencies\n\
1926 -MM As -M, but ignore system header files\n\
1927 -MD Generate make dependencies and compile\n\
1928 -MMD As -MD, but ignore system header files\n\
1929 -MF <file> Write dependency output to the given file\n\
1930 -MG Treat missing header file as generated files\n\
1931 "), stdout);
1932 fputs (_("\
1933 -MP Generate phony targets for all headers\n\
1934 -MQ <target> Add a MAKE-quoted target\n\
1935 -MT <target> Add an unquoted target\n\
1936 "), stdout);
1937 fputs (_("\
1938 -D<macro> Define a <macro> with string '1' as its value\n\
1939 -D<macro>=<val> Define a <macro> with <val> as its value\n\
1940 -A<question>=<answer> Assert the <answer> to <question>\n\
1941 -A-<question>=<answer> Disable the <answer> to <question>\n\
1942 -U<macro> Undefine <macro> \n\
1943 -v Display the version number\n\
1944 "), stdout);
1945 fputs (_("\
1946 -H Print the name of header files as they are used\n\
1947 -C Do not discard comments\n\
1948 -dM Display a list of macro definitions active at end\n\
1949 -dD Preserve macro definitions in output\n\
1950 -dN As -dD except that only the names are preserved\n\
1951 -dI Include #include directives in the output\n\
1952 "), stdout);
1953 fputs (_("\
1954 -fpreprocessed Treat the input file as already preprocessed\n\
1955 -ftabstop=<number> Distance between tab stops for column reporting\n\
1956 -P Do not generate #line directives\n\
1957 -$ Do not allow '$' in identifiers\n\
1958 -remap Remap file names when including files\n\
1959 --version Display version information\n\
1960 -h or --help Display this information\n\
1961 "), stdout);
1962 }
This page took 0.1295 seconds and 6 git commands to generate.