OSDN Git Service

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