OSDN Git Service

More of previous change.
[pf3gnuchains/gcc-fork.git] / gcc / c-lex.c
1 /* Lexical analyzer for C and Objective C.
2    Copyright (C) 1987, 1988, 1989, 1992 Free Software Foundation, Inc.
3
4 This file is part of GNU CC.
5
6 GNU CC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
10
11 GNU CC is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with GNU CC; see the file COPYING.  If not, write to
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
19
20
21 #include <stdio.h>
22 #include <errno.h>
23 #include <setjmp.h>
24
25 #include "config.h"
26 #include "rtl.h"
27 #include "tree.h"
28 #include "input.h"
29 #include "c-lex.h"
30 #include "c-tree.h"
31 #include "flags.h"
32 #include "c-parse.h"
33
34 #ifdef MULTIBYTE_CHARS
35 #include <stdlib.h>
36 #include <locale.h>
37 #endif
38
39 #ifndef errno
40 extern int errno;
41 #endif
42
43 /* The elements of `ridpointers' are identifier nodes
44    for the reserved type names and storage classes.
45    It is indexed by a RID_... value.  */
46 tree ridpointers[(int) RID_MAX];
47
48 /* Cause the `yydebug' variable to be defined.  */
49 #define YYDEBUG 1
50
51 /* the declaration found for the last IDENTIFIER token read in.
52    yylex must look this up to detect typedefs, which get token type TYPENAME,
53    so it is left around in case the identifier is not a typedef but is
54    used in a context which makes it a reference to a variable.  */
55 tree lastiddecl;
56
57 /* Nonzero enables objc features.  */
58
59 int doing_objc_thang;
60
61 extern tree lookup_interface ();
62
63 extern int yydebug;
64
65 /* File used for outputting assembler code.  */
66 extern FILE *asm_out_file;
67
68 #ifndef WCHAR_TYPE_SIZE
69 #ifdef INT_TYPE_SIZE
70 #define WCHAR_TYPE_SIZE INT_TYPE_SIZE
71 #else
72 #define WCHAR_TYPE_SIZE BITS_PER_WORD
73 #endif
74 #endif
75
76 /* Number of bytes in a wide character.  */
77 #define WCHAR_BYTES (WCHAR_TYPE_SIZE / BITS_PER_UNIT)
78
79 static int maxtoken;            /* Current nominal length of token buffer.  */
80 char *token_buffer;     /* Pointer to token buffer.
81                            Actual allocated length is maxtoken + 2.
82                            This is not static because objc-parse.y uses it.  */
83
84 /* Nonzero if end-of-file has been seen on input.  */
85 static int end_of_file;
86
87 /* Buffered-back input character; faster than using ungetc.  */
88 static int nextchar = -1;
89
90 int check_newline ();
91
92 /* Nonzero tells yylex to ignore \ in string constants.  */
93 static int ignore_escape_flag = 0;
94 \f
95 /* C code produced by gperf version 2.5 (GNU C++ version) */
96 /* Command-line: gperf -p -j1 -i 1 -g -o -t -N is_reserved_word -k1,3,$ c-parse.gperf  */ 
97 struct resword { char *name; short token; enum rid rid; };
98
99 #define TOTAL_KEYWORDS 61
100 #define MIN_WORD_LENGTH 2
101 #define MAX_WORD_LENGTH 13
102 #define MIN_HASH_VALUE 10
103 #define MAX_HASH_VALUE 95
104 /* maximum key range = 86, duplicates = 0 */
105
106 #ifdef __GNUC__
107 __inline
108 #endif
109 static unsigned int
110 hash (str, len)
111      register char *str;
112      register int unsigned len;
113 {
114   static unsigned char asso_values[] =
115     {
116      96, 96, 96, 96, 96, 96, 96, 96, 96, 96,
117      96, 96, 96, 96, 96, 96, 96, 96, 96, 96,
118      96, 96, 96, 96, 96, 96, 96, 96, 96, 96,
119      96, 96, 96, 96, 96, 96, 96, 96, 96, 96,
120      96, 96, 96, 96, 96, 96, 96, 96, 96, 96,
121      96, 96, 96, 96, 96, 96, 96, 96, 96, 96,
122      96, 96, 96, 96, 96, 96, 96, 96, 96, 96,
123      96, 96, 96, 96, 96, 96, 96, 96, 96, 96,
124      96, 96, 96, 96, 96, 96, 96, 96, 96, 96,
125      96, 96, 96, 96, 96,  1, 96, 15, 13, 23,
126       1,  6, 32, 36,  3,  5, 96,  1, 20, 29,
127      31, 44, 19, 96, 13,  2,  1, 54, 39, 11,
128       5, 96,  3, 96, 96, 96, 96, 96,
129     };
130   register int hval = len;
131
132   switch (hval)
133     {
134       default:
135       case 3:
136         hval += asso_values[str[2]];
137       case 2:
138       case 1:
139         hval += asso_values[str[0]];
140     }
141   return hval + asso_values[str[len - 1]];
142 }
143
144 #ifdef __GNUC__
145 __inline
146 #endif
147 struct resword *
148 is_reserved_word (str, len)
149      register char *str;
150      register unsigned int len;
151 {
152   static struct resword wordlist[] =
153     {
154       {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, 
155       {"",}, 
156       {"int",  TYPESPEC, RID_INT},
157       {"",}, 
158       {"__signed",  TYPESPEC, RID_SIGNED},
159       {"__typeof__",  TYPEOF, NORID},
160       {"__signed__",  TYPESPEC, RID_SIGNED},
161       {"__imag__",  IMAGPART, NORID},
162       {"switch",  SWITCH, NORID},
163       {"__inline__",  SCSPEC, RID_INLINE},
164       {"else",  ELSE, NORID},
165       {"__iterator__",  SCSPEC, RID_ITERATOR},
166       {"__inline",  SCSPEC, RID_INLINE},
167       {"__extension__",  EXTENSION, NORID},
168       {"struct",  STRUCT, NORID},
169       {"__real__",  REALPART, NORID},
170       {"__asm__",  ASM_KEYWORD, NORID},
171       {"break",  BREAK, NORID},
172       {"",}, 
173       {"while",  WHILE, NORID},
174       {"__alignof__",  ALIGNOF, NORID},
175       {"__iterator",  SCSPEC, RID_ITERATOR},
176       {"__attribute__",  ATTRIBUTE, NORID},
177       {"__label__",  LABEL, NORID},
178       {"__const",  TYPE_QUAL, RID_CONST},
179       {"__attribute",  ATTRIBUTE, NORID},
180       {"__const__",  TYPE_QUAL, RID_CONST},
181       {"case",  CASE, NORID},
182       {"__complex__",  TYPESPEC, RID_COMPLEX},
183       {"inline",  SCSPEC, RID_INLINE},
184       {"__complex",  TYPESPEC, RID_COMPLEX},
185       {"if",  IF, NORID},
186       {"__real",  REALPART, NORID},
187       {"default",  DEFAULT, NORID},
188       {"__typeof",  TYPEOF, NORID},
189       {"sizeof",  SIZEOF, NORID},
190       {"extern",  SCSPEC, RID_EXTERN},
191       {"signed",  TYPESPEC, RID_SIGNED},
192       {"static",  SCSPEC, RID_STATIC},
193       {"do",  DO, NORID},
194       {"__imag",  IMAGPART, NORID},
195       {"void",  TYPESPEC, RID_VOID},
196       {"__asm",  ASM_KEYWORD, NORID},
197       {"return",  RETURN, NORID},
198       {"short",  TYPESPEC, RID_SHORT},
199       {"__volatile__",  TYPE_QUAL, RID_VOLATILE},
200       {"",}, 
201       {"char",  TYPESPEC, RID_CHAR},
202       {"__volatile",  TYPE_QUAL, RID_VOLATILE},
203       {"__alignof",  ALIGNOF, NORID},
204       {"typeof",  TYPEOF, NORID},
205       {"typedef",  SCSPEC, RID_TYPEDEF},
206       {"const",  TYPE_QUAL, RID_CONST},
207       {"for",  FOR, NORID},
208       {"",}, {"",}, 
209       {"auto",  SCSPEC, RID_AUTO},
210       {"unsigned",  TYPESPEC, RID_UNSIGNED},
211       {"",}, 
212       {"double",  TYPESPEC, RID_DOUBLE},
213       {"continue",  CONTINUE, NORID},
214       {"",}, 
215       {"register",  SCSPEC, RID_REGISTER},
216       {"",}, {"",}, 
217       {"volatile",  TYPE_QUAL, RID_VOLATILE},
218       {"",}, {"",}, 
219       {"asm",  ASM_KEYWORD, NORID},
220       {"",}, {"",}, {"",}, {"",}, {"",}, 
221       {"float",  TYPESPEC, RID_FLOAT},
222       {"",}, {"",}, 
223       {"goto",  GOTO, NORID},
224       {"",}, {"",}, {"",}, {"",}, {"",}, 
225       {"long",  TYPESPEC, RID_LONG},
226       {"",}, 
227       {"enum",  ENUM, NORID},
228       {"",}, 
229       {"union",  UNION, NORID},
230     };
231
232   if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
233     {
234       register int key = hash (str, len);
235
236       if (key <= MAX_HASH_VALUE && key >= 0)
237         {
238           register char *s = wordlist[key].name;
239
240           if (*s == *str && !strcmp (str + 1, s + 1))
241             return &wordlist[key];
242         }
243     }
244   return 0;
245 }
246 \f
247 /* Return something to represent absolute declarators containing a *.
248    TARGET is the absolute declarator that the * contains.
249    TYPE_QUALS is a list of modifiers such as const or volatile
250    to apply to the pointer type, represented as identifiers.
251
252    We return an INDIRECT_REF whose "contents" are TARGET
253    and whose type is the modifier list.  */
254
255 tree
256 make_pointer_declarator (type_quals, target)
257      tree type_quals, target;
258 {
259   return build1 (INDIRECT_REF, type_quals, target);
260 }
261 \f
262 void
263 init_lex ()
264 {
265   /* Make identifier nodes long enough for the language-specific slots.  */
266   set_identifier_size (sizeof (struct lang_identifier));
267
268   /* Start it at 0, because check_newline is called at the very beginning
269      and will increment it to 1.  */
270   lineno = 0;
271
272 #ifdef MULTIBYTE_CHARS
273   /* Change to the native locale for multibyte conversions.  */
274   setlocale (LC_CTYPE, "");
275 #endif
276
277   maxtoken = 40;
278   token_buffer = (char *) xmalloc (maxtoken + 2);
279
280   ridpointers[(int) RID_INT] = get_identifier ("int");
281   ridpointers[(int) RID_CHAR] = get_identifier ("char");
282   ridpointers[(int) RID_VOID] = get_identifier ("void");
283   ridpointers[(int) RID_FLOAT] = get_identifier ("float");
284   ridpointers[(int) RID_DOUBLE] = get_identifier ("double");
285   ridpointers[(int) RID_SHORT] = get_identifier ("short");
286   ridpointers[(int) RID_LONG] = get_identifier ("long");
287   ridpointers[(int) RID_UNSIGNED] = get_identifier ("unsigned");
288   ridpointers[(int) RID_SIGNED] = get_identifier ("signed");
289   ridpointers[(int) RID_INLINE] = get_identifier ("inline");
290   ridpointers[(int) RID_CONST] = get_identifier ("const");
291   ridpointers[(int) RID_VOLATILE] = get_identifier ("volatile");
292   ridpointers[(int) RID_AUTO] = get_identifier ("auto");
293   ridpointers[(int) RID_STATIC] = get_identifier ("static");
294   ridpointers[(int) RID_EXTERN] = get_identifier ("extern");
295   ridpointers[(int) RID_TYPEDEF] = get_identifier ("typedef");
296   ridpointers[(int) RID_REGISTER] = get_identifier ("register");
297   ridpointers[(int) RID_ITERATOR] = get_identifier ("iterator");
298   ridpointers[(int) RID_COMPLEX] = get_identifier ("complex");
299
300   /* Some options inhibit certain reserved words.
301      Clear those words out of the hash table so they won't be recognized.  */
302 #define UNSET_RESERVED_WORD(STRING) \
303   do { struct resword *s = is_reserved_word (STRING, sizeof (STRING) - 1); \
304        if (s) s->name = ""; } while (0)
305
306   if (flag_traditional)
307     {
308       UNSET_RESERVED_WORD ("const");
309       UNSET_RESERVED_WORD ("volatile");
310       UNSET_RESERVED_WORD ("typeof");
311       UNSET_RESERVED_WORD ("signed");
312       UNSET_RESERVED_WORD ("inline");
313       UNSET_RESERVED_WORD ("iterator");
314       UNSET_RESERVED_WORD ("complex");
315     }
316   if (flag_no_asm)
317     {
318       UNSET_RESERVED_WORD ("asm");
319       UNSET_RESERVED_WORD ("typeof");
320       UNSET_RESERVED_WORD ("inline");
321       UNSET_RESERVED_WORD ("iterator");
322       UNSET_RESERVED_WORD ("complex");
323     }
324 }
325
326 void
327 reinit_parse_for_function ()
328 {
329 }
330 \f
331 /* Function used when yydebug is set, to print a token in more detail.  */
332
333 void
334 yyprint (file, yychar, yylval)
335      FILE *file;
336      int yychar;
337      YYSTYPE yylval;
338 {
339   tree t;
340   switch (yychar)
341     {
342     case IDENTIFIER:
343     case TYPENAME:
344       t = yylval.ttype;
345       if (IDENTIFIER_POINTER (t))
346         fprintf (file, " `%s'", IDENTIFIER_POINTER (t));
347       break;
348
349     case CONSTANT:
350       t = yylval.ttype;
351       if (TREE_CODE (t) == INTEGER_CST)
352         fprintf (file,
353 #if HOST_BITS_PER_WIDE_INT == 64
354 #if HOST_BITS_PER_WIDE_INT != HOST_BITS_PER_INT
355                  " 0x%lx%016lx",
356 #else
357                  " 0x%x%016x",
358 #endif
359 #else
360 #if HOST_BITS_PER_WIDE_INT != HOST_BITS_PER_INT
361                  " 0x%lx%08lx",
362 #else
363                  " 0x%x%08x",
364 #endif
365 #endif
366                  TREE_INT_CST_HIGH (t), TREE_INT_CST_LOW (t));
367       break;
368     }
369 }
370
371 \f
372 /* If C is not whitespace, return C.
373    Otherwise skip whitespace and return first nonwhite char read.  */
374
375 static int
376 skip_white_space (c)
377      register int c;
378 {
379   static int newline_warning = 0;
380
381   for (;;)
382     {
383       switch (c)
384         {
385           /* We don't recognize comments here, because
386              cpp output can include / and * consecutively as operators.
387              Also, there's no need, since cpp removes all comments.  */
388
389         case '\n':
390           c = check_newline ();
391           break;
392
393         case ' ':
394         case '\t':
395         case '\f':
396         case '\v':
397         case '\b':
398           c = getc (finput);
399           break;
400
401         case '\r':
402           /* ANSI C says the effects of a carriage return in a source file
403              are undefined.  */
404           if (pedantic && !newline_warning)
405             {
406               warning ("carriage return in source file");
407               warning ("(we only warn about the first carriage return)");
408               newline_warning = 1;
409             }
410           c = getc (finput);
411           break;
412
413         case '\\':
414           c = getc (finput);
415           if (c == '\n')
416             lineno++;
417           else
418             error ("stray '\\' in program");
419           c = getc (finput);
420           break;
421
422         default:
423           return (c);
424         }
425     }
426 }
427
428 /* Skips all of the white space at the current location in the input file.
429    Must use and reset nextchar if it has the next character.  */
430
431 void
432 position_after_white_space ()
433 {
434   register int c;
435
436   if (nextchar != -1)
437     c = nextchar, nextchar = -1;
438   else
439     c = getc (finput);
440
441   ungetc (skip_white_space (c), finput);
442 }
443
444 /* Make the token buffer longer, preserving the data in it.
445    P should point to just beyond the last valid character in the old buffer.
446    The value we return is a pointer to the new buffer
447    at a place corresponding to P.  */
448
449 static char *
450 extend_token_buffer (p)
451      char *p;
452 {
453   int offset = p - token_buffer;
454
455   maxtoken = maxtoken * 2 + 10;
456   token_buffer = (char *) xrealloc (token_buffer, maxtoken + 2);
457
458   return token_buffer + offset;
459 }
460 \f
461 /* At the beginning of a line, increment the line number
462    and process any #-directive on this line.
463    If the line is a #-directive, read the entire line and return a newline.
464    Otherwise, return the line's first non-whitespace character.  */
465
466 int
467 check_newline ()
468 {
469   register int c;
470   register int token;
471
472   lineno++;
473
474   /* Read first nonwhite char on the line.  */
475
476   c = getc (finput);
477   while (c == ' ' || c == '\t')
478     c = getc (finput);
479
480   if (c != '#')
481     {
482       /* If not #, return it so caller will use it.  */
483       return c;
484     }
485
486   /* Read first nonwhite char after the `#'.  */
487
488   c = getc (finput);
489   while (c == ' ' || c == '\t')
490     c = getc (finput);
491
492   /* If a letter follows, then if the word here is `line', skip
493      it and ignore it; otherwise, ignore the line, with an error
494      if the word isn't `pragma', `ident', `define', or `undef'.  */
495
496   if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))
497     {
498       if (c == 'p')
499         {
500           if (getc (finput) == 'r'
501               && getc (finput) == 'a'
502               && getc (finput) == 'g'
503               && getc (finput) == 'm'
504               && getc (finput) == 'a'
505               && ((c = getc (finput)) == ' ' || c == '\t' || c == '\n'))
506             {
507 #ifdef HANDLE_SYSV_PRAGMA
508               return handle_sysv_pragma (finput, c);
509 #endif /* HANDLE_SYSV_PRAGMA */
510 #ifdef HANDLE_PRAGMA
511               HANDLE_PRAGMA (finput);
512 #endif /* HANDLE_PRAGMA */
513               goto skipline;
514             }
515         }
516
517       else if (c == 'd')
518         {
519           if (getc (finput) == 'e'
520               && getc (finput) == 'f'
521               && getc (finput) == 'i'
522               && getc (finput) == 'n'
523               && getc (finput) == 'e'
524               && ((c = getc (finput)) == ' ' || c == '\t' || c == '\n'))
525             {
526 #ifdef DWARF_DEBUGGING_INFO
527               if ((debug_info_level == DINFO_LEVEL_VERBOSE)
528                   && (write_symbols == DWARF_DEBUG))
529                 dwarfout_define (lineno, get_directive_line (finput));
530 #endif /* DWARF_DEBUGGING_INFO */
531               goto skipline;
532             }
533         }
534       else if (c == 'u')
535         {
536           if (getc (finput) == 'n'
537               && getc (finput) == 'd'
538               && getc (finput) == 'e'
539               && getc (finput) == 'f'
540               && ((c = getc (finput)) == ' ' || c == '\t' || c == '\n'))
541             {
542 #ifdef DWARF_DEBUGGING_INFO
543               if ((debug_info_level == DINFO_LEVEL_VERBOSE)
544                   && (write_symbols == DWARF_DEBUG))
545                 dwarfout_undef (lineno, get_directive_line (finput));
546 #endif /* DWARF_DEBUGGING_INFO */
547               goto skipline;
548             }
549         }
550       else if (c == 'l')
551         {
552           if (getc (finput) == 'i'
553               && getc (finput) == 'n'
554               && getc (finput) == 'e'
555               && ((c = getc (finput)) == ' ' || c == '\t'))
556             goto linenum;
557         }
558       else if (c == 'i')
559         {
560           if (getc (finput) == 'd'
561               && getc (finput) == 'e'
562               && getc (finput) == 'n'
563               && getc (finput) == 't'
564               && ((c = getc (finput)) == ' ' || c == '\t'))
565             {
566               /* #ident.  The pedantic warning is now in cccp.c.  */
567
568               /* Here we have just seen `#ident '.
569                  A string constant should follow.  */
570
571               while (c == ' ' || c == '\t')
572                 c = getc (finput);
573
574               /* If no argument, ignore the line.  */
575               if (c == '\n')
576                 return c;
577
578               ungetc (c, finput);
579               token = yylex ();
580               if (token != STRING
581                   || TREE_CODE (yylval.ttype) != STRING_CST)
582                 {
583                   error ("invalid #ident");
584                   goto skipline;
585                 }
586
587               if (!flag_no_ident)
588                 {
589 #ifdef ASM_OUTPUT_IDENT
590                   ASM_OUTPUT_IDENT (asm_out_file, TREE_STRING_POINTER (yylval.ttype));
591 #endif
592                 }
593
594               /* Skip the rest of this line.  */
595               goto skipline;
596             }
597         }
598
599       error ("undefined or invalid # directive");
600       goto skipline;
601     }
602
603 linenum:
604   /* Here we have either `#line' or `# <nonletter>'.
605      In either case, it should be a line number; a digit should follow.  */
606
607   while (c == ' ' || c == '\t')
608     c = getc (finput);
609
610   /* If the # is the only nonwhite char on the line,
611      just ignore it.  Check the new newline.  */
612   if (c == '\n')
613     return c;
614
615   /* Something follows the #; read a token.  */
616
617   ungetc (c, finput);
618   token = yylex ();
619
620   if (token == CONSTANT
621       && TREE_CODE (yylval.ttype) == INTEGER_CST)
622     {
623       int old_lineno = lineno;
624       int used_up = 0;
625       /* subtract one, because it is the following line that
626          gets the specified number */
627
628       int l = TREE_INT_CST_LOW (yylval.ttype) - 1;
629
630       /* Is this the last nonwhite stuff on the line?  */
631       c = getc (finput);
632       while (c == ' ' || c == '\t')
633         c = getc (finput);
634       if (c == '\n')
635         {
636           /* No more: store the line number and check following line.  */
637           lineno = l;
638           return c;
639         }
640       ungetc (c, finput);
641
642       /* More follows: it must be a string constant (filename).  */
643
644       /* Read the string constant, but don't treat \ as special.  */
645       ignore_escape_flag = 1;
646       token = yylex ();
647       ignore_escape_flag = 0;
648
649       if (token != STRING || TREE_CODE (yylval.ttype) != STRING_CST)
650         {
651           error ("invalid #line");
652           goto skipline;
653         }
654
655       input_filename
656         = (char *) permalloc (TREE_STRING_LENGTH (yylval.ttype) + 1);
657       strcpy (input_filename, TREE_STRING_POINTER (yylval.ttype));
658       lineno = l;
659
660       /* Each change of file name
661          reinitializes whether we are now in a system header.  */
662       in_system_header = 0;
663
664       if (main_input_filename == 0)
665         main_input_filename = input_filename;
666
667       /* Is this the last nonwhite stuff on the line?  */
668       c = getc (finput);
669       while (c == ' ' || c == '\t')
670         c = getc (finput);
671       if (c == '\n')
672         {
673           /* Update the name in the top element of input_file_stack.  */
674           if (input_file_stack)
675             input_file_stack->name = input_filename;
676
677           return c;
678         }
679       ungetc (c, finput);
680
681       token = yylex ();
682       used_up = 0;
683
684       /* `1' after file name means entering new file.
685          `2' after file name means just left a file.  */
686
687       if (token == CONSTANT
688           && TREE_CODE (yylval.ttype) == INTEGER_CST)
689         {
690           if (TREE_INT_CST_LOW (yylval.ttype) == 1)
691             {
692               /* Pushing to a new file.  */
693               struct file_stack *p
694                 = (struct file_stack *) xmalloc (sizeof (struct file_stack));
695               input_file_stack->line = old_lineno;
696               p->next = input_file_stack;
697               p->name = input_filename;
698               input_file_stack = p;
699               input_file_stack_tick++;
700 #ifdef DWARF_DEBUGGING_INFO
701               if (debug_info_level == DINFO_LEVEL_VERBOSE
702                   && write_symbols == DWARF_DEBUG)
703                 dwarfout_start_new_source_file (input_filename);
704 #endif /* DWARF_DEBUGGING_INFO */
705
706               used_up = 1;
707             }
708           else if (TREE_INT_CST_LOW (yylval.ttype) == 2)
709             {
710               /* Popping out of a file.  */
711               if (input_file_stack->next)
712                 {
713                   struct file_stack *p = input_file_stack;
714                   input_file_stack = p->next;
715                   free (p);
716                   input_file_stack_tick++;
717 #ifdef DWARF_DEBUGGING_INFO
718                   if (debug_info_level == DINFO_LEVEL_VERBOSE
719                       && write_symbols == DWARF_DEBUG)
720                     dwarfout_resume_previous_source_file (input_file_stack->line);
721 #endif /* DWARF_DEBUGGING_INFO */
722                 }
723               else
724                 error ("#-lines for entering and leaving files don't match");
725
726               used_up = 1;
727             }
728         }
729
730       /* Now that we've pushed or popped the input stack,
731          update the name in the top element.  */
732       if (input_file_stack)
733         input_file_stack->name = input_filename;
734
735       /* If we have handled a `1' or a `2',
736          see if there is another number to read.  */
737       if (used_up)
738         {
739           /* Is this the last nonwhite stuff on the line?  */
740           c = getc (finput);
741           while (c == ' ' || c == '\t')
742             c = getc (finput);
743           if (c == '\n')
744             return c;
745           ungetc (c, finput);
746
747           token = yylex ();
748           used_up = 0;
749         }
750
751       /* `3' after file name means this is a system header file.  */
752
753       if (token == CONSTANT
754           && TREE_CODE (yylval.ttype) == INTEGER_CST
755           && TREE_INT_CST_LOW (yylval.ttype) == 3)
756         in_system_header = 1;
757     }
758   else
759     error ("invalid #-line");
760
761   /* skip the rest of this line.  */
762  skipline:
763   if (c == '\n')
764     return c;
765   while ((c = getc (finput)) != EOF && c != '\n');
766   return c;
767 }
768 \f
769 #ifdef HANDLE_SYSV_PRAGMA
770
771 /* Handle a #pragma directive.  INPUT is the current input stream,
772    and C is a character to reread.  Processes the entire input line
773    and returns a character for the caller to reread: either \n or EOF.  */
774
775 /* This function has to be in this file, in order to get at
776    the token types.  */
777
778 int
779 handle_sysv_pragma (input, c)
780      FILE *input;
781      int c;
782 {
783   for (;;)
784     {
785       while (c == ' ' || c == '\t')
786         c = getc (input);
787       if (c == '\n' || c == EOF)
788         {
789           handle_pragma_token (0, 0);
790           return c;
791         }
792       ungetc (c, input);
793       switch (yylex ())
794         {
795         case IDENTIFIER:
796         case TYPENAME:
797         case STRING:
798         case CONSTANT:
799           handle_pragma_token (token_buffer, yylval.ttype);
800           break;
801         default:
802           handle_pragma_token (token_buffer, 0);
803         }
804       if (nextchar >= 0)
805         c = nextchar, nextchar = -1;
806       else
807         c = getc (input);
808     }
809 }
810
811 #endif /* HANDLE_SYSV_PRAGMA */
812 \f
813 #define isalnum(char) ((char >= 'a' && char <= 'z') || (char >= 'A' && char <= 'Z') || (char >= '0' && char <= '9'))
814 #define isdigit(char) (char >= '0' && char <= '9')
815 #define ENDFILE -1  /* token that represents end-of-file */
816
817 /* Read an escape sequence, returning its equivalent as a character,
818    or store 1 in *ignore_ptr if it is backslash-newline.  */
819
820 static int
821 readescape (ignore_ptr)
822      int *ignore_ptr;
823 {
824   register int c = getc (finput);
825   register int code;
826   register unsigned count;
827   unsigned firstdig;
828   int nonnull;
829
830   switch (c)
831     {
832     case 'x':
833       if (warn_traditional)
834         warning ("the meaning of `\\x' varies with -traditional");
835
836       if (flag_traditional)
837         return c;
838
839       code = 0;
840       count = 0;
841       nonnull = 0;
842       while (1)
843         {
844           c = getc (finput);
845           if (!(c >= 'a' && c <= 'f')
846               && !(c >= 'A' && c <= 'F')
847               && !(c >= '0' && c <= '9'))
848             {
849               ungetc (c, finput);
850               break;
851             }
852           code *= 16;
853           if (c >= 'a' && c <= 'f')
854             code += c - 'a' + 10;
855           if (c >= 'A' && c <= 'F')
856             code += c - 'A' + 10;
857           if (c >= '0' && c <= '9')
858             code += c - '0';
859           if (code != 0 || count != 0)
860             {
861               if (count == 0)
862                 firstdig = code;
863               count++;
864             }
865           nonnull = 1;
866         }
867       if (! nonnull)
868         error ("\\x used with no following hex digits");
869       else if (count == 0)
870         /* Digits are all 0's.  Ok.  */
871         ;
872       else if ((count - 1) * 4 >= TYPE_PRECISION (integer_type_node)
873                || (count > 1
874                    && ((1 << (TYPE_PRECISION (integer_type_node) - (count - 1) * 4))
875                        <= firstdig)))
876         pedwarn ("hex escape out of range");
877       return code;
878
879     case '0':  case '1':  case '2':  case '3':  case '4':
880     case '5':  case '6':  case '7':
881       code = 0;
882       count = 0;
883       while ((c <= '7') && (c >= '0') && (count++ < 3))
884         {
885           code = (code * 8) + (c - '0');
886           c = getc (finput);
887         }
888       ungetc (c, finput);
889       return code;
890
891     case '\\': case '\'': case '"':
892       return c;
893
894     case '\n':
895       lineno++;
896       *ignore_ptr = 1;
897       return 0;
898
899     case 'n':
900       return TARGET_NEWLINE;
901
902     case 't':
903       return TARGET_TAB;
904
905     case 'r':
906       return TARGET_CR;
907
908     case 'f':
909       return TARGET_FF;
910
911     case 'b':
912       return TARGET_BS;
913
914     case 'a':
915       if (warn_traditional)
916         warning ("the meaning of `\\a' varies with -traditional");
917
918       if (flag_traditional)
919         return c;
920       return TARGET_BELL;
921
922     case 'v':
923 #if 0 /* Vertical tab is present in common usage compilers.  */
924       if (flag_traditional)
925         return c;
926 #endif
927       return TARGET_VT;
928
929     case 'e':
930     case 'E':
931       if (pedantic)
932         pedwarn ("non-ANSI-standard escape sequence, `\\%c'", c);
933       return 033;
934
935     case '?':
936       return c;
937
938       /* `\(', etc, are used at beginning of line to avoid confusing Emacs.  */
939     case '(':
940     case '{':
941     case '[':
942       if (pedantic)
943         pedwarn ("non-ANSI escape sequence `\\%c'", c);
944       return c;
945     }
946   if (c >= 040 && c < 0177)
947     pedwarn ("unknown escape sequence `\\%c'", c);
948   else
949     pedwarn ("unknown escape sequence: `\\' followed by char code 0x%x", c);
950   return c;
951 }
952 \f
953 void
954 yyerror (string)
955      char *string;
956 {
957   char buf[200];
958
959   strcpy (buf, string);
960
961   /* We can't print string and character constants well
962      because the token_buffer contains the result of processing escapes.  */
963   if (end_of_file)
964     strcat (buf, " at end of input");
965   else if (token_buffer[0] == 0)
966     strcat (buf, " at null character");
967   else if (token_buffer[0] == '"')
968     strcat (buf, " before string constant");
969   else if (token_buffer[0] == '\'')
970     strcat (buf, " before character constant");
971   else if (token_buffer[0] < 040 || (unsigned char) token_buffer[0] >= 0177)
972     sprintf (buf + strlen (buf), " before character 0%o",
973              (unsigned char) token_buffer[0]);
974   else
975     strcat (buf, " before `%s'");
976
977   error (buf, token_buffer);
978 }
979
980 #if 0
981
982 struct try_type
983 {
984   tree *node_var;
985   char unsigned_flag;
986   char long_flag;
987   char long_long_flag;
988 };
989
990 struct try_type type_sequence[] = 
991 {
992   { &integer_type_node, 0, 0, 0},
993   { &unsigned_type_node, 1, 0, 0},
994   { &long_integer_type_node, 0, 1, 0},
995   { &long_unsigned_type_node, 1, 1, 0},
996   { &long_long_integer_type_node, 0, 1, 1},
997   { &long_long_unsigned_type_node, 1, 1, 1}
998 };
999 #endif /* 0 */
1000 \f
1001 int
1002 yylex ()
1003 {
1004   register int c;
1005   register char *p;
1006   register int value;
1007   int wide_flag = 0;
1008
1009   if (nextchar >= 0)
1010     c = nextchar, nextchar = -1;
1011   else
1012     c = getc (finput);
1013
1014   /* Effectively do c = skip_white_space (c)
1015      but do it faster in the usual cases.  */
1016   while (1)
1017     switch (c)
1018       {
1019       case ' ':
1020       case '\t':
1021       case '\f':
1022       case '\v':
1023       case '\b':
1024         c = getc (finput);
1025         break;
1026
1027       case '\r':
1028         /* Call skip_white_space so we can warn if appropriate.  */
1029
1030       case '\n':
1031       case '/':
1032       case '\\':
1033         c = skip_white_space (c);
1034       default:
1035         goto found_nonwhite;
1036       }
1037  found_nonwhite:
1038
1039   token_buffer[0] = c;
1040   token_buffer[1] = 0;
1041
1042 /*  yylloc.first_line = lineno; */
1043
1044   switch (c)
1045     {
1046     case EOF:
1047       end_of_file = 1;
1048       token_buffer[0] = 0;
1049       value = ENDFILE;
1050       break;
1051
1052     case '$':
1053       if (dollars_in_ident)
1054         goto letter;
1055       return '$';
1056
1057     case 'L':
1058       /* Capital L may start a wide-string or wide-character constant.  */
1059       {
1060         register int c = getc (finput);
1061         if (c == '\'')
1062           {
1063             wide_flag = 1;
1064             goto char_constant;
1065           }
1066         if (c == '"')
1067           {
1068             wide_flag = 1;
1069             goto string_constant;
1070           }
1071         ungetc (c, finput);
1072       }
1073       goto letter;
1074
1075     case '@':
1076       if (!doing_objc_thang)
1077         {
1078           value = c;
1079           break;
1080         }
1081       p = token_buffer;
1082       *p++ = '@';
1083       c = getc (finput);
1084       while (isalnum (c) || c == '_')
1085         {
1086           if (p >= token_buffer + maxtoken)
1087             p = extend_token_buffer (p);
1088
1089           *p++ = c;
1090           c = getc (finput);
1091         }
1092
1093       *p = 0;
1094       nextchar = c;
1095       value = recognize_objc_keyword (token_buffer + 1);
1096       if (value != 0)
1097         break;
1098       error ("invalid Objective C keyword `%s'", token_buffer);
1099       /* Cause a syntax error--1 is not a valid token type.  */
1100       value = 1;
1101       break;
1102
1103     case 'A':  case 'B':  case 'C':  case 'D':  case 'E':
1104     case 'F':  case 'G':  case 'H':  case 'I':  case 'J':
1105     case 'K':             case 'M':  case 'N':  case 'O':
1106     case 'P':  case 'Q':  case 'R':  case 'S':  case 'T':
1107     case 'U':  case 'V':  case 'W':  case 'X':  case 'Y':
1108     case 'Z':
1109     case 'a':  case 'b':  case 'c':  case 'd':  case 'e':
1110     case 'f':  case 'g':  case 'h':  case 'i':  case 'j':
1111     case 'k':  case 'l':  case 'm':  case 'n':  case 'o':
1112     case 'p':  case 'q':  case 'r':  case 's':  case 't':
1113     case 'u':  case 'v':  case 'w':  case 'x':  case 'y':
1114     case 'z':
1115     case '_':
1116     letter:
1117       p = token_buffer;
1118       while (isalnum (c) || c == '_' || c == '$' || c == '@')
1119         {
1120           /* Make sure this char really belongs in an identifier.  */
1121           if (c == '@' && ! doing_objc_thang)
1122             break;
1123           if (c == '$' && ! dollars_in_ident)
1124             break;
1125
1126           if (p >= token_buffer + maxtoken)
1127             p = extend_token_buffer (p);
1128
1129           *p++ = c;
1130           c = getc (finput);
1131         }
1132
1133       *p = 0;
1134       nextchar = c;
1135
1136       value = IDENTIFIER;
1137       yylval.itype = 0;
1138
1139       /* Try to recognize a keyword.  Uses minimum-perfect hash function */
1140
1141       {
1142         register struct resword *ptr;
1143
1144         if (ptr = is_reserved_word (token_buffer, p - token_buffer))
1145           {
1146             if (ptr->rid)
1147               yylval.ttype = ridpointers[(int) ptr->rid];
1148             value = (int) ptr->token;
1149
1150             /* Even if we decided to recognize asm, still perhaps warn.  */
1151             if (pedantic
1152                 && (value == ASM_KEYWORD || value == TYPEOF
1153                     || ptr->rid == RID_INLINE)
1154                 && token_buffer[0] != '_')
1155               pedwarn ("ANSI does not permit the keyword `%s'",
1156                        token_buffer);
1157           }
1158       }
1159
1160       /* If we did not find a keyword, look for an identifier
1161          (or a typename).  */
1162
1163       if (value == IDENTIFIER)
1164         {
1165           yylval.ttype = get_identifier (token_buffer);
1166           lastiddecl = lookup_name (yylval.ttype);
1167
1168           if (lastiddecl != 0 && TREE_CODE (lastiddecl) == TYPE_DECL)
1169             value = TYPENAME;
1170           /* A user-invisible read-only initialized variable
1171              should be replaced by its value.
1172              We handle only strings since that's the only case used in C.  */
1173           else if (lastiddecl != 0 && TREE_CODE (lastiddecl) == VAR_DECL
1174                    && DECL_IGNORED_P (lastiddecl)
1175                    && TREE_READONLY (lastiddecl)
1176                    && DECL_INITIAL (lastiddecl) != 0
1177                    && TREE_CODE (DECL_INITIAL (lastiddecl)) == STRING_CST)
1178             {
1179               tree stringval = DECL_INITIAL (lastiddecl);
1180               
1181               /* Copy the string value so that we won't clobber anything
1182                  if we put something in the TREE_CHAIN of this one.  */
1183               yylval.ttype = build_string (TREE_STRING_LENGTH (stringval),
1184                                            TREE_STRING_POINTER (stringval));
1185               value = STRING;
1186             }
1187           else if (doing_objc_thang)
1188             {
1189               tree objc_interface_decl = lookup_interface (yylval.ttype);
1190
1191               if (objc_interface_decl)
1192                 {
1193                   value = CLASSNAME;
1194                   yylval.ttype = objc_interface_decl;
1195                 }
1196             }
1197         }
1198
1199       break;
1200
1201     case '0':  case '1':  case '2':  case '3':  case '4':
1202     case '5':  case '6':  case '7':  case '8':  case '9':
1203     case '.':
1204       {
1205         int base = 10;
1206         int count = 0;
1207         int largest_digit = 0;
1208         int numdigits = 0;
1209         /* for multi-precision arithmetic,
1210            we actually store only HOST_BITS_PER_CHAR bits in each part.
1211            The number of parts is chosen so as to be sufficient to hold
1212            the enough bits to fit into the two HOST_WIDE_INTs that contain
1213            the integer value (this is always at least as many bits as are
1214            in a target `long long' value, but may be wider).  */
1215 #define TOTAL_PARTS ((HOST_BITS_PER_WIDE_INT / HOST_BITS_PER_CHAR) * 2 + 2)
1216         int parts[TOTAL_PARTS];
1217         int overflow = 0;
1218
1219         enum anon1 { NOT_FLOAT, AFTER_POINT, TOO_MANY_POINTS} floatflag
1220           = NOT_FLOAT;
1221
1222         for (count = 0; count < TOTAL_PARTS; count++)
1223           parts[count] = 0;
1224
1225         p = token_buffer;
1226         *p++ = c;
1227
1228         if (c == '0')
1229           {
1230             *p++ = (c = getc (finput));
1231             if ((c == 'x') || (c == 'X'))
1232               {
1233                 base = 16;
1234                 *p++ = (c = getc (finput));
1235               }
1236             /* Leading 0 forces octal unless the 0 is the only digit.  */
1237             else if (c >= '0' && c <= '9')
1238               {
1239                 base = 8;
1240                 numdigits++;
1241               }
1242             else
1243               numdigits++;
1244           }
1245
1246         /* Read all the digits-and-decimal-points.  */
1247
1248         while (c == '.'
1249                || (isalnum (c) && c != 'l' && c != 'L'
1250                    && c != 'u' && c != 'U'
1251                    && c != 'i' && c != 'I' && c != 'j' && c != 'J'
1252                    && (floatflag == NOT_FLOAT || ((c != 'f') && (c != 'F')))))
1253           {
1254             if (c == '.')
1255               {
1256                 if (base == 16)
1257                   error ("floating constant may not be in radix 16");
1258                 if (floatflag == AFTER_POINT)
1259                   {
1260                     error ("malformed floating constant");
1261                     floatflag = TOO_MANY_POINTS;
1262                   }
1263                 else
1264                   floatflag = AFTER_POINT;
1265
1266                 base = 10;
1267                 *p++ = c = getc (finput);
1268                 /* Accept '.' as the start of a floating-point number
1269                    only when it is followed by a digit.
1270                    Otherwise, unread the following non-digit
1271                    and use the '.' as a structural token.  */
1272                 if (p == token_buffer + 2 && !isdigit (c))
1273                   {
1274                     if (c == '.')
1275                       {
1276                         c = getc (finput);
1277                         if (c == '.')
1278                           {
1279                             *p++ = c;
1280                             *p = 0;
1281                             return ELLIPSIS;
1282                           }
1283                         error ("parse error at `..'");
1284                       }
1285                     ungetc (c, finput);
1286                     token_buffer[1] = 0;
1287                     value = '.';
1288                     goto done;
1289                   }
1290               }
1291             else
1292               {
1293                 /* It is not a decimal point.
1294                    It should be a digit (perhaps a hex digit).  */
1295
1296                 if (isdigit (c))
1297                   {
1298                     c = c - '0';
1299                   }
1300                 else if (base <= 10)
1301                   {
1302                     if (c == 'e' || c == 'E')
1303                       {
1304                         base = 10;
1305                         floatflag = AFTER_POINT;
1306                         break;   /* start of exponent */
1307                       }
1308                     error ("nondigits in number and not hexadecimal");
1309                     c = 0;
1310                   }
1311                 else if (c >= 'a')
1312                   {
1313                     c = c - 'a' + 10;
1314                   }
1315                 else
1316                   {
1317                     c = c - 'A' + 10;
1318                   }
1319                 if (c >= largest_digit)
1320                   largest_digit = c;
1321                 numdigits++;
1322
1323                 for (count = 0; count < TOTAL_PARTS; count++)
1324                   {
1325                     parts[count] *= base;
1326                     if (count)
1327                       {
1328                         parts[count]
1329                           += (parts[count-1] >> HOST_BITS_PER_CHAR);
1330                         parts[count-1]
1331                           &= (1 << HOST_BITS_PER_CHAR) - 1;
1332                       }
1333                     else
1334                       parts[0] += c;
1335                   }
1336
1337                 /* If the extra highest-order part ever gets anything in it,
1338                    the number is certainly too big.  */
1339                 if (parts[TOTAL_PARTS - 1] != 0)
1340                   overflow = 1;
1341
1342                 if (p >= token_buffer + maxtoken - 3)
1343                   p = extend_token_buffer (p);
1344                 *p++ = (c = getc (finput));
1345               }
1346           }
1347
1348         if (numdigits == 0)
1349           error ("numeric constant with no digits");
1350
1351         if (largest_digit >= base)
1352           error ("numeric constant contains digits beyond the radix");
1353
1354         /* Remove terminating char from the token buffer and delimit the string */
1355         *--p = 0;
1356
1357         if (floatflag != NOT_FLOAT)
1358           {
1359             tree type = double_type_node;
1360             int garbage_chars = 0, exceeds_double = 0;
1361             int imag = 0;
1362             REAL_VALUE_TYPE value;
1363             jmp_buf handler;
1364
1365             /* Read explicit exponent if any, and put it in tokenbuf.  */
1366
1367             if ((c == 'e') || (c == 'E'))
1368               {
1369                 if (p >= token_buffer + maxtoken - 3)
1370                   p = extend_token_buffer (p);
1371                 *p++ = c;
1372                 c = getc (finput);
1373                 if ((c == '+') || (c == '-'))
1374                   {
1375                     *p++ = c;
1376                     c = getc (finput);
1377                   }
1378                 if (! isdigit (c))
1379                   error ("floating constant exponent has no digits");
1380                 while (isdigit (c))
1381                   {
1382                     if (p >= token_buffer + maxtoken - 3)
1383                       p = extend_token_buffer (p);
1384                     *p++ = c;
1385                     c = getc (finput);
1386                   }
1387               }
1388
1389             *p = 0;
1390             errno = 0;
1391
1392             /* Convert string to a double, checking for overflow.  */
1393             if (setjmp (handler))
1394               {
1395                 error ("floating constant out of range");
1396                 value = dconst0;
1397               }
1398             else
1399               {
1400                 set_float_handler (handler);
1401
1402 /* The second argument, machine_mode, of REAL_VALUE_ATOF tells the
1403    desired precision of the binary result of decimal-to-binary conversion.  */
1404
1405             /* Read the suffixes to choose a data type.  */
1406             switch (c)
1407               {
1408               case 'f': case 'F':
1409                 type = float_type_node;
1410                 value = REAL_VALUE_ATOF (token_buffer, TYPE_MODE (type));
1411                 if (REAL_VALUE_ISINF (value) && pedantic)
1412                   pedwarn ("floating point number exceeds range of `float'");
1413                 garbage_chars = -1;
1414                 break;
1415
1416               case 'l': case 'L':
1417                 type = long_double_type_node;
1418                 value = REAL_VALUE_ATOF (token_buffer, TYPE_MODE (type));
1419                 if (REAL_VALUE_ISINF (value) && pedantic)
1420                   pedwarn (
1421                       "floating point number exceeds range of `long double'");
1422                 garbage_chars = -1;
1423                 break;
1424
1425               case 'i': case 'I':
1426                 if (imag)
1427                   error ("more than one `i' or `j' in numeric constant");
1428                 imag = 1;
1429                 garbage_chars = -1;
1430                 break;
1431
1432               default:
1433                 value = REAL_VALUE_ATOF (token_buffer, TYPE_MODE (type));
1434                 if (REAL_VALUE_ISINF (value) && pedantic)
1435                   pedwarn ("floating point number exceeds range of `double'");
1436               }
1437             set_float_handler (NULL_PTR);
1438             }
1439 #ifdef ERANGE
1440             if (errno == ERANGE && !flag_traditional && pedantic)
1441               {
1442                 /* ERANGE is also reported for underflow,
1443                    so test the value to distinguish overflow from that.  */
1444                 if (REAL_VALUES_LESS (dconst1, value)
1445                     || REAL_VALUES_LESS (value, dconstm1))
1446                   {
1447                     pedwarn ("floating point number exceeds range of `double'");
1448                     exceeds_double = 1;
1449                   }
1450               }
1451 #endif
1452             /* Note: garbage_chars is -1 if first char is *not* garbage.  */
1453             while (isalnum (c) || c == '.' || c == '_'
1454                    || (!flag_traditional && (c == '+' || c == '-')
1455                        && (p[-1] == 'e' || p[-1] == 'E')))
1456               {
1457                 if (p >= token_buffer + maxtoken - 3)
1458                   p = extend_token_buffer (p);
1459                 *p++ = c;
1460                 c = getc (finput);
1461                 garbage_chars++;
1462               }
1463             if (garbage_chars > 0)
1464               error ("garbage at end of number");
1465
1466             /* Create a node with determined type and value.  */
1467             if (imag)
1468               yylval.ttype = build_complex (convert (type, integer_zero_node),
1469                                             build_real (type, value));
1470             else
1471               yylval.ttype = build_real (type, value);
1472
1473             ungetc (c, finput);
1474             *p = 0;
1475           }
1476         else
1477           {
1478             tree traditional_type, ansi_type, type;
1479             HOST_WIDE_INT high, low;
1480             int spec_unsigned = 0;
1481             int spec_long = 0;
1482             int spec_long_long = 0;
1483             int spec_imag = 0;
1484             int bytes, warn, i;
1485
1486             while (1)
1487               {
1488                 if (c == 'u' || c == 'U')
1489                   {
1490                     if (spec_unsigned)
1491                       error ("two `u's in integer constant");
1492                     spec_unsigned = 1;
1493                   }
1494                 else if (c == 'l' || c == 'L')
1495                   {
1496                     if (spec_long)
1497                       {
1498                         if (spec_long_long)
1499                           error ("three `l's in integer constant");
1500                         else if (pedantic)
1501                           pedwarn ("ANSI C forbids long long integer constants");
1502                         spec_long_long = 1;
1503                       }
1504                     spec_long = 1;
1505                   }
1506                 else if (c == 'i' || c == 'j' || c == 'I' || c == 'J')
1507                   {
1508                     if (spec_imag)
1509                       error ("more than one `i' or `j' in numeric constant");
1510                     spec_imag = 1;
1511                   }
1512                 else
1513                   {
1514                     if (isalnum (c) || c == '.' || c == '_'
1515                         || (!flag_traditional && (c == '+' || c == '-')
1516                             && (p[-1] == 'e' || p[-1] == 'E')))
1517                       {
1518                         error ("garbage at end of number");
1519                         while (isalnum (c) || c == '.' || c == '_'
1520                                || (!flag_traditional && (c == '+' || c == '-')
1521                                    && (p[-1] == 'e' || p[-1] == 'E')))
1522                           {
1523                             if (p >= token_buffer + maxtoken - 3)
1524                               p = extend_token_buffer (p);
1525                             *p++ = c;
1526                             c = getc (finput);
1527                           }
1528                       }
1529                     break;
1530                   }
1531                 if (p >= token_buffer + maxtoken - 3)
1532                   p = extend_token_buffer (p);
1533                 *p++ = c;
1534                 c = getc (finput);
1535               }
1536
1537             ungetc (c, finput);
1538
1539             /* If the constant is not long long and it won't fit in an
1540                unsigned long, or if the constant is long long and won't fit
1541                in an unsigned long long, then warn that the constant is out
1542                of range.  */
1543
1544             /* ??? This assumes that long long and long integer types are
1545                a multiple of 8 bits.  This better than the original code
1546                though which assumed that long was exactly 32 bits and long
1547                long was exactly 64 bits.  */
1548
1549             if (spec_long_long)
1550               bytes = TYPE_PRECISION (long_long_integer_type_node) / 8;
1551             else
1552               bytes = TYPE_PRECISION (long_integer_type_node) / 8;
1553
1554             warn = overflow;
1555             for (i = bytes; i < TOTAL_PARTS; i++)
1556               if (parts[i])
1557                 warn = 1;
1558             if (warn)
1559               pedwarn ("integer constant out of range");
1560
1561             /* This is simplified by the fact that our constant
1562                is always positive.  */
1563
1564             high = low = 0;
1565
1566             for (i = 0; i < HOST_BITS_PER_WIDE_INT / HOST_BITS_PER_CHAR; i++)
1567               {
1568                 high |= ((HOST_WIDE_INT) parts[i + (HOST_BITS_PER_WIDE_INT
1569                                                     / HOST_BITS_PER_CHAR)]
1570                          << (i * HOST_BITS_PER_CHAR));
1571                 low |= (HOST_WIDE_INT) parts[i] << (i * HOST_BITS_PER_CHAR);
1572               }
1573             
1574             yylval.ttype = build_int_2 (low, high);
1575             TREE_TYPE (yylval.ttype) = long_long_unsigned_type_node;
1576
1577             /* If warn_traditional, calculate both the ANSI type and the
1578                traditional type, then see if they disagree.
1579                Otherwise, calculate only the type for the dialect in use.  */
1580             if (warn_traditional || flag_traditional)
1581               {
1582                 /* Calculate the traditional type.  */
1583                 /* Traditionally, any constant is signed;
1584                    but if unsigned is specified explicitly, obey that.
1585                    Use the smallest size with the right number of bits,
1586                    except for one special case with decimal constants.  */
1587                 if (! spec_long && base != 10
1588                     && int_fits_type_p (yylval.ttype, unsigned_type_node))
1589                   traditional_type = (spec_unsigned ? unsigned_type_node
1590                                       : integer_type_node);
1591                 /* A decimal constant must be long
1592                    if it does not fit in type int.
1593                    I think this is independent of whether
1594                    the constant is signed.  */
1595                 else if (! spec_long && base == 10
1596                          && int_fits_type_p (yylval.ttype, integer_type_node))
1597                   traditional_type = (spec_unsigned ? unsigned_type_node
1598                                       : integer_type_node);
1599                 else if (! spec_long_long)
1600                   traditional_type = (spec_unsigned ? long_unsigned_type_node
1601                                       : long_integer_type_node);
1602                 else
1603                   traditional_type = (spec_unsigned
1604                                       ? long_long_unsigned_type_node
1605                                       : long_long_integer_type_node);
1606               }
1607             if (warn_traditional || ! flag_traditional)
1608               {
1609                 /* Calculate the ANSI type.  */
1610                 if (! spec_long && ! spec_unsigned
1611                     && int_fits_type_p (yylval.ttype, integer_type_node))
1612                   ansi_type = integer_type_node;
1613                 else if (! spec_long && (base != 10 || spec_unsigned)
1614                          && int_fits_type_p (yylval.ttype, unsigned_type_node))
1615                   ansi_type = unsigned_type_node;
1616                 else if (! spec_unsigned && !spec_long_long
1617                          && int_fits_type_p (yylval.ttype, long_integer_type_node))
1618                   ansi_type = long_integer_type_node;
1619                 else if (! spec_long_long)
1620                   ansi_type = long_unsigned_type_node;
1621                 else if (! spec_unsigned
1622                          /* Verify value does not overflow into sign bit.  */
1623                          && TREE_INT_CST_HIGH (yylval.ttype) >= 0
1624                          && int_fits_type_p (yylval.ttype,
1625                                              long_long_integer_type_node))
1626                   ansi_type = long_long_integer_type_node;
1627                 else
1628                   ansi_type = long_long_unsigned_type_node;
1629               }
1630
1631             type = flag_traditional ? traditional_type : ansi_type;
1632
1633             if (warn_traditional && traditional_type != ansi_type)
1634               {
1635                 if (TYPE_PRECISION (traditional_type)
1636                     != TYPE_PRECISION (ansi_type))
1637                   warning ("width of integer constant changes with -traditional");
1638                 else if (TREE_UNSIGNED (traditional_type)
1639                          != TREE_UNSIGNED (ansi_type))
1640                   warning ("integer constant is unsigned in ANSI C, signed with -traditional");
1641                 else
1642                   warning ("width of integer constant may change on other systems with -traditional");
1643               }
1644
1645             if (!flag_traditional && !int_fits_type_p (yylval.ttype, type)
1646                 && !warn)
1647               pedwarn ("integer constant out of range");
1648
1649             if (base == 10 && ! spec_unsigned && TREE_UNSIGNED (type))
1650               warning ("decimal constant is so large that it is unsigned");
1651
1652             if (spec_imag)
1653               {
1654                 if (TYPE_PRECISION (type)
1655                     <= TYPE_PRECISION (integer_type_node))
1656                   yylval.ttype
1657                     = build_complex (integer_zero_node,
1658                                      convert (integer_type_node, yylval.ttype));
1659                 else
1660                   error ("complex integer constant is too wide for `complex int'");
1661               }
1662             else if (flag_traditional && !int_fits_type_p (yylval.ttype, type))
1663               /* The traditional constant 0x80000000 is signed
1664                  but doesn't fit in the range of int.
1665                  This will change it to -0x80000000, which does fit.  */
1666               {
1667                 TREE_TYPE (yylval.ttype) = unsigned_type (type);
1668                 yylval.ttype = convert (type, yylval.ttype);
1669               }
1670             else
1671               TREE_TYPE (yylval.ttype) = type;
1672
1673             *p = 0;
1674           }
1675
1676         value = CONSTANT; break;
1677       }
1678
1679     case '\'':
1680     char_constant:
1681       {
1682         register int result = 0;
1683         register int num_chars = 0;
1684         unsigned width = TYPE_PRECISION (char_type_node);
1685         int max_chars;
1686
1687         if (wide_flag)
1688           {
1689             width = WCHAR_TYPE_SIZE;
1690 #ifdef MULTIBYTE_CHARS
1691             max_chars = MB_CUR_MAX;
1692 #else
1693             max_chars = 1;
1694 #endif
1695           }
1696         else
1697           max_chars = TYPE_PRECISION (integer_type_node) / width;
1698
1699         while (1)
1700           {
1701           tryagain:
1702
1703             c = getc (finput);
1704
1705             if (c == '\'' || c == EOF)
1706               break;
1707
1708             if (c == '\\')
1709               {
1710                 int ignore = 0;
1711                 c = readescape (&ignore);
1712                 if (ignore)
1713                   goto tryagain;
1714                 if (width < HOST_BITS_PER_INT
1715                     && (unsigned) c >= (1 << width))
1716                   pedwarn ("escape sequence out of range for character");
1717 #ifdef MAP_CHARACTER
1718                 if (isprint (c))
1719                   c = MAP_CHARACTER (c);
1720 #endif
1721               }
1722             else if (c == '\n')
1723               {
1724                 if (pedantic)
1725                   pedwarn ("ANSI C forbids newline in character constant");
1726                 lineno++;
1727               }
1728 #ifdef MAP_CHARACTER
1729             else
1730               c = MAP_CHARACTER (c);
1731 #endif
1732
1733             num_chars++;
1734             if (num_chars > maxtoken - 4)
1735               extend_token_buffer (token_buffer);
1736
1737             token_buffer[num_chars] = c;
1738
1739             /* Merge character into result; ignore excess chars.  */
1740             if (num_chars < max_chars + 1)
1741               {
1742                 if (width < HOST_BITS_PER_INT)
1743                   result = (result << width) | (c & ((1 << width) - 1));
1744                 else
1745                   result = c;
1746               }
1747           }
1748
1749         token_buffer[num_chars + 1] = '\'';
1750         token_buffer[num_chars + 2] = 0;
1751
1752         if (c != '\'')
1753           error ("malformatted character constant");
1754         else if (num_chars == 0)
1755           error ("empty character constant");
1756         else if (num_chars > max_chars)
1757           {
1758             num_chars = max_chars;
1759             error ("character constant too long");
1760           }
1761         else if (num_chars != 1 && ! flag_traditional)
1762           warning ("multi-character character constant");
1763
1764         /* If char type is signed, sign-extend the constant.  */
1765         if (! wide_flag)
1766           {
1767             int num_bits = num_chars * width;
1768             if (TREE_UNSIGNED (char_type_node)
1769                 || ((result >> (num_bits - 1)) & 1) == 0)
1770               yylval.ttype
1771                 = build_int_2 (result & ((unsigned HOST_WIDE_INT) ~0
1772                                          >> (HOST_BITS_PER_WIDE_INT - num_bits)),
1773                                0);
1774             else
1775               yylval.ttype
1776                 = build_int_2 (result | ~((unsigned HOST_WIDE_INT) ~0
1777                                           >> (HOST_BITS_PER_WIDE_INT - num_bits)),
1778                                -1);
1779             TREE_TYPE (yylval.ttype) = integer_type_node;
1780           }
1781         else
1782           {
1783 #ifdef MULTIBYTE_CHARS
1784             /* Set the initial shift state and convert the next sequence.  */
1785             result = 0;
1786             /* In all locales L'\0' is zero and mbtowc will return zero,
1787                so don't use it.  */
1788             if (num_chars > 1
1789                 || (num_chars == 1 && token_buffer[1] != '\0'))
1790               {
1791                 wchar_t wc;
1792                 (void) mbtowc (NULL_PTR, NULL_PTR, 0);
1793                 if (mbtowc (& wc, token_buffer + 1, num_chars) == num_chars)
1794                   result = wc;
1795                 else
1796                   warning ("Ignoring invalid multibyte character");
1797               }
1798 #endif
1799             yylval.ttype = build_int_2 (result, 0);
1800             TREE_TYPE (yylval.ttype) = wchar_type_node;
1801           }
1802
1803         value = CONSTANT;
1804         break;
1805       }
1806
1807     case '"':
1808     string_constant:
1809       {
1810         c = getc (finput);
1811         p = token_buffer + 1;
1812
1813         while (c != '"' && c >= 0)
1814           {
1815             /* ignore_escape_flag is set for reading the filename in #line.  */
1816             if (!ignore_escape_flag && c == '\\')
1817               {
1818                 int ignore = 0;
1819                 c = readescape (&ignore);
1820                 if (ignore)
1821                   goto skipnewline;
1822                 if (!wide_flag
1823                     && TYPE_PRECISION (char_type_node) < HOST_BITS_PER_INT
1824                     && c >= (1 << TYPE_PRECISION (char_type_node)))
1825                   pedwarn ("escape sequence out of range for character");
1826               }
1827             else if (c == '\n')
1828               {
1829                 if (pedantic)
1830                   pedwarn ("ANSI C forbids newline in string constant");
1831                 lineno++;
1832               }
1833
1834             if (p == token_buffer + maxtoken)
1835               p = extend_token_buffer (p);
1836             *p++ = c;
1837
1838           skipnewline:
1839             c = getc (finput);
1840           }
1841         *p = 0;
1842
1843         /* We have read the entire constant.
1844            Construct a STRING_CST for the result.  */
1845
1846         if (wide_flag)
1847           {
1848             /* If this is a L"..." wide-string, convert the multibyte string
1849                to a wide character string.  */
1850             char *widep = (char *) alloca ((p - token_buffer) * WCHAR_BYTES);
1851             int len;
1852
1853 #ifdef MULTIBYTE_CHARS
1854             len = mbstowcs ((wchar_t *) widep, token_buffer + 1, p - token_buffer);
1855             if ((unsigned) len >= (p - token_buffer))
1856               {
1857                 warning ("Ignoring invalid multibyte string");
1858                 len = 0;
1859               }
1860             bzero (widep + (len * WCHAR_BYTES), WCHAR_BYTES);
1861 #else
1862             {
1863               union { long l; char c[sizeof (long)]; } u;
1864               int big_endian;
1865               char *wp, *cp;
1866
1867               /* Determine whether host is little or big endian.  */
1868               u.l = 1;
1869               big_endian = u.c[sizeof (long) - 1];
1870               wp = widep + (big_endian ? WCHAR_BYTES - 1 : 0);
1871
1872               bzero (widep, (p - token_buffer) * WCHAR_BYTES);
1873               for (cp = token_buffer + 1; cp < p; cp++)
1874                 *wp = *cp, wp += WCHAR_BYTES;
1875               len = p - token_buffer - 1;
1876             }
1877 #endif
1878             yylval.ttype = build_string ((len + 1) * WCHAR_BYTES, widep);
1879             TREE_TYPE (yylval.ttype) = wchar_array_type_node;
1880           }
1881         else
1882           {
1883             yylval.ttype = build_string (p - token_buffer, token_buffer + 1);
1884             TREE_TYPE (yylval.ttype) = char_array_type_node;
1885           }
1886
1887         *p++ = '"';
1888         *p = 0;
1889
1890         value = STRING; break;
1891       }
1892
1893     case '+':
1894     case '-':
1895     case '&':
1896     case '|':
1897     case '<':
1898     case '>':
1899     case '*':
1900     case '/':
1901     case '%':
1902     case '^':
1903     case '!':
1904     case '=':
1905       {
1906         register int c1;
1907
1908       combine:
1909
1910         switch (c)
1911           {
1912           case '+':
1913             yylval.code = PLUS_EXPR; break;
1914           case '-':
1915             yylval.code = MINUS_EXPR; break;
1916           case '&':
1917             yylval.code = BIT_AND_EXPR; break;
1918           case '|':
1919             yylval.code = BIT_IOR_EXPR; break;
1920           case '*':
1921             yylval.code = MULT_EXPR; break;
1922           case '/':
1923             yylval.code = TRUNC_DIV_EXPR; break;
1924           case '%':
1925             yylval.code = TRUNC_MOD_EXPR; break;
1926           case '^':
1927             yylval.code = BIT_XOR_EXPR; break;
1928           case LSHIFT:
1929             yylval.code = LSHIFT_EXPR; break;
1930           case RSHIFT:
1931             yylval.code = RSHIFT_EXPR; break;
1932           case '<':
1933             yylval.code = LT_EXPR; break;
1934           case '>':
1935             yylval.code = GT_EXPR; break;
1936           }
1937
1938         token_buffer[1] = c1 = getc (finput);
1939         token_buffer[2] = 0;
1940
1941         if (c1 == '=')
1942           {
1943             switch (c)
1944               {
1945               case '<':
1946                 value = ARITHCOMPARE; yylval.code = LE_EXPR; goto done;
1947               case '>':
1948                 value = ARITHCOMPARE; yylval.code = GE_EXPR; goto done;
1949               case '!':
1950                 value = EQCOMPARE; yylval.code = NE_EXPR; goto done;
1951               case '=':
1952                 value = EQCOMPARE; yylval.code = EQ_EXPR; goto done;
1953               }
1954             value = ASSIGN; goto done;
1955           }
1956         else if (c == c1)
1957           switch (c)
1958             {
1959             case '+':
1960               value = PLUSPLUS; goto done;
1961             case '-':
1962               value = MINUSMINUS; goto done;
1963             case '&':
1964               value = ANDAND; goto done;
1965             case '|':
1966               value = OROR; goto done;
1967             case '<':
1968               c = LSHIFT;
1969               goto combine;
1970             case '>':
1971               c = RSHIFT;
1972               goto combine;
1973             }
1974         else if ((c == '-') && (c1 == '>'))
1975           { value = POINTSAT; goto done; }
1976         ungetc (c1, finput);
1977         token_buffer[1] = 0;
1978
1979         if ((c == '<') || (c == '>'))
1980           value = ARITHCOMPARE;
1981         else value = c;
1982         goto done;
1983       }
1984
1985     case 0:
1986       /* Don't make yyparse think this is eof.  */
1987       value = 1;
1988       break;
1989
1990     default:
1991       value = c;
1992     }
1993
1994 done:
1995 /*  yylloc.last_line = lineno; */
1996
1997   return value;
1998 }
1999
2000 /* Sets the value of the 'yydebug' variable to VALUE.
2001    This is a function so we don't have to have YYDEBUG defined
2002    in order to build the compiler.  */
2003
2004 void
2005 set_yydebug (value)
2006      int value;
2007 {
2008 #if YYDEBUG != 0
2009   yydebug = value;
2010 #else
2011   warning ("YYDEBUG not defined.");
2012 #endif
2013 }