2 Copyright (C) 1986, 1987, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
3 1999, 2000 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
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. */
32 /* `struct directive' defines one #-directive, including how to handle it. */
36 directive_handler func
; /* Function to handle directive. */
37 const char *name
; /* Name of directive. */
38 unsigned short length
; /* Length of name. */
39 unsigned short flags
; /* Flags describing this directive. */
42 /* Stack of conditionals currently in progress
43 (including both successful and failing conditionals). */
47 struct if_stack
*next
;
48 int lineno
; /* line number where condition started */
49 int if_succeeded
; /* truth of last condition in this group */
50 const U_CHAR
*control_macro
; /* macro name for #ifndef around entire file */
51 int type
; /* type of last directive seen in this group */
53 typedef struct if_stack IF_STACK
;
55 /* Forward declarations. */
57 static void validate_else
PARAMS ((cpp_reader
*, const char *));
58 static int parse_ifdef
PARAMS ((cpp_reader
*, const char *));
59 static unsigned int parse_include
PARAMS ((cpp_reader
*, const char *));
60 static int conditional_skip
PARAMS ((cpp_reader
*, int, int,
62 static int skip_if_group
PARAMS ((cpp_reader
*));
63 static void pass_thru_directive
PARAMS ((const U_CHAR
*, size_t,
65 static int read_line_number
PARAMS ((cpp_reader
*, int *));
66 static U_CHAR
*detect_if_not_defined
PARAMS ((cpp_reader
*));
67 static int consider_directive_while_skipping
68 PARAMS ((cpp_reader
*, IF_STACK
*));
70 /* Values for the flags field of the table below. KANDR and COND
71 directives come from traditional (K&R) C. The difference is, if we
72 care about it while skipping a failed conditional block, its origin
73 is COND. STDC89 directives come from the 1989 C standard.
74 EXTENSION directives are extensions, with origins noted below. */
82 #define ORIGIN(f) ((f) & ORIGIN_MASK)
83 #define TRAD_DIRECT_P(f) (ORIGIN (f) == KANDR || ORIGIN (f) == COND)
85 /* This is the table of directive handlers. It is ordered by
86 frequency of occurrence; the numbers at the end are directive
87 counts from all the source code I have lying around (egcs and libc
88 CVS as of 1999-05-18, plus grub-0.5.91, linux-2.2.9, and
91 The entries with a dash and a name after the count are extensions,
92 of which all but #warning and #include_next are deprecated. The name
93 is where the extension appears to have come from. */
95 /* #sccs is not always recognized. */
97 # define SCCS_ENTRY D(sccs, T_SCCS, EXTENSION) /* 0 - SVR2? */
99 # define SCCS_ENTRY /* nothing */
102 #define DIRECTIVE_TABLE \
103 D(define, T_DEFINE = 0, KANDR) /* 270554 */ \
104 D(include, T_INCLUDE, KANDR | SYNTAX_INCLUDE) /* 52262 */ \
105 D(endif, T_ENDIF, COND) /* 45855 */ \
106 D(ifdef, T_IFDEF, COND) /* 22000 */ \
107 D(if, T_IF, COND) /* 18162 */ \
108 D(else, T_ELSE, COND) /* 9863 */ \
109 D(ifndef, T_IFNDEF, COND) /* 9675 */ \
110 D(undef, T_UNDEF, KANDR) /* 4837 */ \
111 D(line, T_LINE, KANDR) /* 2465 */ \
112 D(elif, T_ELIF, COND) /* 610 */ \
113 D(error, T_ERROR, STDC89) /* 475 */ \
114 D(pragma, T_PRAGMA, STDC89) /* 195 */ \
115 D(warning, T_WARNING, EXTENSION) /* 22 GNU */ \
116 D(include_next, T_INCLUDE_NEXT, EXTENSION | SYNTAX_INCLUDE) /* 19 GNU */ \
117 D(ident, T_IDENT, EXTENSION) /* 11 SVR4 */ \
118 D(import, T_IMPORT, EXTENSION | SYNTAX_INCLUDE) /* 0 ObjC */ \
119 D(assert, T_ASSERT, EXTENSION | SYNTAX_ASSERT) /* 0 SVR4 */ \
120 D(unassert, T_UNASSERT, EXTENSION | SYNTAX_ASSERT) /* 0 SVR4 */ \
123 /* Use the table to generate a series of prototypes, an enum for the
124 directive names, and an array of directive handlers. */
126 /* The directive-processing functions are declared to return int
127 instead of void, because some old compilers have trouble with
128 pointers to functions returning void. */
130 /* Don't invoke CONCAT2 with any whitespace or K&R cc will fail. */
131 #define D(name, t, f) static int CONCAT2(do_,name) PARAMS ((cpp_reader *));
135 #define D(n, tag, f) tag,
143 /* Don't invoke CONCAT2 with any whitespace or K&R cc will fail. */
144 #define D(name, t, flags) \
145 { CONCAT2(do_,name), STRINGX(name), sizeof STRINGX(name) - 1, flags },
146 static const struct directive dtable
[] =
151 #undef DIRECTIVE_TABLE
153 /* Check if a token's name matches that of a known directive. Put in
154 this file to save exporting dtable and other unneeded information. */
156 _cpp_check_directive (list
, token
)
160 const char *name
= list
->namebuf
+ token
->val
.name
.offset
;
161 size_t len
= token
->val
.name
.len
;
164 list
->dir_handler
= 0;
167 for (i
= 0; i
< N_DIRECTIVES
; i
++)
168 if (dtable
[i
].length
== len
&& !strncmp (dtable
[i
].name
, name
, len
))
170 list
->dir_handler
= dtable
[i
].func
;
171 list
->dir_flags
= dtable
[i
].flags
;
176 /* Handle a possible # directive.
177 '#' has already been read. */
180 _cpp_handle_directive (pfile
)
187 long old_written
= CPP_WRITTEN (pfile
);
190 if (CPP_IS_MACRO_BUFFER (CPP_BUFFER (pfile
)))
192 cpp_ice (pfile
, "handle_directive called on macro buffer");
196 /* -traditional directives are recognized only with the # in column 1. */
197 hash_at_bol
= CPP_IN_COLUMN_1 (pfile
);
199 /* Scan the next token, then pretend we didn't. */
200 CPP_SET_MARK (pfile
);
201 pfile
->no_macro_expand
++;
202 tok
= _cpp_get_directive_token (pfile
);
203 pfile
->no_macro_expand
--;
205 ident
= pfile
->token_buffer
+ old_written
;
206 len
= CPP_PWRITTEN (pfile
) - ident
;
207 CPP_SET_WRITTEN (pfile
, old_written
);
208 CPP_GOTO_MARK (pfile
);
210 /* # followed by a number is equivalent to #line. Do not recognize
211 this form in assembly language source files. Complain about this
212 form if we're being pedantic, but not if this is regurgitated
213 input (preprocessed or fed back in by the C++ frontend). */
214 if (tok
== CPP_NUMBER
)
216 if (CPP_OPTION (pfile
, lang_asm
))
219 if (CPP_PEDANTIC (pfile
)
220 && ! CPP_OPTION (pfile
, preprocessed
)
221 && ! CPP_BUFFER (pfile
)->manual_pop
)
222 cpp_pedwarn (pfile
, "# followed by integer");
227 /* If we are rescanning preprocessed input, don't obey any directives
229 else if (CPP_OPTION (pfile
, preprocessed
))
232 /* A line of just # becomes blank. */
233 else if (tok
== CPP_VSPACE
)
236 /* A NAME token might in fact be a directive! */
237 else if (tok
== CPP_NAME
)
239 for (i
= 0; i
< N_DIRECTIVES
; i
++)
241 if (dtable
[i
].length
== len
242 && !strncmp (dtable
[i
].name
, ident
, len
))
245 /* Don't complain about invalid directives in assembly source,
246 we don't know where the comments are, and # may introduce
247 assembler pseudo-ops. */
248 if (!CPP_OPTION (pfile
, lang_asm
))
249 cpp_error (pfile
, "invalid preprocessing directive #%s", ident
);
252 /* And anything else means the # wasn't a directive marker. */
258 /* In -traditional mode, a directive is ignored unless its # is in
260 if (CPP_TRADITIONAL (pfile
) && !hash_at_bol
)
262 if (CPP_WTRADITIONAL (pfile
))
263 cpp_warning (pfile
, "ignoring #%s because of its indented #",
268 /* no_directives is set when we are parsing macro arguments. Directives
269 in macro arguments are undefined behavior (C99 6.10.3.11); this
270 implementation chooses to make them hard errors. */
271 if (pfile
->no_directives
)
273 cpp_error (pfile
, "#%s may not be used inside a macro argument",
275 _cpp_skip_rest_of_line (pfile
);
279 /* Issue -pedantic warnings for extended directives. */
280 if (CPP_PEDANTIC (pfile
) && ORIGIN (dtable
[i
].flags
) == EXTENSION
)
281 cpp_pedwarn (pfile
, "ISO C does not allow #%s", dtable
[i
].name
);
283 /* -Wtraditional gives warnings about directives with inappropriate
285 if (CPP_WTRADITIONAL (pfile
))
287 if (!hash_at_bol
&& TRAD_DIRECT_P (dtable
[i
].flags
))
288 cpp_warning (pfile
, "traditional C ignores #%s with the # indented",
290 else if (hash_at_bol
&& ! TRAD_DIRECT_P (dtable
[i
].flags
))
292 "suggest hiding #%s from traditional C with an indented #",
296 /* Unfortunately, it's necessary to scan the directive name again,
297 now we know we're going to consume it. FIXME. */
299 pfile
->no_macro_expand
++;
300 _cpp_get_directive_token (pfile
);
301 pfile
->no_macro_expand
--;
302 CPP_SET_WRITTEN (pfile
, old_written
);
304 /* Some directives (e.g. #if) may return a request to execute
305 another directive handler immediately. No directive ever
306 requests that #define be executed immediately, so it is safe for
307 the loop to terminate when some function returns 0 (== T_DEFINE). */
308 while ((i
= dtable
[i
].func (pfile
)));
312 /* Pass a directive through to the output file.
313 BUF points to the contents of the directive, as a contiguous string.
314 LEN is the length of the string pointed to by BUF.
315 KEYWORD is the keyword-table entry for the directive. */
318 pass_thru_directive (buf
, len
, pfile
, keyword
)
324 const struct directive
*kt
= &dtable
[keyword
];
325 register unsigned klen
= kt
->length
;
327 CPP_RESERVE (pfile
, 1 + klen
+ len
);
328 CPP_PUTC_Q (pfile
, '#');
329 CPP_PUTS_Q (pfile
, kt
->name
, klen
);
330 if (len
!= 0 && buf
[0] != ' ')
331 CPP_PUTC_Q (pfile
, ' ');
332 CPP_PUTS_Q (pfile
, buf
, len
);
335 /* Process a #define command. */
345 cpp_toklist
*list
= &pfile
->directbuf
;
347 pfile
->no_macro_expand
++;
348 pfile
->parsing_define_directive
++;
349 CPP_OPTION (pfile
, discard_comments
)++;
351 _cpp_scan_line (pfile
, list
);
353 /* First token on the line must be a NAME. There must be at least
354 one token (the VSPACE at the end). */
355 if (list
->tokens
[0].type
!= CPP_NAME
)
357 cpp_error_with_line (pfile
, list
->line
, list
->tokens
[0].col
,
358 "#define must be followed by an identifier");
362 sym
= list
->namebuf
+ list
->tokens
[0].val
.name
.offset
;
363 len
= list
->tokens
[0].val
.name
.len
;
365 /* That NAME is not allowed to be "defined". (Not clear if the
366 standard requires this.) */
367 if (len
== 7 && !strncmp (sym
, "defined", 7))
369 cpp_error_with_line (pfile
, list
->line
, list
->tokens
[0].col
,
370 "\"defined\" is not a legal macro name");
374 slot
= _cpp_lookup_slot (pfile
, sym
, len
, INSERT
, &hash
);
377 /* Check for poisoned identifiers now. All other checks
378 are done in cpphash.c. */
379 if ((*slot
)->type
== T_POISON
)
381 cpp_error (pfile
, "redefining poisoned `%.*s'", len
, sym
);
386 *slot
= _cpp_make_hashnode (sym
, len
, T_VOID
, hash
);
388 if (_cpp_create_definition (pfile
, list
, *slot
) == 0)
391 if (CPP_OPTION (pfile
, debug_output
)
392 || CPP_OPTION (pfile
, dump_macros
) == dump_definitions
)
393 _cpp_dump_definition (pfile
, *slot
);
394 else if (CPP_OPTION (pfile
, dump_macros
) == dump_names
)
395 pass_thru_directive (sym
, len
, pfile
, T_DEFINE
);
398 pfile
->no_macro_expand
--;
399 pfile
->parsing_define_directive
--;
400 CPP_OPTION (pfile
, discard_comments
)--;
404 /* Handle #include and #import. */
407 parse_include (pfile
, name
)
411 long old_written
= CPP_WRITTEN (pfile
);
412 enum cpp_ttype token
;
415 pfile
->parsing_include_directive
++;
416 token
= _cpp_get_directive_token (pfile
);
417 pfile
->parsing_include_directive
--;
419 len
= CPP_WRITTEN (pfile
) - old_written
;
421 if (token
== CPP_STRING
)
422 ; /* No special treatment required. */
424 else if (token
== CPP_NAME
)
426 /* Support '#include xyz' like VAX-C. It is taken as
427 '#include <xyz.h>' and generates a warning. */
428 cpp_warning (pfile
, "#%s filename is obsolete, use #%s <filename.h>",
431 /* Rewrite the token to <xyz.h>. */
432 CPP_RESERVE (pfile
, 4);
434 memmove (pfile
->token_buffer
+ old_written
+ 1,
435 pfile
->token_buffer
+ old_written
,
436 CPP_WRITTEN (pfile
) - old_written
);
437 pfile
->token_buffer
[old_written
] = '<';
438 CPP_PUTS_Q (pfile
, ".h>", 2);
443 cpp_error (pfile
, "`#%s' expects \"FILENAME\" or <FILENAME>", name
);
444 CPP_SET_WRITTEN (pfile
, old_written
);
445 _cpp_skip_rest_of_line (pfile
);
449 if (_cpp_get_directive_token (pfile
) != CPP_VSPACE
)
451 cpp_error (pfile
, "junk at end of `#%s'", name
);
452 _cpp_skip_rest_of_line (pfile
);
455 CPP_SET_WRITTEN (pfile
, old_written
);
458 cpp_error (pfile
, "empty file name in `#%s'", name
);
470 len
= parse_include (pfile
, dtable
[T_INCLUDE
].name
);
473 token
= alloca (len
+ 1);
474 memcpy (token
, CPP_PWRITTEN (pfile
), len
);
477 if (CPP_OPTION (pfile
, dump_includes
))
478 pass_thru_directive (token
, len
, pfile
, T_INCLUDE
);
480 _cpp_execute_include (pfile
, token
, len
, 0, 0);
491 if (CPP_OPTION (pfile
, warn_import
)
492 && !CPP_BUFFER (pfile
)->system_header_p
&& !pfile
->import_warning
)
494 pfile
->import_warning
= 1;
496 "#import is obsolete, use an #ifndef wrapper in the header file");
499 len
= parse_include (pfile
, dtable
[T_IMPORT
].name
);
502 token
= alloca (len
+ 1);
503 memcpy (token
, CPP_PWRITTEN (pfile
), len
);
506 if (CPP_OPTION (pfile
, dump_includes
))
507 pass_thru_directive (token
, len
, pfile
, T_IMPORT
);
509 _cpp_execute_include (pfile
, token
, len
, 1, 0);
514 do_include_next (pfile
)
519 struct file_name_list
*search_start
= 0;
521 len
= parse_include (pfile
, dtable
[T_INCLUDE_NEXT
].name
);
524 token
= alloca (len
+ 1);
525 memcpy (token
, CPP_PWRITTEN (pfile
), len
);
528 if (CPP_OPTION (pfile
, dump_includes
))
529 pass_thru_directive (token
, len
, pfile
, T_INCLUDE_NEXT
);
531 /* For #include_next, skip in the search path past the dir in which the
532 containing file was found. Treat files specified using an absolute path
533 as if there are no more directories to search. Treat the primary source
534 file like any other included source, but generate a warning. */
535 if (CPP_PREV_BUFFER (CPP_BUFFER (pfile
)))
537 if (CPP_BUFFER (pfile
)->ihash
->foundhere
!= ABSOLUTE_PATH
)
538 search_start
= CPP_BUFFER (pfile
)->ihash
->foundhere
->next
;
541 cpp_warning (pfile
, "#include_next in primary source file");
543 _cpp_execute_include (pfile
, token
, len
, 0, search_start
);
547 /* Subroutine of do_line. Read next token from PFILE without adding it to
548 the output buffer. If it is a number between 1 and 4, store it in *NUM
549 and return 1; otherwise, return 0 and complain if we aren't at the end
553 read_line_number (pfile
, num
)
557 long save_written
= CPP_WRITTEN (pfile
);
559 enum cpp_ttype token
= _cpp_get_directive_token (pfile
);
560 p
= pfile
->token_buffer
+ save_written
;
562 if (token
== CPP_NUMBER
&& p
+ 1 == CPP_PWRITTEN (pfile
)
563 && p
[0] >= '1' && p
[0] <= '4')
566 CPP_SET_WRITTEN (pfile
, save_written
);
571 if (token
!= CPP_VSPACE
&& token
!= CPP_EOF
)
572 cpp_error (pfile
, "invalid format `#line' command");
573 CPP_SET_WRITTEN (pfile
, save_written
);
578 /* Interpret #line command.
579 Note that the filename string (if any) is treated as if it were an
580 include filename. That means no escape handling. */
586 cpp_buffer
*ip
= CPP_BUFFER (pfile
);
587 unsigned int new_lineno
;
588 long old_written
= CPP_WRITTEN (pfile
);
589 enum cpp_ttype token
;
592 token
= _cpp_get_directive_token (pfile
);
594 if (token
!= CPP_NUMBER
)
596 cpp_error (pfile
, "token after `#line' is not an integer");
597 goto bad_line_directive
;
600 CPP_PUTC (pfile
, '\0'); /* not terminated for us */
601 new_lineno
= strtoul (pfile
->token_buffer
+ old_written
, &x
, 10);
604 cpp_error (pfile
, "token after `#line' is not an integer");
605 goto bad_line_directive
;
607 CPP_SET_WRITTEN (pfile
, old_written
);
609 if (CPP_PEDANTIC (pfile
) && (new_lineno
<= 0 || new_lineno
> 32767))
610 cpp_pedwarn (pfile
, "line number out of range in `#line' command");
612 token
= _cpp_get_directive_token (pfile
);
614 if (token
== CPP_STRING
)
616 U_CHAR
*fname
= pfile
->token_buffer
+ old_written
+ 1;
617 U_CHAR
*end_name
= CPP_PWRITTEN (pfile
) - 1;
618 int action_number
= 0;
620 if (read_line_number (pfile
, &action_number
))
622 if (CPP_PEDANTIC (pfile
))
623 cpp_pedwarn (pfile
, "garbage at end of `#line' command");
625 /* This is somewhat questionable: change the buffer stack
626 depth so that output_line_command thinks we've stacked
628 if (action_number
== 1)
630 pfile
->buffer_stack_depth
++;
631 ip
->system_header_p
= 0;
632 read_line_number (pfile
, &action_number
);
634 else if (action_number
== 2)
636 pfile
->buffer_stack_depth
--;
637 ip
->system_header_p
= 0;
638 read_line_number (pfile
, &action_number
);
640 if (action_number
== 3)
642 ip
->system_header_p
= 1;
643 read_line_number (pfile
, &action_number
);
645 if (action_number
== 4)
647 ip
->system_header_p
= 2;
648 read_line_number (pfile
, &action_number
);
654 if (strcmp (fname
, ip
->nominal_fname
))
656 if (!strcmp (fname
, ip
->ihash
->name
))
657 ip
->nominal_fname
= ip
->ihash
->name
;
659 ip
->nominal_fname
= _cpp_fake_ihash (pfile
, fname
);
662 else if (token
!= CPP_VSPACE
&& token
!= CPP_EOF
)
664 cpp_error (pfile
, "token after `#line %d' is not a string", new_lineno
);
665 goto bad_line_directive
;
668 /* The Newline at the end of this line remains to be processed.
669 To put the next line at the specified line number,
670 we must store a line number now that is one less. */
671 ip
->lineno
= new_lineno
- 1;
672 CPP_SET_WRITTEN (pfile
, old_written
);
676 _cpp_skip_rest_of_line (pfile
);
677 CPP_SET_WRITTEN (pfile
, old_written
);
681 /* Remove the definition of a symbol from the symbol table.
682 According to the C standard, it is not an error to undef
683 something that has no definitions. */
691 long here
= CPP_WRITTEN (pfile
);
692 enum cpp_ttype token
;
694 pfile
->no_macro_expand
++;
695 token
= _cpp_get_directive_token (pfile
);
696 pfile
->no_macro_expand
--;
698 if (token
!= CPP_NAME
)
700 cpp_error (pfile
, "token after #undef is not an identifier");
701 _cpp_skip_rest_of_line (pfile
);
704 len
= CPP_WRITTEN (pfile
) - here
;
706 token
= _cpp_get_directive_token (pfile
);
707 if (token
!= CPP_VSPACE
)
709 cpp_pedwarn (pfile
, "junk on line after #undef");
710 _cpp_skip_rest_of_line (pfile
);
713 name
= pfile
->token_buffer
+ here
;
714 CPP_SET_WRITTEN (pfile
, here
);
716 slot
= _cpp_lookup_slot (pfile
, name
, len
, NO_INSERT
, 0);
719 HASHNODE
*hp
= *slot
;
720 if (hp
->type
== T_POISON
)
721 cpp_error (pfile
, "cannot undefine poisoned `%s'", hp
->name
);
724 /* If we are generating additional info for debugging (with -g) we
725 need to pass through all effective #undef commands. */
726 if (CPP_OPTION (pfile
, debug_output
))
727 pass_thru_directive (hp
->name
, len
, pfile
, T_UNDEF
);
729 if (hp
->type
!= T_MACRO
&& hp
->type
!= T_FMACRO
730 && hp
->type
!= T_MCONST
731 && hp
->type
!= T_EMPTY
&& hp
->type
!= T_IDENTITY
)
732 cpp_warning (pfile
, "undefining `%s'", hp
->name
);
734 htab_clear_slot (pfile
->hashtab
, (void **)slot
);
742 * Report an error detected by the program we are processing.
743 * Use the text of the line in the error message.
744 * (We use error because it prints the filename & line#.)
751 const U_CHAR
*text
, *limit
;
753 _cpp_skip_hspace (pfile
);
754 text
= CPP_BUFFER (pfile
)->cur
;
755 _cpp_skip_rest_of_line (pfile
);
756 limit
= CPP_BUFFER (pfile
)->cur
;
758 cpp_error (pfile
, "#error %.*s", (int)(limit
- text
), text
);
763 * Report a warning detected by the program we are processing.
764 * Use the text of the line in the warning message, then continue.
771 const U_CHAR
*text
, *limit
;
773 _cpp_skip_hspace (pfile
);
774 text
= CPP_BUFFER (pfile
)->cur
;
775 _cpp_skip_rest_of_line (pfile
);
776 limit
= CPP_BUFFER (pfile
)->cur
;
778 cpp_warning (pfile
, "#warning %.*s", (int)(limit
- text
), text
);
782 /* Report program identification. */
788 long old_written
= CPP_WRITTEN (pfile
);
790 CPP_PUTS (pfile
, "#ident ", 7);
792 /* Next token should be a string constant. */
793 if (_cpp_get_directive_token (pfile
) == CPP_STRING
)
794 /* And then a newline. */
795 if (_cpp_get_directive_token (pfile
) == CPP_VSPACE
)
796 /* Good - ship it. */
799 cpp_error (pfile
, "invalid #ident");
800 _cpp_skip_rest_of_line (pfile
);
801 CPP_SET_WRITTEN (pfile
, old_written
); /* discard directive */
806 /* Pragmata handling. We handle some of these, and pass the rest on
807 to the front end. C99 defines three pragmas and says that no macro
808 expansion is to be performed on them; whether or not macro
809 expansion happens for other pragmas is implementation defined.
810 This implementation never macro-expands the text after #pragma.
812 We currently do not support the _Pragma operator. Support for that
813 has to be coordinated with the front end. Proposed implementation:
814 both #pragma blah blah and _Pragma("blah blah") become
815 __builtin_pragma(blah blah) and we teach the parser about that. */
817 /* Sub-handlers for the pragmas needing treatment here.
818 They return 1 if the token buffer is to be popped, 0 if not. */
819 static int do_pragma_once
PARAMS ((cpp_reader
*));
820 static int do_pragma_implementation
PARAMS ((cpp_reader
*));
821 static int do_pragma_poison
PARAMS ((cpp_reader
*));
822 static int do_pragma_default
PARAMS ((cpp_reader
*));
831 enum cpp_ttype token
;
833 here
= CPP_WRITTEN (pfile
);
834 CPP_PUTS (pfile
, "#pragma ", 8);
836 key
= CPP_WRITTEN (pfile
);
837 pfile
->no_macro_expand
++;
838 token
= _cpp_get_directive_token (pfile
);
839 if (token
!= CPP_NAME
)
841 if (token
== CPP_VSPACE
)
847 buf
= pfile
->token_buffer
+ key
;
848 CPP_PUTC (pfile
, ' ');
850 #define tokis(x) !strncmp((char *) buf, x, sizeof(x) - 1)
852 pop
= do_pragma_once (pfile
);
853 else if (tokis ("implementation"))
854 pop
= do_pragma_implementation (pfile
);
855 else if (tokis ("poison"))
856 pop
= do_pragma_poison (pfile
);
858 pop
= do_pragma_default (pfile
);
861 if (_cpp_get_directive_token (pfile
) != CPP_VSPACE
)
865 CPP_SET_WRITTEN (pfile
, here
);
866 pfile
->no_macro_expand
--;
870 cpp_error (pfile
, "malformed #pragma directive");
871 _cpp_skip_rest_of_line (pfile
);
873 CPP_SET_WRITTEN (pfile
, here
);
874 pfile
->no_macro_expand
--;
879 do_pragma_default (pfile
)
882 while (_cpp_get_directive_token (pfile
) != CPP_VSPACE
)
883 CPP_PUTC (pfile
, ' ');
888 do_pragma_once (pfile
)
891 cpp_buffer
*ip
= CPP_BUFFER (pfile
);
893 /* Allow #pragma once in system headers, since that's not the user's
895 if (!ip
->system_header_p
)
896 cpp_warning (pfile
, "`#pragma once' is obsolete");
898 if (CPP_PREV_BUFFER (ip
) == NULL
)
899 cpp_warning (pfile
, "`#pragma once' outside include file");
901 ip
->ihash
->control_macro
= (const U_CHAR
*) ""; /* never repeat */
907 do_pragma_implementation (pfile
)
910 /* Be quiet about `#pragma implementation' for a file only if it hasn't
911 been included yet. */
912 enum cpp_ttype token
;
913 long written
= CPP_WRITTEN (pfile
);
918 token
= _cpp_get_directive_token (pfile
);
919 if (token
== CPP_VSPACE
)
921 else if (token
!= CPP_STRING
)
923 cpp_error (pfile
, "malformed #pragma implementation");
927 /* Trim the leading and trailing quote marks from the string. */
928 name
= pfile
->token_buffer
+ written
+ 1;
929 len
= CPP_PWRITTEN (pfile
) - name
;
930 copy
= (U_CHAR
*) alloca (len
);
931 memcpy (copy
, name
, len
- 1);
932 copy
[len
- 1] = '\0';
934 if (cpp_included (pfile
, copy
))
936 "`#pragma implementation' for `%s' appears after file is included",
942 do_pragma_poison (pfile
)
945 /* Poison these symbols so that all subsequent usage produces an
951 enum cpp_ttype token
;
955 /* As a rule, don't include #pragma poison commands in output,
956 unless the user asks for them. */
957 writeit
= (CPP_OPTION (pfile
, debug_output
)
958 || CPP_OPTION (pfile
, dump_macros
) == dump_definitions
959 || CPP_OPTION (pfile
, dump_macros
) == dump_names
);
963 written
= CPP_WRITTEN (pfile
);
964 token
= _cpp_get_directive_token (pfile
);
965 if (token
== CPP_VSPACE
)
967 if (token
!= CPP_NAME
)
969 cpp_error (pfile
, "invalid #pragma poison directive");
970 _cpp_skip_rest_of_line (pfile
);
974 p
= pfile
->token_buffer
+ written
;
975 len
= CPP_PWRITTEN (pfile
) - p
;
976 slot
= _cpp_lookup_slot (pfile
, p
, len
, INSERT
, &hash
);
979 HASHNODE
*hp
= *slot
;
980 if (hp
->type
!= T_POISON
)
982 cpp_warning (pfile
, "poisoning existing macro `%s'", hp
->name
);
983 if (hp
->type
== T_MACRO
)
984 _cpp_free_definition (hp
->value
.defn
);
991 HASHNODE
*hp
= _cpp_make_hashnode (p
, len
, T_POISON
, hash
);
996 CPP_PUTC (pfile
, ' ');
1001 /* Just ignore #sccs, on systems where we define it at all. */
1002 #ifdef SCCS_DIRECTIVE
1007 _cpp_skip_rest_of_line (pfile
);
1012 /* We've found an `#if' directive. If the only thing before it in
1013 this file is white space, and if it is of the form
1014 `#if ! defined SYMBOL', then SYMBOL is a possible controlling macro
1015 for inclusion of this file. (See redundant_include_p in cppfiles.c
1016 for an explanation of controlling macros.) If so, return a
1017 malloced copy of SYMBOL. Otherwise, return NULL. */
1020 detect_if_not_defined (pfile
)
1023 U_CHAR
*control_macro
= 0;
1024 enum cpp_ttype token
;
1025 unsigned int base_offset
;
1026 unsigned int token_offset
;
1027 unsigned int need_rparen
= 0;
1028 unsigned int token_len
;
1030 if (pfile
->only_seen_white
!= 2)
1033 /* Save state required for restore. */
1034 pfile
->no_macro_expand
++;
1035 CPP_SET_MARK (pfile
);
1036 base_offset
= CPP_WRITTEN (pfile
);
1039 if (_cpp_get_directive_token (pfile
) != CPP_OTHER
1040 || CPP_WRITTEN (pfile
) != (size_t) base_offset
+ 1
1041 || CPP_PWRITTEN (pfile
)[-1] != '!')
1044 /* ...then `defined', */
1045 token_offset
= CPP_WRITTEN (pfile
);
1046 token
= _cpp_get_directive_token (pfile
);
1047 if (token
!= CPP_NAME
)
1049 if (strncmp (pfile
->token_buffer
+ token_offset
, "defined", 7))
1052 /* ...then an optional '(' and the name, */
1053 token_offset
= CPP_WRITTEN (pfile
);
1054 token
= _cpp_get_directive_token (pfile
);
1055 if (token
== CPP_OPEN_PAREN
)
1057 token_offset
= CPP_WRITTEN (pfile
);
1059 token
= _cpp_get_directive_token (pfile
);
1061 if (token
!= CPP_NAME
)
1064 token_len
= CPP_WRITTEN (pfile
) - token_offset
;
1066 /* ...then the ')', if necessary, */
1067 if (need_rparen
&& _cpp_get_directive_token (pfile
) != CPP_CLOSE_PAREN
)
1070 /* ...and make sure there's nothing else on the line. */
1071 if (_cpp_get_directive_token (pfile
) != CPP_VSPACE
)
1074 /* We have a legitimate controlling macro for this header. */
1075 control_macro
= (U_CHAR
*) xmalloc (token_len
+ 1);
1076 memcpy (control_macro
, pfile
->token_buffer
+ token_offset
, token_len
);
1077 control_macro
[token_len
] = '\0';
1080 CPP_SET_WRITTEN (pfile
, base_offset
);
1081 pfile
->no_macro_expand
--;
1082 CPP_GOTO_MARK (pfile
);
1084 return control_macro
;
1088 * #if is straightforward; just call _cpp_parse_expr, then conditional_skip.
1089 * Also, check for a reinclude preventer of the form #if !defined (MACRO).
1096 U_CHAR
*control_macro
= detect_if_not_defined (pfile
);
1097 int value
= _cpp_parse_expr (pfile
);
1098 return conditional_skip (pfile
, value
== 0, T_IF
, control_macro
);
1102 * handle a #elif directive by not changing if_stack either.
1103 * see the comment above do_else.
1110 if (pfile
->if_stack
== CPP_BUFFER (pfile
)->if_stack
)
1112 cpp_error (pfile
, "`#elif' not within a conditional");
1117 if (pfile
->if_stack
->type
== T_ELSE
)
1119 cpp_error (pfile
, "`#elif' after `#else'");
1120 cpp_error_with_line (pfile
, pfile
->if_stack
->lineno
, 0,
1121 "the conditional began here");
1123 pfile
->if_stack
->type
= T_ELIF
;
1126 if (pfile
->if_stack
->if_succeeded
)
1128 _cpp_skip_rest_of_line (pfile
);
1129 return skip_if_group (pfile
);
1131 if (_cpp_parse_expr (pfile
) == 0)
1132 return skip_if_group (pfile
);
1134 ++pfile
->if_stack
->if_succeeded
; /* continue processing input */
1138 /* Parse an #ifdef or #ifndef directive. Returns 1 for defined, 0 for
1139 not defined; the macro tested is left in the token buffer (but
1143 parse_ifdef (pfile
, name
)
1149 enum cpp_ttype token
;
1150 long old_written
= CPP_WRITTEN (pfile
);
1153 pfile
->no_macro_expand
++;
1154 token
= _cpp_get_directive_token (pfile
);
1155 pfile
->no_macro_expand
--;
1157 ident
= pfile
->token_buffer
+ old_written
;
1158 len
= CPP_WRITTEN (pfile
) - old_written
;
1160 if (token
== CPP_VSPACE
)
1162 if (! CPP_TRADITIONAL (pfile
))
1163 cpp_pedwarn (pfile
, "`#%s' with no argument", name
);
1167 else if (token
== CPP_NAME
)
1169 defined
= cpp_defined (pfile
, ident
, len
);
1170 CPP_PUTC (pfile
, '\0'); /* so it can be copied with xstrdup */
1175 if (! CPP_TRADITIONAL (pfile
))
1176 cpp_error (pfile
, "`#%s' with invalid argument", name
);
1179 if (!CPP_TRADITIONAL (pfile
))
1181 if (_cpp_get_directive_token (pfile
) == CPP_VSPACE
)
1184 cpp_pedwarn (pfile
, "garbage at end of `#%s' argument", name
);
1186 _cpp_skip_rest_of_line (pfile
);
1189 CPP_SET_WRITTEN (pfile
, old_written
); /* Pop */
1193 /* #ifdef is dead simple. */
1199 int skip
= ! parse_ifdef (pfile
, dtable
[T_IFDEF
].name
);
1200 return conditional_skip (pfile
, skip
, T_IFDEF
, 0);
1203 /* #ifndef is a tad more complex, because we need to check for a
1204 no-reinclusion wrapper. */
1210 int start_of_file
, skip
;
1211 U_CHAR
*control_macro
= 0;
1213 start_of_file
= pfile
->only_seen_white
== 2;
1214 skip
= parse_ifdef (pfile
, dtable
[T_IFNDEF
].name
);
1216 if (start_of_file
&& !skip
)
1217 control_macro
= (U_CHAR
*) xstrdup (CPP_PWRITTEN (pfile
));
1219 return conditional_skip (pfile
, skip
, T_IFNDEF
, control_macro
);
1222 /* Push TYPE on stack; then, if SKIP is nonzero, skip ahead.
1223 If this is a #ifndef starting at the beginning of a file,
1224 CONTROL_MACRO is the macro name tested by the #ifndef.
1225 Otherwise, CONTROL_MACRO is 0. */
1228 conditional_skip (pfile
, skip
, type
, control_macro
)
1232 U_CHAR
*control_macro
;
1236 temp
= (IF_STACK
*) xcalloc (1, sizeof (IF_STACK
));
1237 temp
->lineno
= CPP_BUFFER (pfile
)->lineno
;
1238 temp
->next
= pfile
->if_stack
;
1239 temp
->control_macro
= control_macro
;
1240 pfile
->if_stack
= temp
;
1242 pfile
->if_stack
->type
= type
;
1245 return skip_if_group (pfile
);
1247 ++pfile
->if_stack
->if_succeeded
;
1251 /* Subroutine of skip_if_group. Examine one preprocessing directive
1252 and return 0 if skipping should continue, or the directive number
1253 of the directive that ends the block if it should halt.
1255 Also adjusts the if_stack as appropriate. The `#' has been read,
1256 but not the identifier. */
1259 consider_directive_while_skipping (pfile
, stack
)
1268 /* -traditional directives are recognized only with the # in column 1. */
1269 hash_at_bol
= CPP_IN_COLUMN_1 (pfile
);
1271 ident
= CPP_WRITTEN (pfile
);
1272 if (_cpp_get_directive_token (pfile
) != CPP_NAME
)
1274 len
= CPP_WRITTEN (pfile
) - ident
;
1276 for (i
= 0; i
< N_DIRECTIVES
; i
++)
1278 if (dtable
[i
].length
== len
1279 && !strncmp (dtable
[i
].name
, pfile
->token_buffer
+ ident
, len
))
1280 goto real_directive
;
1286 /* If it's not a directive of interest to us, return now. */
1287 if (ORIGIN (dtable
[i
].flags
) != COND
)
1290 /* First, deal with -traditional and -Wtraditional.
1291 All COND directives are from K+R. */
1295 if (CPP_TRADITIONAL (pfile
))
1297 if (CPP_WTRADITIONAL (pfile
))
1298 cpp_warning (pfile
, "ignoring #%s because of its indented #",
1302 if (CPP_WTRADITIONAL (pfile
))
1303 cpp_warning (pfile
, "traditional C ignores %s with the # indented",
1310 cpp_ice (pfile
, "non COND directive in switch in c_d_w_s");
1316 temp
= (IF_STACK
*) xcalloc (1, sizeof (IF_STACK
));
1317 temp
->lineno
= CPP_BUFFER (pfile
)->lineno
;
1318 temp
->next
= pfile
->if_stack
;
1320 pfile
->if_stack
= temp
;
1324 if (pfile
->if_stack
!= stack
)
1325 validate_else (pfile
, dtable
[i
].name
);
1328 if (pfile
->if_stack
== stack
)
1331 pfile
->if_stack
->type
= i
;
1335 if (pfile
->if_stack
!= stack
)
1336 validate_else (pfile
, dtable
[i
].name
);
1338 if (pfile
->if_stack
== stack
)
1341 temp
= pfile
->if_stack
;
1342 pfile
->if_stack
= temp
->next
;
1348 /* Skip to #endif, #else, or #elif. Consumes the directive that
1349 causes it to stop, but not its argument. Returns the number of
1350 that directive, which must be passed back up to
1351 _cpp_handle_directive, which will execute it. */
1353 skip_if_group (pfile
)
1356 enum cpp_ttype token
;
1357 IF_STACK
*save_if_stack
= pfile
->if_stack
; /* don't pop past here */
1361 /* We are no longer at the start of the file. */
1362 pfile
->only_seen_white
= 0;
1364 old_written
= CPP_WRITTEN (pfile
);
1365 pfile
->no_macro_expand
++;
1368 /* We are at the end of a line. Only cpp_get_token knows how to
1369 advance the line number correctly. */
1370 token
= cpp_get_token (pfile
);
1371 if (token
== CPP_POP
)
1372 break; /* Caller will issue error. */
1373 else if (token
!= CPP_VSPACE
)
1374 cpp_ice (pfile
, "cpp_get_token returned %d in skip_if_group", token
);
1375 CPP_SET_WRITTEN (pfile
, old_written
);
1377 token
= _cpp_get_directive_token (pfile
);
1379 if (token
== CPP_DIRECTIVE
)
1381 ret
= consider_directive_while_skipping (pfile
, save_if_stack
);
1386 if (token
!= CPP_VSPACE
)
1387 _cpp_skip_rest_of_line (pfile
);
1389 CPP_SET_WRITTEN (pfile
, old_written
);
1390 pfile
->no_macro_expand
--;
1395 * handle a #else directive. Do this by just continuing processing
1396 * without changing if_stack ; this is so that the error message
1397 * for missing #endif's etc. will point to the original #if. It
1398 * is possible that something different would be better.
1405 validate_else (pfile
, dtable
[T_ELSE
].name
);
1406 _cpp_skip_rest_of_line (pfile
);
1408 if (pfile
->if_stack
== CPP_BUFFER (pfile
)->if_stack
)
1410 cpp_error (pfile
, "`#else' not within a conditional");
1415 /* #ifndef can't have its special treatment for containing the whole file
1416 if it has a #else clause. */
1417 pfile
->if_stack
->control_macro
= 0;
1419 if (pfile
->if_stack
->type
== T_ELSE
)
1421 cpp_error (pfile
, "`#else' after `#else'");
1422 cpp_error_with_line (pfile
, pfile
->if_stack
->lineno
, 0,
1423 "the conditional began here");
1425 pfile
->if_stack
->type
= T_ELSE
;
1428 if (pfile
->if_stack
->if_succeeded
)
1429 return skip_if_group (pfile
);
1431 ++pfile
->if_stack
->if_succeeded
; /* continue processing input */
1436 * unstack after #endif command
1443 validate_else (pfile
, dtable
[T_ENDIF
].name
);
1444 _cpp_skip_rest_of_line (pfile
);
1446 if (pfile
->if_stack
== CPP_BUFFER (pfile
)->if_stack
)
1447 cpp_error (pfile
, "`#endif' not within a conditional");
1450 IF_STACK
*temp
= pfile
->if_stack
;
1451 pfile
->if_stack
= temp
->next
;
1452 if (temp
->control_macro
!= 0)
1453 pfile
->potential_control_macro
= temp
->control_macro
;
1459 /* Issue -pedantic warning for text which is not a comment following
1460 an #else or #endif. Do not warn in system headers, as this is harmless
1461 and very common on old systems. */
1464 validate_else (pfile
, directive
)
1466 const char *directive
;
1469 if (! CPP_PEDANTIC (pfile
))
1472 old_written
= CPP_WRITTEN (pfile
);
1473 pfile
->no_macro_expand
++;
1474 if (_cpp_get_directive_token (pfile
) != CPP_VSPACE
)
1476 "text following `#%s' violates ANSI standard", directive
);
1477 CPP_SET_WRITTEN (pfile
, old_written
);
1478 pfile
->no_macro_expand
--;
1482 _cpp_handle_eof (pfile
)
1485 struct if_stack
*ifs
, *nifs
;
1487 /* Unwind the conditional stack and generate error messages. */
1488 for (ifs
= pfile
->if_stack
;
1489 ifs
!= CPP_BUFFER (pfile
)->if_stack
;
1492 cpp_error_with_line (pfile
, ifs
->lineno
, 0,
1493 "unterminated `#%s' conditional",
1494 dtable
[ifs
->type
].name
);
1499 pfile
->if_stack
= ifs
;
1500 CPP_BUFFER (pfile
)->seen_eof
= 1;
1510 HASHNODE
*base
, *this;
1511 HASHNODE
**bslot
, **tslot
;
1513 unsigned long bhash
, thash
;
1515 old_written
= CPP_WRITTEN (pfile
); /* remember where it starts */
1516 ret
= _cpp_parse_assertion (pfile
);
1521 cpp_error (pfile
, "missing token-sequence in #assert");
1524 tlen
= CPP_WRITTEN (pfile
) - old_written
;
1526 if (_cpp_get_directive_token (pfile
) != CPP_VSPACE
)
1528 cpp_error (pfile
, "junk at end of #assert");
1532 sym
= pfile
->token_buffer
+ old_written
;
1533 blen
= (U_CHAR
*) strchr (sym
, '(') - sym
;
1534 tslot
= _cpp_lookup_slot (pfile
, sym
, tlen
, INSERT
, &thash
);
1537 cpp_warning (pfile
, "%s re-asserted", sym
);
1541 bslot
= _cpp_lookup_slot (pfile
, sym
, blen
, INSERT
, &bhash
);
1544 *bslot
= base
= _cpp_make_hashnode (sym
, blen
, T_ASSERT
, bhash
);
1545 base
->value
.aschain
= 0;
1550 if (base
->type
!= T_ASSERT
)
1552 /* Token clash - but with what?! */
1553 cpp_ice (pfile
, "base->type != T_ASSERT in do_assert");
1557 *tslot
= this = _cpp_make_hashnode (sym
, tlen
, T_ASSERT
, thash
);
1558 this->value
.aschain
= base
->value
.aschain
;
1559 base
->value
.aschain
= this;
1562 _cpp_skip_rest_of_line (pfile
);
1563 CPP_SET_WRITTEN (pfile
, old_written
);
1574 long baselen
, thislen
;
1575 HASHNODE
*base
, *this, *next
;
1577 old_written
= CPP_WRITTEN (pfile
);
1578 ret
= _cpp_parse_assertion (pfile
);
1581 thislen
= CPP_WRITTEN (pfile
) - old_written
;
1583 if (_cpp_get_directive_token (pfile
) != CPP_VSPACE
)
1585 cpp_error (pfile
, "junk at end of #unassert");
1588 sym
= pfile
->token_buffer
+ old_written
;
1589 CPP_SET_WRITTEN (pfile
, old_written
);
1593 base
= _cpp_lookup (pfile
, sym
, thislen
);
1595 goto error
; /* It isn't an error to #undef what isn't #defined,
1596 so it isn't an error to #unassert what isn't
1597 #asserted either. */
1599 for (this = base
->value
.aschain
; this; this = next
)
1601 next
= this->value
.aschain
;
1602 htab_remove_elt (pfile
->hashtab
, this);
1604 htab_remove_elt (pfile
->hashtab
, base
);
1608 baselen
= (U_CHAR
*) strchr (sym
, '(') - sym
;
1609 base
= _cpp_lookup (pfile
, sym
, baselen
);
1610 if (! base
) goto error
;
1611 this = _cpp_lookup (pfile
, sym
, thislen
);
1612 if (! this) goto error
;
1615 while (next
->value
.aschain
!= this)
1616 next
= next
->value
.aschain
;
1618 next
->value
.aschain
= this->value
.aschain
;
1619 htab_remove_elt (pfile
->hashtab
, this);
1621 if (base
->value
.aschain
== NULL
)
1622 /* Last answer for this predicate deleted. */
1623 htab_remove_elt (pfile
->hashtab
, base
);
1628 _cpp_skip_rest_of_line (pfile
);
1629 CPP_SET_WRITTEN (pfile
, old_written
);
1633 /* These are for -D, -U, -A. */
1635 /* Process the string STR as if it appeared as the body of a #define.
1636 If STR is just an identifier, define it with value 1.
1637 If STR has anything after the identifier, then it should
1638 be identifier=definition. */
1641 cpp_define (pfile
, str
)
1648 p
= strchr (str
, '=');
1649 /* Copy the entire option so we can modify it.
1650 Change the first "=" in the string to a space. If there is none,
1651 tack " 1" on the end. Then add a newline and a NUL. */
1655 count
= strlen (str
) + 2;
1656 buf
= (char *) alloca (count
);
1657 memcpy (buf
, str
, count
- 2);
1659 buf
[count
- 2] = '\n';
1660 buf
[count
- 1] = '\0';
1664 count
= strlen (str
) + 4;
1665 buf
= (char *) alloca (count
);
1666 memcpy (buf
, str
, count
- 4);
1667 strcpy (&buf
[count
-4], " 1\n");
1670 if (cpp_push_buffer (pfile
, buf
, count
- 1) != NULL
)
1673 cpp_pop_buffer (pfile
);
1677 /* Process MACRO as if it appeared as the body of an #undef. */
1679 cpp_undef (pfile
, macro
)
1683 /* Copy the string so we can append a newline. */
1684 size_t len
= strlen (macro
);
1685 char *buf
= (char *) alloca (len
+ 2);
1686 memcpy (buf
, macro
, len
);
1688 buf
[len
+ 1] = '\0';
1689 if (cpp_push_buffer (pfile
, buf
, len
+ 1))
1692 cpp_pop_buffer (pfile
);
1696 /* Process the string STR as if it appeared as the body of a #assert. */
1698 cpp_assert (pfile
, str
)
1702 if (cpp_push_buffer (pfile
, str
, strlen (str
)) != NULL
)
1705 cpp_pop_buffer (pfile
);
1709 /* Process STR as if it appeared as the body of an #unassert. */
1711 cpp_unassert (pfile
, str
)
1715 if (cpp_push_buffer (pfile
, str
, strlen (str
)) != NULL
)
1717 do_unassert (pfile
);
1718 cpp_pop_buffer (pfile
);
1722 /* Determine whether the identifier ID, of length LEN, is a defined macro. */
1724 cpp_defined (pfile
, id
, len
)
1729 HASHNODE
*hp
= _cpp_lookup (pfile
, id
, len
);
1730 if (hp
&& hp
->type
== T_POISON
)
1732 cpp_error (pfile
, "attempt to use poisoned `%s'", hp
->name
);
1735 return (hp
!= NULL
);